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

没有这样的模块

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

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

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


当前回答

为了它的价值(我是使用Xcode 7.2/Swift 2的新手),但我注意到,只要从项目目录中的库中拥有. Swift文件,就可以自动地访问它,而不需要using语句。

示例:我正在使用SwiftyJSON,在项目中拥有SwiftyJSON.swift文件就是我所需要的。using语句实际上给了我“没有这样的模块”错误,并把它解决了,它工作得很好。

其他回答

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.

当我使用Cocoapods添加两个框架时,我得到了相同的错误。如果我们在项目中使用Pods,我们应该使用xcodeworkspace而不是xcodeproject。 为了通过xcodebuild运行项目,我在xcodebuild命令中添加了-workspace <workspacename>参数,它工作得很好。

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

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

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

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

我已经安装了吊舱。当我在我的设备上构建应用程序时,构建工作没有任何问题,但存档不能工作。我只是跑:

pod install

没有安装新的pod,只是重新生成了.xcodeproj文件,并开始工作

在我的例子中: 该问题只发生在Xcode 12.4,而不是Xcode 13。 测试目标的一个框架在我为arm64模拟器支持重新构建框架后给出了这个错误(在XCFramework格式)。我通过更新框架搜索路径中的路径来修复它

"$(SRCROOT)/Carthage/Build/WireTesting.xcframework/ios-x86_64-simulator" 

to

"$(SRCROOT)/Carthage/Build/WireTesting.xcframework/ios-arm64_x86_64-simulator"