xcodebuild should derive Swift version from Xcode project
| Originator: | piet.brauer | ||
| Number: | rdar://26866292 | Date Originated: | 17-Jun-2016 11:27 AM |
| Status: | Resolved | Resolved: | |
| Product: | Developer Tools | Product Version: | 8.0 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary: When compiling a framework or app using `xcodebuild` it defaults to Swift 3, which breaks the build most of the time, although the Xcode project knows the correct swift version it should use. Steps to Reproduce: 1. Take a Swift 2.2 project 2. Migrate to Swift 2.3 3. Run xcodebuild from the command line Expected Results: The project builds using the Swift 2.3 toolchain Actual Results: The build is failing because it uses Swift 3 to compile Version: 8.0 Notes: One can workaround this issue by adding the `TOOLCHAINS=com.apple.dt.toolchain.Swift_2_3` environment variable. This seems unnecessary given that the Xcode project contains the correct toolchain version.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Piet Brauer
This issue has been verified as resolved and can be closed.
Piet Brauer
The "SWIFT_VERSION = 2.3" build setting was present only in the iOS target. I had to set the "Use Legacy Swift Language Version" on the project level in order for it to succeed.
Apple Developer Relations
Engineering has the following feedback for you:
If the migrator was run to convert to swift 2.3, the project should build with swift 2.3 from either Xcode or xcodebuild. Is it possible that you didn't check in the changes the migrator made to your project file? The migrator sets a build setting to let Xcode/xcodebuild know to use Swift 2.3 – if you look at the diffs to your project file after running the migrator, you should see "SWIFT_VERSION = 2.3" show up as an addition. If you are sure that you didn't accidentally discard your project file changes, please check and see what this build setting is set to in your project; in the build settings interface in Xcode, it should show up as "Use Legacy Swift Language Version" "Yes".
Please provide your response or results by updating your bug report and compress any bundled files (e.g. nested folders) prior to uploading.