SwiftGen: SwiftGen Errors on Swift 6
SwiftGen has multiple errors with concurrency in Swift 6. Specifically, all of the Storyboard functions result in the following error:
Call to main actor-isolated initializer 'init(name:bundle:)' in a synchronous nonisolated context.
In order to replicate Swift 6, you can turn on “Complete” strict concurrency checking in Build Settings and see the errors.
This will make SwiftGen unusable when Swift 6 is released. Please update SwiftGen to conform to the concurrency checks introduced in Swift 6.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 29
- Comments: 15
One option is to create your own stencil template for generating assets, like this one:
Potential Swift-6 Stencil template
This will change the generated
Assetsto look something like this:Since these will all be defined in an enum like so:
the
static lets are inherently lazy – and so using aletproperty should be the same as using alazy var.Hi it’s been almost year since that thread opened. Is there any plans for release with swift-6 support?
Can confirm generated Images and Sounds also have issues.
Static property 'exampleImage' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6Hi, is there any progress? Cause Xcode 16 already released
The same is true for
ColorAssetandImageAssetwithin anAsset.Any update on this?
If someone would be looking for quick solution for
runtime-swift5plist template, here is potential quick fix using@unchecked Sendableandvarinsteadlet:I just simply changed
enumtoactorwhich conforms Sendable. Here is the stencil file of it.There is another issue in Swift 6. Instead of generating:
…it needs to be:
(adding
any)This should be backwards-compatible to Swift 5 and can easily be previewed with the
ExistentialAnySwift feature flag. I wouldn’t mind opening a PR for the Swift 5 template, anything I should be aware of before doing that?Oh, I may have missed that – happy to hear if anyone has a reference to that. Given it’s a very minor change in the template, it probably doesn’t hurt to add it, given it’s valid from Swift 5.6?