总是建立自己的错误:没有这样的模块“Alamofire”
我跟着的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'
。下面是截图:
为什么我得到这个问题,但我也跟着一步的指示一步?
(我用XCode 7.2.1
,Swift 2.1.1
& Alamofire 3.3.0
)
======= UPDATE ========
我试图@LK杨的回答,取消import Alamofire
,然后再清理&身材,我从Alarmofire一堆编译器错误的:
我有这个完全相同的问题。请确保您使用的是Xcode 7.3并使用Swift 2.2。
您可以使用xcrun swift -version
检查您的Swift版本。更新Xcode到7.3应该也会自动更新Swift。
更新Xcode为我解决了这个问题。
你是对的!谢谢! –
您需要添加的lib到“链接二进制与图书馆”栏目也
您需要使用库
意见进口Alamofire成功之前曾经构建项目 - >构建 - >取消注释进口Alamofire
这解决了我的问题。顺便说一下,它只影响基于Swift的豆荚。我能够成功导入基于Obj-C的豆荚,而无需首先构建。 – CodeBender
尽管我取消了“导入Alamofire”的注释,但我仍然清理并构建,xcode仍然构建了Alamofire,它会产生一堆编译错误。所以,这不是正确的答案,因为Alamofire已经是我的项目的一部分。请参阅我的更新 –
这也解决了我的问题。 – r3dm4n
你可以尝试把pod 'Alamofire', '~> 3.0'
如下所示。再次运行pod install
。
target 'yourtarget' do
pod 'Alamofire', '~> 3.0'
end
它没有帮助。 –
我有同样的问题,原因是因为我安装了错误版本的alamofire。
我使用的Xcode 7.3,快捷2.2,所以alamofire 3.0为我工作
使用@Michal
Remove or uninstall library previously added : cocoapods
然后在您的POD文件中提到的这些步骤删除库
来源'https://github.com/CocoaPods/Specs.git'
平台:ios,'9.3'< - 你r目标版本
use_frameworks!
目标“”做 荚 'Alamofire',“〜> 3.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
确保你已经打开了“PROJECT_NAME” .xcworkspace,而不是“PROJECT_NAME” .xcodeproj。至于您正在使用的吊舱安装的所有pod将仅在您的.xcworkspace项目文件中可用。
如果您正在手动安装Alamofire(或任何其他框架),请确保您的构建配置在您的父项目和子项目之间匹配。例如,如果您的项目中的构建配置称为“开发”,但Alamofire的称为“调试”,则会出现“无此类模块”错误。
“您需要将该库添加到”链接二进制库“部分。” http://stackoverflow.com/questions/25817479/cannot-install-alamofire-in-new-xcode-project-no-such-module-alamofire – YarGnawh
@YarGnawh,不,您提供的链接是完全不同的安装方式Alamofire。它下载库,但我正在使用Alamofire github建议的方式,这是通过cocoapod工具。他们是不同的。在“Link Binary With Library”中,我甚至没有看到Alamofire框架。因为我以另一种方式安装它,请阅读我的文章,我已经一步步地告诉我如何安装它。 –
http://stackoverflow.com/a/40360050/1804274上的说明解决了我的问题 – Dudling