博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
编译命令行终端 swift
阅读量:6837 次
发布时间:2019-06-26

本文共 2738 字,大约阅读时间需要 9 分钟。

 
So, this is where swift lives, after you've installed XCode 6 Beta:
/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
Also, there's a directory named swift which has various libraries:
/Applications/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 are loaded (via @rpath) from /Applications/Xcode6-Beta/.../swift/macosx so the binary won't work on another system unless it's got the same version of Xcode installed in the same place. Unless you want to do lots of copying/install_name_tool calls 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. 安装xcode 6 beta
2. 设置路径:

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

转载地址:http://oyqkl.baihongyu.com/

你可能感兴趣的文章
Spring Mvc 实例
查看>>
MySQL深入理解
查看>>
三步快速解决dll冲突问题
查看>>
vue
查看>>
【cl】找不到火狐Cannot find firefox binary in PATH
查看>>
移动端无法复制:使用clipboard.js碰到的一个小问题
查看>>
程序员常去的103个网站
查看>>
联想的amd电脑,Debian8.8开机后亮度值始终最大,尝试过各种方法,始终无法解决,最后debian8.8在安装开源驱动后,成功调节...
查看>>
debian8修改kde桌面语言
查看>>
PHP对于数据库的基本操作——更新数据
查看>>
How HashMap works in Java
查看>>
洛谷P2057 善意的投票
查看>>
UVa11401 Triangle Counting
查看>>
MongoDB
查看>>
Matlab DIP(瓦)ch11表示与描述练习
查看>>
Sicily/1203. The Cubic End
查看>>
进程监控树。
查看>>
如何将ToolBar 样式设置Title文字水平居中
查看>>
Maven 核心原理
查看>>
UVA 1613 K-Graph Oddity
查看>>