“没有这样的模块‘Alamofire’”Xcode 无法识别 Alamofire 框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36417151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"No such module 'Alamofire'" Xcode won't recognize Alamofire framework
提问by S.Sohi
I realize that the same error was asked in other questions (like here), but their solutions are not working for me.
I keep getting a build failure in my app: "No such module 'Alamofire'". I followed the cocoadocs installation instructions (here) for installing Alamofire and it still is not working. I made sure everything has the same deployment target.
Embedded Binaries and Frameworks
我意识到在其他问题中也出现了同样的错误(比如这里),但他们的解决方案对我不起作用。我的应用程序中不断出现构建失败:“没有这样的模块‘Alamofire’”。我按照 cocoadocs 安装说明(此处)安装 Alamofire,但它仍然无法正常工作。我确保所有内容都具有相同的部署目标。
嵌入式二进制文件和框架
Here's my podfile text.
这是我的 podfile 文本。
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘9.2'
use_frameworks!
target 'MyApp' do
pod 'Alamofire', '~> 3.0'
end
target 'MyAppTests' do
end
target 'MyAppUITests' do
end
Also, I tried "$ pod install" again in Terminal and got this message:
另外,我在终端中再次尝试了“$ pod install”并收到了这条消息:
[!] The `App [Debug]` target overrides the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting defined in `Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
After following Sohil's suggestions, XCode now recognizes the Alamofire module, but 22 new issues have arisen.
在遵循 Sohil 的建议后,XCode 现在可以识别 Alamofire 模块,但出现了 22 个新问题。
Update #2: So I'm now on Xcode 7.3 and Swift 2.2, but I'm receiving a new error with the workspace Link: "ld: framework not found Alamofire. clang: error: linker command failed with exit code 1 (use -v to see invocation)."
更新 #2:所以我现在使用 Xcode 7.3 和 Swift 2.2,但我收到工作区链接的新错误:“ld:框架未找到 Alamofire。clang:错误:链接器命令失败,退出代码为 1(使用-v 查看调用)。”
回答by Sohil R. Memon
Do the following things and you can import any swift file from "Pods"
执行以下操作,您可以从“Pods”导入任何 swift 文件
1) Clean your project
2) Make sure that all your "Pods" > "Build Settings" > "Build Active Architecture Only" is set to "NO".
3) Don't run, just build your project.
4) Now, import any file from "Pods" to any swift file
E.g.: import Alamofire
5) Again, build project and it will work as expected. Finally, you can access it properties
1)清理你的项目
2) 确保你所有的“Pods”>“Build Settings”>“Build Active Architecture Only”都设置为“NO”。
3)不要运行,只需构建您的项目。
4) 现在,将任何文件从“Pods”导入任何 swift 文件
例如:进口 Alamofire
5)再次构建项目,它将按预期工作。最后,您可以访问它的属性
Update:
更新:
For the updated question, I hope you are using Xcode 7.3 so please update the Alamofire
to Swift 2.2
对于更新的问题,我希望您使用的是 Xcode 7.3,因此请将Alamofire
Swift 2.2更新为
Hope this helps!
希望这可以帮助!
回答by Krutarth Patel
回答by jonathanrz
For me the solution was to open the "App".xcworkspace as pointed by the cocoapods documentation
对我来说,解决方案是打开cocoapods 文档指出的“App”.xcworkspace
The steps was:
步骤是:
- Close project
- Close xcode
- Go to terminal
- type "open |App|.xcworkspace"
- 关闭项目
- 关闭 xcode
- 前往终端
- 输入“打开|应用|.xcworkspace”
When I opened Xcode it was still pointing the error then I built the project (cmd+b) and everything is fine now.
当我打开 Xcode 时,它仍然指向错误,然后我构建了项目 (cmd+b),现在一切都很好。
回答by eureka19
The target overrides the OTHER_LDFLAGS
build setting.
目标会覆盖OTHER_LDFLAGS
构建设置。
Use the $(inherited)
flag in TARGENTS -> Build Settings -> Framework Search Paths
使用$(inherited)
TARGENTS -> Build Settings -> Framework Search Paths 中的标志
回答by alicanozkara
in my case, i couldn't run archive after change bundle name. I've cleaned build folder and run pod install then everything worked fine.
就我而言,更改包名称后无法运行存档。我已经清理了构建文件夹并运行 pod install 然后一切正常。