Where are the swift/swiftc binaries for v3? - xcode

I've just downloaded the Xcode 8 beta, and am struggling to figure out where the swift and swiftc binaries are hidden.
The Swift website says that the toolchain should be available at /Library/Developer/Toolchains and that it can be exported for use on command line with:
$ export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
But that path doesn't seem to exist for me.
I can see Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain, but that's for 2.3 rather than 3.
Any ideas?

Thanks to Marc B's suggestion:
⇒ find / -name swift -type f
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
/Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/bin/swift
/Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
/usr/bin/swift
Which for me are:
⇒ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
⇒ /Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/bin/swift --version
Apple Swift version 2.3 (swiftlang-800.10.6 clang-800.0.24.1)
Target: x86_64-apple-macosx10.9
⇒ /Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9
⇒ /usr/bin/swift --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
To set v3 as your 'main' swift, you can do the following (make sure to use the right path to your Xcode 8 application):
⇒ sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
⇒ xcrun --find swift
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
⇒ swift --version
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9

As Arsen notes in Run Swift 3 from command line using Xcode 8 Beta, you can also change the settings through the Xcode menu directly. Just follow Xcode > Preferences > Locations > Command Line Tools. Then switch the drop down list from Xcode 7.3.1 to Xcode 8.0. Then enter your password for admin privileges. However, for scripting, xcode-select is the most useful answer.
http://i.stack.imgur.com/Nzi3q.png

Related

How to switch between multiple Command Line Tools installations in Mac OS X (without installing XCode)

Is it possible to install and switch between multiple version of Command Line Tools in Mac OS X? I was wondering if it's possible use xcode-select but the Command Line Tools installer doesn't have an option to choose the installation destination. I tried to create multiple installations by manually renaming Library/Developer/CommandLineTools and then passing it to xcode-select. The command succeeds but when I try to access gcc I get:
gcc: error: unable to find Xcode installation from active developer path "/Library/Developer/CommandLineTools_9.0.0", use xcode-select to change
It seems this is possible when installing the whole XCode but I have no need for XCode and prefer not to install it. All I need is the command line tools.
I tried to do the same and after some experiments found the next solution. Yes, it is possible but you need to copy/rename the whole /Library/Developer folder. For example:
1) first, I just show my macOS version:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G65
2) download and install Command Line Tools for Xcode, e.g. 10b5 version
3) create folders to store different versions of tools:
$ mkdir ~/Project/tools
$ mkdir ~/Projects/tools/Developer10b5
$ mkdir ~/Projects/tools/Developer9.4.1
4) copy the whole Developer folder:
$ cp -R /Library/Developer/ ~/Project/tools/Developer10b5/
5) then, download and install Command Line Tools for Xcode, e.g. 9.4.1 version
6) copy the whole Developer folder:
$ cp -R /Library/Developer/ ~/Project/tools/Developer9.4.1/
7) switch to 9.4.1 version of tools and check the clang version:
$ sudo xcode-select -s ~/Project/tools/Developer9.4.1/
$ clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/<username>/Projects/tools/Developer9.4.1/CommandLineTools/usr/bin
8) switch to 10b5 version of tools and check the clang version:
$ clang --version
Apple LLVM version 10.0.0 (clang-1000.10.40.1)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/<username>/Projects/tools/Developer10b5/CommandLineTools/usr/bin
For those who have a problem like as #PaulMasri-Stone, I found that after removing a previously installed Xcode (installing multiple versions of Xcode was not an option on my computer because of space), the method above also gave me the 'invalid developer directory' error.
I overcame this problem by typing sudo xcode-select -r to reset to the default command-line tools (and reset whatever other underlying state that the system uses to track the SDK location -- and lack of Xcode), followed by sudo xcode-select -s /Library/Developer/CommandLineTools10.13_Xcode9.4.1. Note that sudo xcode-select -s /Library/Developer would not work for me, just like the problem that #PaulMasri-Stone had.
Otherwise, you will want to follow the instructions that #Ilirium specified, but you only need to copy/rename the CommandLineTools directory.
These instructions worked for me. #PaulMasri-Stone - Instead of pointing xcode to the root directory, I had to point it to the CommandLineTools directory like so:
sudo xcode-select -s ~/projects/tools/llvm1131/CommandLineTools/

