2016-03-31 29 views
9

我跟着的Alamofire的指令github總是建立自己的錯誤:沒有這樣的模塊「Alamofire」

我創建了一個名爲cocoapods-test & Xcode的項目,我關閉了它。

我去項目文件夾運行pod init命令,它生成一個Podfile。然後,我添加以下代碼到Podfile:

source 'https://github.com/CocoaPods/Specs.git' 
platform :ios, '8.0' 
use_frameworks! 

pod 'Alamofire', '~> 3.0' 

然後,我運行命令pod install,這是導致終端:

Updating local specs repositories 

CocoaPods 1.0.0.beta.6 is available. 
To update use: `gem install cocoapods --pre` 
[!] This is a test version we'd love you to try. 

For more information see http://blog.cocoapods.org 
and the CHANGELOG for this version http://git.io/BaH8pQ. 

Analyzing dependencies 
Downloading dependencies 
Installing Alamofire (3.3.0) 
Generating Pods project 
Integrating client project 

[!] Please close any current Xcode sessions and use `cocoapods-test.xcworkspace` for this project from now on. 
Sending stats 
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed. 

然後,在我的項目文件夾中有一個新的文件名爲cocoapods-test.xcworkspace。我雙擊它再次打開我的xcode,我可以看到Alamofire模塊。

然後,我打開了我的項目ViewController類和import Alamofire。但不管我多少次清洗&內置,我總是得到錯誤No such module 'Alamofire'。下面是截圖:

enter image description here

爲什麼我得到這個問題,但我也跟着一步的指示一步?

(我用XCode 7.2.1Swift 2.1.1 & Alamofire 3.3.0

======= UPDATE ========

我試圖@LK楊的回答,取消import Alamofire,然後再清理&身材,我從Alarmofire一堆編譯器錯誤的:

enter image description here

+0

「您需要將該庫添加到」鏈接二進制庫「部分。」 http://stackoverflow.com/questions/25817479/cannot-install-alamofire-in-new-xcode-project-no-such-module-alamofire – YarGnawh

+0

@YarGnawh,不,您提供的鏈接是完全不同的安裝方式Alamofire。它下載庫,但我正在使用Alamofire github建議的方式,這是通過cocoapod工具。他們是不同的。在「Link Binary With Library」中,我甚至沒有看到Alamofire框架。因爲我以另一種方式安裝它,請閱讀我的文章,我已經一步步地告訴我如何安裝它。 –

+0

http://stackoverflow.com/a/40360050/1804274上的說明解決了我的問題 – Dudling

回答

7

我有這個完全相同的問題。請確保您使用的是Xcode 7.3並使用Swift 2.2。

您可以使用xcrun swift -version檢查您的Swift版本。更新Xcode到7.3應該也會自動更新Swift。

更新Xcode爲我解決了這個問題。

+0

你是對的!謝謝! –

2

您需要添加的lib到「鏈接二進制與圖書館」欄目也

8

您需要使用庫

意見進口Alamofire成功之前曾經構建項目 - >構建 - >取消註釋進口Alamofire

+0

這解決了我的問題。順便說一下,它隻影響基於Swift的豆莢。我能夠成功導入基於Obj-C的豆莢,而無需首先構建。 – CodeBender

+0

儘管我取消了「導入Alamofire」的註釋,但我仍然清理並構建,xcode仍然構建了Alamofire,它會產生一堆編譯錯誤。所以,這不是正確的答案,因爲Alamofire已經是我的項目的一部分。請參閱我的更新 –

+0

這也解決了我的問題。 – r3dm4n

2

你可以嘗試把pod 'Alamofire', '~> 3.0'如下所示。再次運行pod install

target 'yourtarget' do 
    pod 'Alamofire', '~> 3.0' 
end 
+0

它沒有幫助。 –

0

嘗試最新的更新安裝alamofire並檢查u使用alamofire最新的是這個在您的Xcode支持。

source 'https://github.com/CocoaPods/Specs.git' 
platform :ios, '10.0' 
use_frameworks! 

target '<Your Target Name>' do 
    pod 'Alamofire', '~> 4.4' 
end 

嘗試在你的podfile這上面alamofire

2

確保你已經打開了「PROJECT_NAME」 .xcworkspace,而不是「PROJECT_NAME」 .xcodeproj。至於您正在使用的吊艙安裝的所有pod將僅在您的.xcworkspace項目文件中可用。

0

如果您正在手動安裝Alamofire(或任何其他框架),請確保您的構建配置在您的父項目和子項目之間匹配。例如,如果您的項目中的構建配置稱爲「開發」,但Alamofire的稱爲「調試」,則會出現「無此類模塊」錯誤。

相關問題