简体   繁体   中英

Using Swift 3 in Xcode 10.2 - Command /Library/Developer/Toolchains/swift-3.0-RELEASE.xctoolchain/usr/bin/swiftc failed with exit code 1

My goal is to get the new Xcode 10.2 compile and run our projects that are build using Swift 3 and 4.2 (some cocoapods too) and since Xcode 10.2 comes with Swift 5, an unsupported swift error came up when trying to run the projects out of the box (this is expected):

在此输入图像描述

The solution here is to use an older toolchain as stated on blogs like this , which i did.

在此输入图像描述

All good so far. However, after installing the Swift 3 toolchain from Swift.org , compiling the project will bring the following error:

Command /Library/Developer/Toolchains/swift-3.0-RELEASE.xctoolchain/usr/bin/swiftc failed with exit code 1

在此输入图像描述

I already deleted Derived Data folder, cleanup pods ( my podfile ) and reinstalled them, restarted Xcode and Mac multiple times.

Running xcrun -f swift and swift --version will indeed print the correct swift 3.0 toolchain

在此输入图像描述

Yes, I know I could just stay with Xcode 10.1 and don't have these issues. Code migration to Swift 4 is also an option but we don't have the time at hand for now so I'm trying to workout this walkaround.

Please help me to resolve this issue, I'm completely stuck. Thanks in advance.

Xcode10.2 Release Notes

Swift 5 no longer supports the Swift 3 Package.swift tools-version. Packages still on the Swift 3 Package.swift tools-version should update to a newer tools-version. (41974124)

Swift 5.0

Source Compatibility As with Swift 4.2, the vast majority of sources that built with the Swift 4.2 compiler should compile with the Swift 5.0 compiler.

However, the Swift 3 compatibility mode will not be supported in the Swift 5 compiler. Swift 4.2 is the last release of Swift to support Swift 3 mode. There are important changes to both the surface of the language and the interior of its implementation in the releases following Swift 3 that will be the basis of future (and lasting) source and binary stability.

Using Swift 4.2.1 toolchain work for me.

But https://swift.org/download/#using-downloads tips:

To submit to the App Store you must build your app using the version of Swift that comes included within Xcode.

Upload to apple connect probably reject by apple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Command /Xcode.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/bin/swiftc failed with exit code 1 Swift Compiler Error : Command /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 6 Xcode 8.0 Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 Xcode 6.0.1 Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 Xcode 7 fails with Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 XCode - Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 Error: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 Error — Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 Xcode 10.0 Error "Command /Applications/Xcode 10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1" Bridging-header.h causes Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM