Search results for

Swift 6

49,193 results found

Post

Replies

Boosts

Views

Activity

Reply to Swift 6 Minimum Requirement for App Store
While I can't predict the future or comment on anything future looking, I'd like to color in some details of the complier so you have a more complete understanding of how things work, in hopes that you can use this information to inform your own decisions around adopting Swift 6. If you take a look at the Xcode support page and look at the table of Xcode versions, you'll notice the Swift column has two sets of data — the complier version, and language modes. As you stated, Swift 6 was released with Xcode 16, and you can see that in the version number of the complier in the chart. Every Xcode release has one version of the Swift complier, and so that means every app that has compiled with Xcode 16 or newer has already compiled with the Swift 6 complier. Your question here is better stated as what is the longevity of the Swift 5 language mode? The language mode (which you'll find in your project as the SWIFT_VERSION build setting) is the version of the langu
Aug ’25
Xcode 26: Sendable checking + NSManagedObjectContext.perform in Swift 6
I have some code which handles doing some computation on a background thread before updating Core Data NSManagedObjects by using the NSManagedObjectContext.perform functions. This code is covered in Sendable warnings in Xcode 26 (beta 6) because my NSManagedObject subclasses (autogenerated) are non-Sendable and NSManagedObjectContext.perform function takes a Sendable closure. But I can't really figure out what I should be doing. I realize this pattern is non-ideal for Swift concurrency, but it's what Core Data demands AFAIK. How do I deal with this? let moc = object.managedObjectContext! try await moc.perform { object.completed = true // Capture of 'object' with non-Sendable type 'MySpecialObject' in a '@Sendable' closure try moc.save() } Thanks in advance for your help!
1
0
101
2w
SwiftUI + OSlog breaks previews in Swift 6
import SwiftUI import OsLog let logger = Logger(subsystem: Test, category: Test) struct ContentView: View { var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundStyle(.tint) Text(Hello, world!) } .padding() .task { logger.info(Hallo) } } } #Preview { ContentView() } 27 | .padding() 28 | .task { 29 | logger.info(__designTimeString(#6734_2, fallback: Hallo)) | `- error: argument must be a string interpolation 30 | } 31 | } Should OsLog be compatible with __designTimeString?
1
0
83
Mar ’25
Swift 6 Concurrency errors with ModelActor, or Core Data actors
In my app, I've been using ModelActors in SwiftData, and using actors with a custom executor in Core Data to create concurrency safe services. I have multiple actor services that relate to different data model components or features, each that have their own internally managed state (DocumentService, ImportService, etc). The problem I've ran into, is that I need to be able to use multiple of these services within another service, and those services need to share the same context. Swift 6 doesn't allow passing contexts across actors. The specific problem I have is that I need a master service that makes multiple unrelated changes without saving them to the main context until approved by the user. I've tried to find a solution in SwiftData and Core Data, but both have the same problem which is contexts are not sendable. Read the comments in the code to see the issue: /// This actor does multiple things without saving, until committed in SwiftData. @ModelActor actor DatabaseHelper { func commitChange()
6
0
761
Mar ’25
Porting Thread & Delegate Code to Swift 6 Using Tasks
Hello, I have a lot of apps and I am currently trying to port them over to Swift 6. I thought that this process should be relatively simple but I have to admit that I have a lot of trouble to understand how the Concurrency system works. Let's start with some code that shows how I am currently working when it comes to asynchronous work in my apps: I have a Model that is marked with @Observable. Inside this model, a Controller is hosted. The Controller has its own ControllerDelegate. The Model has a search function. Inside this function a lot of IO stuff is executed. This can take a lot of time. Because of this fact, I am doing this in a separate Thread. I all is put together, it looks a little bit like this: @main struct OldExampleApp : App { @State private var model = Model() var body: some Scene { WindowGroup { ContentView() .environment(self.model) } } } struct ContentView: View { @Environment(Model.self) private var model var body: some View { if self.model.isSearching { ProgressView() } else { Bu
3
0
1.1k
Jul ’24
.alignmentGuide modifier causes consistent app crash when Swift 6 language mode is enabled
I've been experiencing random crashes in my app and today, I could finally narrow it down enough to start building an example project that consistently crashes. The error is this: com.apple.SwiftUI.AsyncRenderer (19): EXC_BREAKPOINT (code=1, subcode=0x102f103f8) It's a very strange bug because the SwiftUI view hierarchy has to be in a very specific shape to cause the crash, but if it is, then it crashes 100% of the time: It's a button inside a List and a simple @State var number: Int? that is being animated when the view appears. You can simply paste the following code into a project and run it (device, simulator or even in a preview): // Must be in Swift 6 Language Mode! // iOS 18 Beta 4 struct ContentView: View { @State var number: Int? var body: some View { List { // Must be in a List // It also crashes if button is here inside the List } .overlay { button } .task { // Has to be in a task modifier (or .onAppear + Task {}, so it has to be async) number = 0 } } // Has to be in a separate view proper
6
0
990
Jul ’24
Reply to SwiftUI Lists down arrow handling broken
I have a profiler names alecazam/kram kram-profile. It's a SwiftUI app that does build analysis. It's not doing anything exotic with the List. The List was just broken. I finally got that app ported from Swift 5 to Swift 6, and that seems to have fixed the VStack { List } case. I can't port the other app to Swift 6 due to so many concurrency warnings. Not sure if this link will send, but this is the usage. But it's working now. I didn't change any code, just ported to Swift 6. But the tagged build isn't yet updated. https://github.com/alecazam/kram/blob/main/kram-profile/kram-profile/kram_profileApp.swift
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24
Reply to is it true that xcode 15 apps won't compile in xcode 16?
I understand now what your developer is saying. iOS apps are developed using Apple's programming language Swift. There's a new version of Swift available in Xcode 16, Verizon 6. Your developer is saying you need to migrate your app's code to Swift 6 and/or saying that the app cannot continue to use some libraries unless they too are updated by their developers to support Swift 6 as they won't build (or if they are dead and no longer being maintained then to find alternatives). Apple should not be forcing people to migrate to swift 6, and Xcode should continue to build with apps built using an older version of Swift and therefore the fact that does not occur in your case is perhaps a bug in Xcode and might get rectified in the next release. Something else to try as a temporary workaround is to make sure that the Xcode setting Treat Warnings as Errors is set to NO to see if that makes the errors go away. What they are saying about not being able to
Aug ’24