因为我使用的是黑苹果 10.13.6 不支持安装Xcode 10.2,黑苹果升级系统又太麻烦,所以只能想了个办法让Xcode 10.1支持Swift 5.
操作步骤
1.下载Swift 5.0 Development Branch Toolchain。
2.安装
3.在Xcode.app中 将Swift.xcspec文件复制出来修改 修改完成替换
路径: /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/XCLanguageSupport.xcplugin/Contents/Resources/Swift.xcspec
SupportedLanguageVersions = (
3.0,
4.0,
4.2
);
LanguageVersionDisplayNames = {
3.0 = "Swift 3";
4.0 = "Swift 4";
4.2 = "Swift 4.2";
};
//添加以下
SupportedLanguageVersions = (
3.0,
4.0,
4.2,
5.0
);
LanguageVersionDisplayNames = {
3.0 = "Swift 3";
4.0 = "Swift 4";
4.2 = "Swift 4.2";
5.0 = "Swift 5.0";
};
4.使用
- 打开或创建一个Xcode项目
-
转到顶部菜单并选择Xcode…Toolchains… Swift 5.0 Snapshot…
-
在Build Settings中设置Swift language版本
来源:传送门