With Swift DEVELOPMENT-SNAPSHOT-2016-02-08-a
, I'm trying to build a project using swift build
but as soon as I add the line import Foundation
I get the error:
[I] ~/Dropbox/Projects/test
↪ swift build --clean; and swift build
Compiling Swift Module 'test' (1 sources)
<unknown>:0: error: cannot load underlying module for 'CoreGraphics'
<unknown>:0: note: did you forget to set an SDK using -sdk or SDKROOT?
<unknown>:0: note: use "xcrun -sdk macosx swiftc" to select the default OS X SDK installed with Xcode
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swift-build-tool", "-f", "/Users/me/Dropbox/Projects/test/.build/debug/test.o/llbuild.yaml"]
Running xcrun -sdk macosx
results in "no such SDK: 'machos'" error:
↪ xcrun -sdk macosx swift build 0@10:34:03
<unknown>:0: warning: no such SDK: 'macosx'
<unknown>:0: warning: no such sysroot directory: 'macosx'
<unknown>:0: error: cannot load underlying module for 'Darwin'
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swiftc", "--driver-mode=swift", "-I", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/lib/swift/pm", "-L", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/lib/swift/pm", "-lPackageDescription", "-target", "x86_64-apple-macosx10.10", "/Users/me/Dropbox/Projects/test/Package.swift"]
This is with only main.swift, whose contents are:
import Foundation
print("Hello, world!")
No dependencies are defined in Packages.swift.
Really don't know what's going on here. This compiles fine on my Ubuntu 14.04 DigitalOcean VPS as well as within Xcode 7.3 Beta 5.
OS X 10.11.3
↪ swift --version 0@10:21:16
Apple Swift version 3.0-dev (LLVM a7663bb722, Clang 4ca3c7fa28, Swift 1c2f40e246)
Target: x86_64-apple-macosx10.9
Do you have the stable release of Xcode.app in your [/Applications] directory? If you just have Xcode-beta.app, that's likely what's causing this error. Try creating a symlink of Xcode-beta.app to Xcode.app:
$ ln -s /Applications/Xcode-beta.app /Applications/Xcode.app
(Kudos to anton for the answer).