My app is used to construct with Swift 6
and it really works completely effective. Nonetheless, since I’m utilizing Google AdMob for monetization, I’ve to implement the App Monitoring Transparency (ATT) immediate dialog at first of the app.
That is my present implementation:
import SwiftUI
import GoogleMobileAds
import AppTrackingTransparency
class AppDelegate: UIResponder, UIApplicationDelegate {
func utility(_ utility: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize Cellular Advertisements SDK
MobileAds.shared.begin(completionHandler: nil)
// Request ATT authorization after a delay
DispatchQueue.major.asyncAfter(deadline: .now() + 1.0) {
self.requestIDFA()
}
return true
}
func requestIDFA() {
ATTrackingManager.requestTrackingAuthorization { standing in
// Deal with authorization standing
change standing {
case .licensed:
print("ATT: Person licensed monitoring")
case .denied:
print("ATT: Person denied monitoring")
case .restricted:
print("ATT: Monitoring is restricted")
case .notDetermined:
print("ATT: Person has not made a selection")
@unknown default:
print("ATT: Unknown standing")
}
}
}
}
@major
struct MyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var physique: some Scene {
WindowGroup {
ContentView()
}
}
}
I examined with iOS 16 and 17, and it really works as anticipated. However after I examined on iOS 18 emulator, the immediate seems, click on on the Enable
or Not Enable
, and it froze. The consumer selection remains to be registered as ATT: Person licensed monitoring
present within the log (and after exit the app and open once more, the log nonetheless present the right consumer ATT selection).
The issue is relating to string assertion problem. For instance:
Thread 2 Queue : com.apple.root.default-qos (concurrent)
#0 0x00000001023e4214 in _dispatch_assert_queue_fail ()
#12 0x00000001025afb38 in _pthread_wqthread ()
My answer: After making an attempt to debug, I came upon that I solely want to modify from Swift 6
to Swift 5
. And the applying works once more.
My Request: My request is that I nonetheless wish to construct the app with Swift 6
(for future proof functions), how can I accomplish that? Thanks~