当前位置:懂科普 >

综合知识

> xcode怎么写swift

xcode怎么写swift

1.怎么利用xcode开发swift应用程序

1首先,我们必须在苹果Mac电脑上搭建xcode开发环境。

xcode怎么写swift

2打开“xcode”开发工具,点击“File”->“New”->“Project”项来创建一个新的工程。3接着在打开的“创建工程”向导界面中,选择“OS X”系统中的“Application”项,选中“Command Line Tool”项,点击“Next”按钮来创建一个基于OS X系统的命令行应用程序。

4接着输入“Project Name”(工程名称)和“Language”(语言),特别的在此我们选择使用“swift”语言进行创建应用程序,点击“Next”按钮。5然后直接点击“Create”按钮创建应用程序。

6在程序开发界面中,点击左侧的“main_swift”项,就可以打开主程序编程窗口。在此窗口中,只有一条语句:“println("Hello,World!")”该语句的功能是在输出窗口中显示“Hello,World!”字样。

7点击界面左上角的“运行”按钮,然后就可以在输出窗口中看到输出结果啦。

2.如何找出Xcode中不同版本Swift的路径

熟悉unix shell命令的童鞋都知道有一个find指令,在我们已知Xcode路径时,我们可以在其中找到Swift在哪里:

find /Applications/Xcode.app -name swift -a -type f

以上命令中的-a选项表示的是and逻辑,你也可以写全称为-and.所以你必须同时符合name为swift,同时type为一般文件这两个条件才可以哦.

其他type的参数有:

-type t

True if the file is of the specified type. Possible file types are as follows:

b block special

c character special

d directory

f regular file

l symbolic link

p FIFO

s socket

在本猫的air上运行以上指令结果如下:

/Applications/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/bin/swift

/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift

第一个swift版本显然是2.3,我们看一下后面Swift的版本:

/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -version

Apple Swift version 3.0 (swiftlang-800.0.34.6 clang-800.0.33)

Target: x86_64-apple-macosx10.9

不出意外是Swift 3.0哦,我的Xcode是8.0beta4

标签: swift xcode
  • 文章版权属于文章作者所有,转载请注明 https://dongkepu.com/zonghezhishi/gwvj5w.html