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

没有这样的模块

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

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

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


当前回答

Another possible cause in XCode 10 can be the Supported Platforms sometimes gets changed to macOS and the Valid Architectures gets changed to i386 x86_64 for the Pods Projects. Assuming the project is for iOS, then select the Pods Project and change the Supported Platforms to iOS and the Valid Architectures to arm64 arm64e armv7 armv7s, You could do each of the Targets, however that takes longer if you have more than one Pod. Also the Swift version of frameworks in written Swift sometimes gets set to the wrong version.

其他回答

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

错误是“模块未找到”

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)

这是所有。

我在开发定制Pod时遇到了这个问题。发现我只需要在我的Procfile中指定依赖项:

Pod::Spec.new do |s|
   # ... other declarations

   s.dependency 'Alamofire', '~> 4.3'
end

假设框架真的在那里,在道路上,等等……删除~/Library/Developer/Xcode/DerivedData/ModuleCache目录(清理项目并删除项目特定的派生数据)。

在执行标准清理时,不会重新构建ModuleCache目录。

大多数其他答案都是针对CocoaPods或迦太基用户的。如果你不使用这些,但只是想在你的项目中删除一个框架并链接它,它将需要在框架搜索路径中。

系统框架已经在搜索路径(即/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/ sdk/ iPhoneOS${version}.sdk/ system /Library/ frameworks /)。如果您试图使用的文件不在此路径中,则需要将它们的路径添加到Build Settings中的FRAMEWORK_SEARCH_PATHS中。


为什么XCode不知道在哪里找到它,即使你左边面板上的框架在右边面板的标识和类型中列出了一个位置和完整的路径?那我不知道。

No such module编译错误

这是编译时错误。你可以在很多情况下得到它:

打开的是.xcodeproj而不是。xcworkspace 模块。modulemap or .swiftmodule[关于]

Objective-C库/框架目标

确保生成的二进制文件包含模块。modulemap文件和它的头文件位于Build Phases -> headers部分

框架搜索路径

Consumer ->框架

如果你试图在没有设置框架搜索路径(消费者)的情况下构建应用程序。在设置框架搜索路径指向框架资源后,Xcode将成功构建项目。然而,当你在模拟器中运行应用程序时,有一个崩溃的原因:Image not foundabout

它可以是一个绝对路径或相对路径,如$(SRCROOT)或$(SRCROOT)/..对于工作空间

导入路径

Swift消费者-> Swift静态库

导入路径(消费者)应该指向.swiftmodule

寻找隐式依赖关系

当您有一个隐式依赖项,但“查找隐式依赖项”已关闭时

CocoaPods

检查目标中是否存在此依赖项

pod deintegrate
pod install

CocoaPods UI测试包

对于应用程序目标,使用额外的依赖CocoaPods。要解决它使用继承![关于]在Podfile

(递归路径)