前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >编译命令行终端 swift

编译命令行终端 swift

作者头像
全栈程序员站长
发布2022-07-06 17:26:34
9230
发布2022-07-06 17:26:34
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是全栈君

代码语言:javascript
复制
   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.swift
Swift 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

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116893.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年1月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档