Search results for

Swift 6

49,195 results found

Post

Replies

Boosts

Views

Activity

SwiftData crashes on insert (Swift 6, Xcode 16, macOS 15)
I'm trying to insert values into my SwiftData container but it crashes on insert context.insert(fhirObject) and the only error I get from Xcode is: @Transient private var _hkID: _SwiftDataNoType? // original-source-range: /Users/cyril/Documents/GitHub/MyApp/MyApp/HealthKit/FHIR/FHIRModels.swift:35:20-35:20 configured as follows: import SwiftData import SwiftUI @main struct MyApp: App { var container: ModelContainer init() { do { let config = ModelConfiguration(cloudKitDatabase: .private(iCloud.com.author.MyApp)) container = try ModelContainer(for: FHIRObservation.self, configurations: config) UserData.shared = UserData(modelContainer: container) } catch { fatalError(Failed to configure SwiftData container.) } } var body: some Scene { WindowGroup { ContentView() .environmentObject(UserData.shared) } .modelContainer(container) } } My UserData and DataStore are configured as follows: import SwiftUI import SwiftData import os /// `FHIRDataStore` is an actor responsible for updating the SwiftData db as needed on t
2
0
630
Jun ’24
Reply to ckqueryoperation in CloudKit crashing
If it is a crash that occurs at _dispatch_assert_queue_fail in libdispatch.dylic when you adopt Swift 6, please see here for an in-depth analysis. Basically, Swift 6 inserted a runtime check to detect concurrency issues, and if indeed detecting an issue, it (intentionally) triggers a crash. The Swift compiler doesn't spot the issue at compile time because of a Swift / Objective-C impedance mismatch. To solve the issue, I'd consider two options: Use async APIs. Concretely in your case, you can replace CKQueryOperation with records(matching:inZoneWith:desiredKeys:resultsLimit:) and records(continuingMatchFrom:desiredKeys:resultsLimit:). Make the closure passed to CKQueryOperation sendable: operation.recordMatchedBlock = { @Sendable (recordID, result) in ... } You can give it a try and follow up here if this doesn't help. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Oct ’24
Reply to Request authorization for the notification center crash iOS app on Swift 6
At the time of posting, this problem still persist. I had to downgrade the Swift Version Language that the Swift Compiler uses from Swift 6 to Swift 5. As soon as I invoke this function, I get hosed and the app crashes: UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in // ... } I hear that this is a known Apple Bug. Is this true?
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’25
Reply to [ERROR] Could not create a bookmark: NSError: Cocoa 4097 "connection to service named com.apple.FileProvider" when using PhotosPicker
I'm getting a crash using PhotosPicker, and it can be reproduced using a sample project provided by Apple: https://developer.apple.com/documentation/photokit/bringing_photos_picker_to_your_swiftui_app If you load that project and then change Swift Language Version to Swift 6 in the Build Settings, when you come back from the photo picker the app crashes.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to Is OSLog Logger Sendable?
Logger should be sendable. Under the covers, it’s an immutable struct with a single OSLog property, and that in turn is just a wrapper around the C os_log_t which is definitely thread safe. We already have a bug on file requesting that it be marked sendable (r. 122467426). Sadly, the fix didn’t make Xcode 15.3. In the meantime, I think it’s fine for you to suppress the warning with that annotation. I also recommend that you add this: #if swift(>=6.0) #warning(Reevaluate whether this decoration is necessary.) #endif to remind you to revisit this when Swift 6 lands. IMPORTANT I’m not promising that this’ll be fixed in Swift 6 [1], just that it makes sense to reevaluate it then. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] Because that’s a statement about The Future™, and I can’t predict that.
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’24
Reply to Xcode 16 build fails randomly with
I’m getting the same error as well with Xcode 16 and Swift 6, with also other files showing the same error : MyApp.abi.json MyApp.swiftdoc MyApp.swiftmodule MyApp.swiftsourceinfo Cleaning the project, removing the derived data, deleting every external dependencies and re-fetching them didn’t change anything.
Oct ’24
Reply to How to Remove OpaqueTypeErasure from SwiftUI
I’m not exactly sure what your concern is here, so lets start with something simple: Are you building your app with Xcode 16 already? If so, be aware that you’re already using the Swift 6 compiler version. You can switch between language modes via the Swift Language Version build setting, but you always get the Swift 6 compiler [1]. The main difference between the Swift 5 and 6 language modes is the data race safety enforcement. If you’re not prepared to tackle that, it’s fine to stay on the Swift 5 language mode. AFAIK the language mode doesn’t affect generics, like some and any. If you have a specific case that’s a concern, please post back with the details and I’ll take a look. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] And yes, this stuff is confusing, and there’s an active effort to improve how we talk about this stuff. See SE-0441 Formalize ‘language mode’ terminology.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’24