我目前在Swift编码,我有一个错误:

没有这样的模块

但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。

框架是在Objective-C中,所以我为它写了一个桥标头。

请问,如何让Xcode识别框架?


当前回答

几分钟前我找到了解决我案子的办法。 该项目是一个使用cocos2d框架的objective c项目。 没有一个预览解决方案有效。

只是我删除VALID_ARCH行自定义在构建设置和项目开始构建模拟器。

其他回答

当框架没有正确编译时也会发生这种情况。

在Xcode中打开框架项目,看看Product→Build是否成功。

一旦在框架中修复了构建错误,打开主项目,看看是否可以导入框架。

几天前我也遇到了同样的错误。下面是我解决这个问题的方法:

错误是“模块未找到”

Create Podfile in your root project directory Install cocoapods (a dependency manager for Swift and iOS projects) Run pod install Go to Project Build Settings: Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project) Drag and drop the library header file from left side to bridging header (see image attached) Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above) In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h" In your Swift file the code should be: Import Mixpanel (i.e name of library)

这是所有。

请将此截图与您的构建设置进行比较。 这可能会奏效。 进入框架搜索路径:

如果你使用迦太基,建筑设置中的框架通常是不变的

$ (PROJECT_DIR) /迦太基/构建/ iOS

如果你运行carthage update—platform ios—no- Build(为了节省时间),Build文件夹中的文件将不会被重新创建,那么这些模块将无法用于XCode。

以我为例,我运行了carthage update平台ios,然后我的问题就解决了。

确保子项目中配置的命名与“父”项目相匹配。如果配置命名不完全匹配(区分大小写),Xcode将中止存档过程,并显示错误“No such module…”

也就是说,如果你有一个“父”项目,配置名为“AppStore”,你必须确保所有子项目也有这个配置名称。

请看我所附的截图。