Compiling command-line terminal Swift

Source: Internet
Author: User

So, that's where Swift lives, after you ' ve installed XCode 6 Beta:/applications/xcode6-beta.app/contents/developer/too Lchains/xcodedefault.xctoolchain/usr/bin/swift Also, there's a directory named Swift which has various libraries:/appli Cations/xcode6-beta.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/lib/swift to start playing in a Terminal:export path=/applications/xcode6-beta.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/ Bin: $PATH You could also change this in XCode 6 ' s Preferences.

i use it via xcrun :

$ xcrun swift-v-O Test test.swiftswift version 1.0 (swift-600.0.34.4.5) target:x86_64-apple-darwin14.0.0/applications/ Xcode6-beta.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/swift-frontend-c-primary-file Test.swift-enable-objc-attr-requires-objc-module-target X86_64-apple-darwin14.0.0-module-name TEST-SDK/ APPLICATIONS/XCODE6-BETA.APP/CONTENTS/DEVELOPER/PLATFORMS/MACOSX.PLATFORM/DEVELOPER/SDKS/MACOSX10.10.SDK- Color-diagnostics-o/var/folders/2p/rs8p19s957ggyxzntnj3tp_40000gn/t/test-bb5ff8.o/usr/bin/ld/var/folders/2p/ rs8p19s957ggyxzntnj3tp_40000gn/t/test-bb5ff8.o-force_load/applications/xcode6-beta.app/contents/developer/ toolchains/xcodedefault.xctoolchain/usr/lib/arc/libarclite_macosx.a-syslibroot/applications/xcode6-beta.app/ Contents/developer/platforms/macosx.platform/developer/sdks/macosx10.10.sdk-lsystem-arch x86_64-l/Applications/ Xcode6-beta.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/lib/swift/macosx-rpath/applicatioNs/xcode6-beta.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/lib/swift/macosx-macosx_version_ Min 10.10.0-no_objc_category_merging-o Test

Note However the Swift libraries is loaded (via@rpath) from/Applications/Xcode6-Beta/.../swift/macosxSo the binary won ' t work on another system unless it's got the same version of Xcode installed in the same place. Unless want to do lots of copying/install_name_toolCalls to sort it out ...

$ otool -l test |fgrep path name @rpath/libswiftAppKit.dylib (offset 24) name @rpath/libswiftCoreGraphics.dylib (offset 24) name @rpath/libswiftDarwin.dylib (offset 24) name @rpath/libswiftDispatch.dylib (offset 24) name @rpath/libswiftFoundation.dylib (offset 24) name @rpath/libswiftObjectiveC.dylib (offset 24) name @rpath/libswift_stdlib_core.dylib (offset 24) path /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.x



1. Install Xcode 6 Beta2. To set the path:

Export Path=/applications/xcode6-beta.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin: $PATH

3. Vim Test.swift

println ("Hello Swift")

4.

xcrun swift-v-o test test.swift  
5 ./test


Compiling command-line terminal Swift

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.