I have an iOS Swift project with multiple targets.
Converting the first target to Swift 5 was easy.
Converting the second target to Swift 5, Xcode 10.2 tries to compile files that clearly exist only in the first target and fails (Because it doesn't compile all files of the first target and complains about unresolved identifiers).
What can I do that Xcode compiles only those files, that are part of the target while converting to Swift 5?
How can I convert my project to Swift 5?
Cleaning the Build folder and restarting Xcode 10.2 doesn't help.
I just went through this process and was able to figure out a fairly simple solution from a hint in the last sentence of the Migration Guide https://swift.org/migration-guide-swift5/
When I tried to convert each target individually in my project, the second target would fail because of shared code with the first target that had already been converted. The solution is to create a new scheme that includes all of the targets that need to be migrated in a single pass.
Click on the scheme button to get the drop down and select "New Scheme..."
Create the scheme and then select it in the drop down and choose "Edit Scheme..."
Under the "Build" section use the "+" button to add all of the targets you need to convert to the scheme.
Build the new scheme with the current Swift version to confirm that all targets build correctly.
Use Edit -> Convert -> "To Current Swift Syntax..." to start the conversion
This worked for me in a project with 15 targets with lots of shared Swift code that was in version 4.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With