其他

在Xcode 10.1 中使用 Swift 5

2019-06-28  本文已影响478人  zhongxiaoyue

因为我使用的是黑苹果 10.13.6 不支持安装Xcode 10.2,黑苹果升级系统又太麻烦,所以只能想了个办法让Xcode 10.1支持Swift 5.

操作步骤

  1. 下载并安装Swift 5.0 Development Branch Toolchain。

  2. 打开或创建一个Xcode项目

  3. 转到顶部菜单并选择Xcode…Toolchains… Swift 5.0 Snapshot…

Xcode-Toolchain-Menu.png

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";        
        };
  1. 在Build Settings中设置Swift language版本


上一篇下一篇

猜你喜欢

热点阅读