ios 使用 Xcode 出现错误“没有这样的模块”,但框架在那里
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29500227/
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
Getting error "No such module" using Xcode, but the framework is there
提问by alexandresecanove
I'm currently coding in Swift, and I've got an error:
我目前正在使用 Swift 进行编码,但出现错误:
No such module Social
没有这样的模块社交
But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries".
但我不明白,因为该模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
The frameworks is in Objective-C, so I wrote a Bridge Header for it.
框架是在 Objective-C 中的,所以我为它写了一个 Bridge Header。
Please, how can I make Xcode recognize the framework?
请问,我怎样才能让Xcode识别框架?
采纳答案by terhechte
I'm not sure why this happens, but one way to solve your issue is to go into your build settingsand defining the Framework Search Pathsto a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT)
and set it to recursive.
我不确定为什么会发生这种情况,但解决您的问题的一种方法是进入您的构建设置并将框架搜索路径定义为包含相关框架的文件夹。如果框架放置在您的项目目录中,只需将框架搜索路径$(SRCROOT)
设置为并将其设置为递归。
回答by capikaw
In case it's Friday afternoon or anytime after 1am:
如果是周五下午或凌晨 1 点之后的任何时间:
Opening xcodeproj
instead of xcworkspace
will cause an error like this...
打开xcodeproj
而不是xcworkspace
会导致这样的错误......
回答by Groot
Make sure that the naming of you configurations in the sub projects matches that of the "parent" project. If the configuration naming don't match exactly (case-sensitive), Xcode will abort the archive process and show the error "No such module ..."
确保子项目中配置的命名与“父”项目的命名匹配。如果配置命名不完全匹配(区分大小写),Xcode 将中止存档过程并显示错误“No such module ...”
That is, if you have a "parent" project with a configuration named "AppStore" you must make sure that allsubprojects also have this configuration name.
也就是说,如果您有一个名为“AppStore”的配置的“父”项目,您必须确保所有子项目也具有此配置名称。
See my attached screenshots.
请参阅我附加的屏幕截图。
回答by Mike K
回答by nburk
I had the same issue using Cocoapods and Swift. I didn't notice the following lines in the Podfile:
我在使用 Cocoapods 和Swift 时遇到了同样的问题。我没有注意到 Podfile 中的以下几行:
# Uncomment this line if you're using Swift
# use_frameworks!
So, all I had to do was change it to:
所以,我所要做的就是将其更改为:
# Uncomment this line if you're using Swift
use_frameworks!
...aaand it worked :)
...aa它起作用了:)
回答by Krutarth Patel
回答by mikepj
I was experiencing this problem as well. The fix for me was that the Archive schemes between the two projects didn't match. I have an xcworkspace with a framework project and an app project. The problem was that in the Archive scheme for my app, I was using a different Build Configuration than the framework was using for it's Archive scheme. I set both Build Configurations to Release, and that fixed the issue.
我也遇到了这个问题。对我来说,解决方法是两个项目之间的存档方案不匹配。我有一个带有框架项目和应用程序项目的 xcworkspace。问题是,在我的应用程序的存档方案中,我使用的构建配置与框架用于其存档方案的构建配置不同。我将两个构建配置都设置为发布,并解决了这个问题。
回答by john raja
The following steps worked for me.
以下步骤对我有用。
- Quit xcode
- Run
"pod update"
in terminal - Open
.xcworkspace
and build again.
- 退出 xcode
"pod update"
在终端运行- 打开
.xcworkspace
并重新构建。
回答by mcsheffrey
In my case, after many attempts to figure out what I was doing wrong importing a framework I eventually discovered that the framework itself was the problem. If you are not getting your framework from a trusted source you should inspect the framework and ensure that it contains a Modules folder with a module.modulemap file inside it. If module.modulemap is not present, you will get the "No such module 'MyFramework'" error.
就我而言,经过多次尝试找出我在导入框架时做错了什么之后,我最终发现框架本身就是问题所在。如果您不是从受信任的来源获取您的框架,您应该检查框架并确保它包含一个 Modules 文件夹,其中包含一个 module.modulemap 文件。如果 module.modulemap 不存在,您将收到“No such module 'MyFramework'”错误。
If the Modules folder is missing the "MyFramework.swiftmodule" folder then the framework will be found but Xcode won't know about its contents so you will get different errors.
如果 Modules 文件夹缺少“MyFramework.swiftmodule”文件夹,那么框架会被找到,但 Xcode 不会知道它的内容,所以你会得到不同的错误。
回答by Brad Brighton
Assuming the Framework really is there and in the path, etc... delete the ~/Library/Developer/Xcode/DerivedData/ModuleCache directory (and clean the project and delete the project-specific derived data for good measure).
假设框架确实存在并且在路径中等......删除 ~/Library/Developer/Xcode/DerivedData/ModuleCache 目录(并清理项目并删除项目特定的派生数据以进行良好衡量)。
When you do the standard cleanup, the ModuleCache directory doesn't get rebuilt.
执行标准清理时,不会重建 ModuleCache 目录。