I am facing weird issue with xcode build setting for swift language version. I am trying to keep latest swift version i.e 5.3 but it is not showing in my xcode build setting. I upgraded xcode to 12.3 as well but no luck. Any suggestion?
XCode 12 comes with swift 5.3, we are not able to choose between 5.1, 5.2 & 5.3. If you want to use Swift 5.2 then you have to use XCode 11.4 as mentioned here: https://developer.apple.com/support/xcode/
In order to determine which swift version you are using you can try this command in terminal:
xcrun swift -version
You will get something like that:
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Note: If you have installed different versions of XCode use :
xcrun --find swift in order to find the path of each swift and then use the above command to determine it's version.
Related
I'm creating a simple Swift framework in Xcode 10.3 and trying to use a lower Swift 4.0.3 version. I went to the Xcode build settings and switch from 5.0.1 to 4.0.3 and then build the project.
I ran otool against resulted framework to make sure it's built using correct Swift version but the libraries included are still from Swift 5.0.1 (corresponds to 1001.0.82 from the output below):
otool -l SwiftyHello.framework/SwiftyHello
cmd LC_LOAD_DYLIB
cmdsize 56
name #rpath/libswiftCore.dylib (offset 24)
time stamp 2 Wed Dec 31 16:00:02 1969
current version **1001.0.82**
compatibility version 1.0.0
My toolchain is running Swift 5.0.1:
swift -version
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.7.0
How can I make sure that the Swift framework is built using Swift 4.0.3?
SWIFT_VERSION (Swift Language Version) key does nothing with an actual Swift version of the resulting binary. From $ swift --help:
-swift-version Interpret input according to a specific Swift language version number
So, basically, Xcode executes Swift compiler with -swift-version 4 argument. It changes how Swift compiler parses the source files, but do not affect the binary in any way.
To build the actual Swift 4 binary, you have to install the Swift 4 toolchain. Then you would be able to pick the correct toolchain from the menu Xcode -> Toolchains. But, honestly, I wouldn't recommend doing this way, because Apple does not care about older versions of toolchains, and Xcode usually behaves unstable with them.
Instead, I'd recommend you install older Xcode (in your case 9.3) from the Apple Downloads website and build the project from there.
Alternatively, you can set up relatively simple CI/CD inside Github Actions, CircleCI or TravisCI and build in multiple Xcode versions at the same time there. And use the latest Xcode locally. Because they these CIs provide you multiple virtual environments with different Xcode and macOS versions.
After a recent Xcode version install (10.2) my AudioKit import statements don't work
"Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler: ".
I have thus far always used cocoa pods to install AudioKit.
Is the best thing to do here to revert Xcode and wait a while for the 5.0 version?
We just pushed a pre-release pod (version 4.6.4.b1) compiled with Swift 5 on Xcode 10.2. You can use it by following the instructions on this page:
https://github.com/AudioKit/Specs
You can use that one until the next mainstream release compiled with Xcode 10.2 is pushed out, hopefully in the coming days.
Rather than reverting Xcode, downloading and installing the 10.1 toolchain from https://swift.org/builds/swift-4.2.3-release/xcode/swift-4.2.3-RELEASE/swift-4.2.3-RELEASE-osx.pkg
then setting Xcode | Toolchains to use the Swift 4.2.3 Release allows me to keep running the existing code until Swift 5 build issues are resolved.
Alternatively use the recently pushed working staging pod. Its version number is 4.6.4.b1 - instructions are here: https://github.com/AudioKit/Specs
Short story: Xcode 10 is set to Swift 4, but it is using Swift 4.2.
Long story: Our project is not ready for Swift 4.2, since our dependent frameworks are not Swift 4.2, yet. But, I would like to, at least, use Xcode 10.
I have Xcode 9.4.1 and Xcode 10 installed.
I have Command Line Tools set to use Xcode 9.4.1:
In Xcode 10, I have the project setting, Swift Language Version, set to
Swift 4.
I have verified on the command line the Swift version the shell is
using is 4.1.2:
"swift --version Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)"
I've run carthage update.
I've quit Xcode 10 and relaunched.
I have deep cleaned and deleted Derived Data.
I build and I get this error:
"Module compiled with Swift 4.1.2 cannot be imported by the Swift 4.2
compiler:
.../App/Carthage/Build/iOS/RealmSwift.framework/Modules/RealmSwift.swiftmodule/arm64.swiftmodule"
To me, this indicates that I have my intended Swift version (4.1.2) set correctly and Xcode is still trying to use the wrong version of Swift (4.2).
Does anyone have suggestions on how to resolve this? Am I missing something? Xcode bug?
I'm not positive, but my guess is that this is the reason:
I have Command Line Tools set to use Xcode 9.4.1
You have to recompile your Swift 4 dependencies using Xcode 10, because Swift is not ABI-stable, i.e. binaries compiled with different compiler versions are not compatible. And even Swift 4.0 binaries compiled with different versions of Xcode may not be compatible.
I don't have much experience with Carthage, but my guess is that you should use Xcode 10 as a command-line tool, but you have to set a different Swift language version to be used by Xcode 10. It should probably be specified in the project (in this case RealmSwift), or using environment variables, but you'll need someone else to answer with more details, I'm afraid.
Using Realm with Xcode 10 requires building it from source. In Terminal write:
git clone --recursive https://github.com/realm/realm-cocoa.git
cd realm-cocoa
sh build.sh ios-swift
you can use multiple swift toolchains. download url swift toolchain download after you install some version. restart your xcode, in xocde menu you can see toolchains option.
I had the same problem and then I realised I had not selected Xcode 10 as my Xcode. Try:
sudo xcode-select -s /Applications/Xcode10.app
Also, if you will be switching between Xcode9 and 10, I recommend you the following: If you change from 9 to 10, run mv Carthage Carthage9 and then rebuild Carthage. Whenever you want to switch back, move Carthage to Carthage10 and do mv Carthage9 Carthage. This will save you lots of time building.
Good Day,
Lastweek i updated my Xcode from 8.2 to 8.3, In my project i used swift 2.3 version. I tried to use multiple version of xcode to my Mac but when i use the older version of Xcode i can't run the project on devices that has iOS Version 10.3.1
I don't know how to run swift 2.3 to iOS Version 10.3.1
Note: My Project still not uploaded on App Store.
Thanks
You need DeveloperDiskImage for iOS version 10.3 to run your project on device(iOS 10.3) using xcode 8.2.
Download Xcode 8.3.2 from here and copy 10.3 (14E269) folder inside DeviceSupport from the downloaded Xcode using path Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ and paste it into Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ path in your existing Xcode 8.2 in Finder.
It's said in release note clearly that Xcode 8.3 no longer supports Swift 2.3 version. So you need to migrate your projects containing Swift 2.3 code to Swift 3 syntax by opening the project and choosing Edit > Convert > To Current Swift Syntax.
Running "swift -version" reveals that:
Xcode 8.2.1 is using Swift 3.0.2
BUT
Xcode 8.3 Beta is using Swift 3.0.
This is a nuisance as Realm has different Swift frameworks for 3.0 and 3.0.2 - which means using a project created with Xcode 8.2.1 using the Realm framework for 3.0.2 won't build if using Xcode 8.3.
Is there a way to change Xcode 8.3 beta to use Swift 3.0.2?