因为我使用的是黑苹果 10.13.6 不支持安装Xcode 10.2,黑苹果升级系统又太麻烦,所以只能想了个办法让Xcode 10.1支持Swift 5.
操作步骤
-
打开或创建一个Xcode项目
-
转到顶部菜单并选择Xcode…Toolchains… Swift 5.0 Snapshot…
4.在Xcode.app中编辑Swift.xcspec 文件
路径: /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/XCLanguageSupport.xcplugin/Contents/Resources/Swift.xcspec
4.1 找到SupportedLanguage的部分
SupportedLanguageVersions = (
3.0,
4.0,
4.2
);
LanguageVersionDisplayNames = {
3.0 = "Swift 3";
4.0 = "Swift 4";
4.2 = "Swift 4.2";
};
4.2 在 SupportedLanguageVersions 和 LanguageVersionDisplayNames 下添加5.0 标签
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";
};
-
在Build Settings中设置Swift language版本
网友评论