You can compile your command line interface Swift code like so:
$ xcrun swiftc -c fibonacci.swift -F /System/Library/Frameworks -I/usr/include $ xcrun swiftc -o fibonacci fibonacci.o
If you also have regular C code, you can do it like the following:
1. Compile regular .m file:
$ xcrun clang C.m -o C.o -c
Be sure to import the bridge header .h file
$ xcrun swiftc -c S.swift -import-objc-header C.h -F /System/Library/Frameworks -I/usr/include
What's the SDK path?
$ xcrun --show-sdk-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
Helpful?
Let us know if you liked the post. That’s the only way we can improve.