2016-09-19 50 views
3

我有一個swift版本2.3的應用程序。使用傳統的Swift語言版本「(SWIFT_VERSION)不起作用

當我嘗試在xcode 8中運行並在構建設置中設置「User Legacy Swift - > YES」時,它僅給出cocoapods的錯誤。

見下圖:

enter image description here

MY莢文件:

platform :ios, '8.0' 
use_frameworks! 

target 'xxx' do 
pod 'Alamofire', '~> 3.3' 
pod 'PKHUD', '~> 3.1' 
pod 'SCLAlertView', '~> 0.5' 
pod 'SwiftyJSON', '~> 2.3' 
pod 'ICSPullToRefresh', '~> 0.4' 
pod 'ReachabilitySwift', '~> 2.3' 
pod 'IQKeyboardManagerSwift', '~> 4.0' 

end 

target 'xxTests' do 

end 

target 'xxUITests' do 

end 


post_install do |installer| 
    installer.pods_project.targets.each do |target| 
     target.build_configurations.each do |config| 
      config.build_settings['SWIFT_VERSION'] = '2.3' 
     end 
    end 
    end 
+1

看到這個https://medium.com/@ziminalex/xcode-8-0-cocoapods-95d8e7a769a9#.io4x2qz6a –

+0

可能是它的HTTP可能重複:/ /stackoverflow.com/questions/38446097/xcode-8-beta-3-use-legacy-swift-issue –

+1

@ Anbu.Karthik,我已經做了同樣的事情,但仍然有錯誤,如圖所示 – user2526811

回答

2

這基本上意味着,豆莢的不同版本迅速比當前的項目建設。

在我的情況下,我的應用程序遷移到了Swift 3,但我的Pod保持在Swift 2.3上,因爲它們還沒有適應Swift 3。你可以做任何這裏的兩件事情:

  1. 由去編輯>轉換>當前斯威夫特語法更改莢斯威夫特3(或任何最新版本雨燕)。
  2. 將您的主項目降級回老版本的Swift。

我希望這可以解釋一些問題。

1

這僅僅是爲我工作的事...

注意,這個錯誤是目前一個豆莢裏的,但可能是在你的項目樹的任何地方。我將向您展示如何在此窗格中「允許」Swift 2.3。基本上我們需要啓用「Legacy Swift Language」。選擇您的吊艙框架(通過點擊在錯誤導航器)和生成設置下找到「使用舊斯威夫特語言版本」

enter image description here

將其設置爲「是」。比「Build & Run」再次測試它。

退房這個帖子: http://rebeloper.com/downgrade-swift-3-swift-2-3-xcode-8/