8.5 C
Canberra
Tuesday, July 22, 2025

xcode – SwiftUI app freezes on iOS 18 with Swift 6 after ATT permission dialog clicked – thread assertion problem


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~

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles