Search results for

Swift 6

49,197 results found

Post

Replies

Boosts

Views

Activity

Reply to Live activity sample code for Swift 6?
Emoji Rangers is quite large, and converting all of it to Swift 6 is a challenge. You should feel free to file a bug against the sample requesting that, but on DevForums I prefer to focus on specific problems. Is there a specific issue you’re trying to resolve? If so, can you pull that out into a small test project that reproduces it? Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: App & System Services SubTopic: General Tags:
Sep ’24
Reply to How to build clang modules to work with Swift/C++ interop
I have C++ Xcode projects and Swift projects. These only work right now with a c-style bridging header. Apple doesn’t have any sample apps that build clang modules sinice they were released many years ago. Watched the WWDC on explicit modules, but then read these don’t work with Swift interop. Have a modulemap file, -fmodules defined, but Swift still can’t see the C++ sources. one of the strengths of Apple development was ease of interop between ObjC++ and C++. Have had to wait until Swift 5/6 for something not under a C-wrapper. My code is on Swift 5 if that matters. But switching to Swift 6 is a concurrency warning flood.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’24
Reply to NIOThreadPool segfault
[quote='761575021, Foxyy, /thread/761575, /profile/Foxyy'] swiftlang-6.0.0.7.6 [/quote] That suggests you’re using a Swift 6 beta. My advice is that you re-test with the latest beta and, if you still see the crash, file a bug about this failure. Please post your bug number, just for the record. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’24
Reply to Confused with type erasure when working with existential type
Currently Animal and any Animal are synonyms. To quote SE-0335 Introduce existential any: In Swift 5, anywhere that an existential type can be used today, the any keyword can be used to explicitly denote an existential type The plan is for Swift 6 to make the any required, which ‘frees up space’ for the protocol type name (Animal) to be used for other stuff. See this section of the proposal. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’23
Reply to Swift Testing not recognising tests
I had the same issue in my project, which is still on Swift 5. The tests wouldn’t run even though the project built successfully. I tried converting the folder to a group and setting the Swift 6 compiler for the test target, but it didn’t help. I found a thread suggesting the problem could be with the simulator. The solution was to delete all simulators using xcrun simctl delete all. After that, the tests started running. I did run into some dependency issues, but that’s a separate problem. Try this solution, it might help you!
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’24
Reply to Request authorization for the notification center crash iOS app on Swift 6
I can attest that AVCaptureDevice.requestAccess suffered from this same problem, i.e. crashing with a thread/queue violation when built under Swift 6. Original code: AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: { granted in if (granted) { DispatchQueue.main.async { [weak self] in // do something } } }) Modified code: Task { let granted = await AVCaptureDevice.requestAccess(for: .video) if (granted) { Task { @MainActor in // do something } } } This code pops a permission dialog for using the camera, and as soon as the Allow button is clicked the app would crash.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’24
Reply to SwiftData SchemaMigrationPlan and VersionedSchema not Sendable?
Thanks for filing the feedback report. As of today, SwiftData does't run through Swift 6 check yet. I personally don't see any reason that MigrationStage and Schema.Version can't be sendable. You can probably consider using the following extensions to eliminate the warnings or errors related to Sensibility of the two types: extension MigrationStage: @unchecked @retroactive Sendable { } extension Schema.Version: @unchecked @retroactive Sendable { } Best, —— Ziqiao Chen  Worldwide Developer Relations.
Jun ’24
Reply to How to position multiple Views with a single Scene?
OK, so it was a dumb question as I now know it's possible to use VStack, HStack, etc. However, the recent macOS / Xcode update (15th March 2022) has introduced warning messages: Expression requiring global actor 'MainActor' cannot appear in default-value expression of property '_callsign'; this is an error in Swift 6 With no clues on how to solve. If only Apple would spend a little more time writing user friendly documentation.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’22
Reply to How to build clang modules to work with Swift/C++ interop
[quote='812461022, Alecazam, /thread/767766?answerId=812461022#812461022, /profile/Alecazam'] Also when I have Swift 5 set in Xcode 16, is that 5.xx (f.e. 5.9 has interop) or 5.0? [/quote] That’d be Swift 6 (-: There’s a difference between the compiler version and the language mode. Xcode 16 only includes the Swift 6 compiler. The Swift Language Version build setting controls the language mode. And, yes, that’s confusing, and there’s an active effort to improve how we talk about this stuff. See SE-0441 Formalize ‘language mode’ terminology. AFAIK there’s no difference between the Swift 5 and 6 language modes when it comes to C++ interop. The mode increment is all about Swift concurrency enforcement, and it’s fine to ignore that for the moment. C++ interop is still cutting edge stuff, so it’s not as smooth as it should be. However, you should be able to get the basics working. [quote='812442022, Alecazam, /thread/767766?answerId=812442022#812442022
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’24
Reply to Swift 6 conversion for IBOutlet
MainActor.assumeIsolated seems the simplest way to go. I have noticed an important point when converting to Swift 6 which may help others. At some point, I had nearly 200 errors… Don't panic they say… Problem was that errors kept coming and disappearing. Just as if the compiler was a bit lost (and me with him) with all the changes occurring on classes or func (such as declaring MainActor or non isolated). This made error correction pretty erratic. I did a Clean build folder, and the number of errors dropped to less than 10.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to UIHostingConfiguration + MainActor.assumeIsolated?
There are a number of different approaches but this is a perfectly reasonable one. It assumes that the calendar view calls its delegate on the main thread / queue / actor, which is a reasonable assumption for a view class in the absence of any documentation to the contrary. Feel free to file a bug against the calendar view requesting that it delegate be decorated so that the Swift compiler understands this. And please post your bug number, just for the record. Migrating to Swift 6 is chock-full of useful info in this space. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to com.Metal.CompletionQueueDispatch crash in Swift 6
Thanks to Quinn's extended explaination in another thread the problem is fixed by adding @Sendable to the Metal command queue command buffer's completion handler. The app is now running on Swift 6 commandBuffer.addCompletedHandler { @Sendable (_ commandBuffer)-> Swift.Void in ... The compiler team should consider adding information that can be used for correcting the problem. Right now the assert crash is completely cryptic to me and has no usable information about the cause. [(https://developer.apple.com/forums/thread/764777?answerId=807248022#807248022)]
Dec ’24
Reply to Swift6 race warning
[quote='821476022, markdaws, /thread/772582?answerId=821476022#821476022, /profile/markdaws'] Swift 6 makes writing code miserable [/quote] Keep in mind that the Swift 6 language mode is optional; you can always revert to Swift 5 mode. In general, I’m the opposite an early adopter. I let other folks deal with all the grief associated with new OS versions, APIs, and tools. By the time I get around to it, the early adopters have encounter all the bumps, and either smoothed them over or published a map for how to avoid them. Now, Swift concurrency is an exception to my general rule because I’m super interested in this technology. But that’s just me. It’s fine for you to take your time here. Adoption is only going to get easier as the tools, SDKs, and documentation improve. [quote='821476022, markdaws, /thread/772582?answerId=821476022#821476022, /profile/markdaws'] it looks like it's a misleading compiler error [/quote] Right. That’s why I was trying to reproduce it. I origina
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’25
Reply to Swift 6 conversion for IBOutlet
[quote='853068022, Claude31, /thread/796278?answerId=853068022#853068022, /profile/Claude31'] Converting to Swift 6 is definitely not an easy ride… [/quote] Well, we’re actively working to improve that. Speaking of that, what version of Xcode are you testing this on? I want to play around with some specific scenarios and it’d be good to know whether you’re testing on Xcode 16.4 or the latest Xcode 26.0 beta. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic: Programming Languages SubTopic: Swift Tags:
4w
Reply to Module compiled with Swift 5.0 cannot be imported by the Swift 5.1 compile
The same issue here, don't even know how to adress this the best, as we build a framework that we sell and want to allow customers (developers) to be able to use either Swift 5.0.1 (and Xcode 10) or 5.1 (and Xcode 11) as they have their own requests/timeline for upgrading... We are considering releasing multiple packages - one for each supported Swift version - but it's something that is not going to be good for the long term. (Hopefully Swift 6 would end this charade, though...)As andrewtheis mentioned above we've also tried the solution of downloading and using Swift 5.0.1 toolchain (thinking that we could tell our customers to do it as well, at least for now, if they switched to Xcode 11 but can still use Swift 5.0 for a while), but... dyld: Symbol not found: _OBJC_CLASS_$__TtCs12_SwiftObject anyway.
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’19