Xcode 7.3.1 can't build from the commandline swift-build missing

[OSX 10.11.6, Xcode 7.3.1]
I have Xcode 7.3.1 installed from the App Store and I can compile Swift code inside the IDE. However, I am unable to build from the commandline. When I try to, I get an error:
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build (No such file or directory)
I don't have a toolchain tab in my Preferences -> Components dialog, which, according to other threads I've read, is because I don't have any other toolchains installed. Since, according to Apple, Swift 2.2.1 came with Xcode 7.3.1 (but my --version reports 2.2), what command can I issue to create the /Library/Developer/Toolchain folder (or other variations that will work) that will allow me to build from the command line?
The SnapShot master trunk is up to Swift 3, which is not suitable for my needs and I don't want to (can't afford to) download another gig of data, when I already have the compiler, linker, etc. And I prefer not to have a -dev version of Swift.
Please help.
Additional info:
swift --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
which swift
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
swift build
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build (No such file or directory)
I don't think swift-build is available in Swift 2.2.1 (Xcode 7.3.1), as it's part of the Package Manager which is Swift 3 only:
The Package Manager will be released with Swift 3 and is currently only available with the Swift 3 development snapshots.

Wrong version of swift

How can I run swift 2.1?
I have Xcode 7.0.1 installed but when I run swift in the terminal,
I getting version 2.0.
> swift -v
Apple Swift version 2.0 (swiftlang-700.0.59 clang-700.0.72)
Target: x86_64-apple-darwin14.5.0
/Applications/Xcode.app/Contents/Developer/usr/bin/lldb "--repl=-target x86_64-apple-darwin14.5.0 -enable-objc-interop -sdk
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics"
Welcome to Apple Swift version 2.0 (700.0.59 700.0.72). Type :help for assistance.
I thought Xcode7 included swift 2.1
See the Wikipedia article on Xcode § Toolchain Versions.
In the table, it says that Xcode 7.0 includes Swift 2.0.
The first version of Xcode to include Swift 2.1 is version 7.1.
You will have to update Xcode from the App Store.

Install another Command Line Tool version in XCode

In Preferences -> Locations there is an option called Command Line Tools in which there is a list of different versions.
I did have 2 xcode versions installed 6.2 and 6.3, when I had both installed I could switch to 6.2 to use Swift 1.1 and to 6.3 to use Swift 1.2.
But today I updated to XCode 6.3.2 and it removed my XCode 6.2 so now I cant choose another Command Line Tools version.
Now I could just download the whole XCode 6.2 again but that is quite big and Im thin on storage. I found Apple development center downloads where I could download and install different version I installed 'Command Line Tools (OS X 10.10) for Xcode 6.2' but I still cannot see 6.2 as option inside Preferences -> Locations -> Command Line Tools.
Obviously Im doing something wrong, anyone that can help me?

XCode 4.3.1 and iPhone 3.2 SDK Link Warnings, Directory Not Found

After installed XCode 4.3.1, not getting linker warnings as follows:
ld: warning: directory not found for option '-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2/Symbols/usr/lib'
One for armv6 and one for armv7.
In the directory we have...
$ pwd
/Applications/xcode.app/Contents/Developer/platforms/iPhoneOS.platform/DeviceSupport
$ ls
4.2 4.3 5.0 5.1 (9B176) Latest
So, I am assuming that the SDK for 3.2 is not present, do we need to reinstall, etc?
Try installing the 3.0-3.2.2 Device Debugging Support from Preferences->Downloads->Components

Resources