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

没有这样的模块

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

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

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


当前回答

我只是通过删除引用来删除框架,然后再次添加它们。

其他回答

我赢得了“没有这样的模块”错误的最愚蠢原因奖。在我的例子中,我手工构建了包含的框架,并将其复制到我的项目目录中。我的框架搜索路径设置正确,框架也被正确地添加到项目中。

当我归档我正在构建的框架时,我使用“Show in Finder”将我带到派生数据中的发布文件夹。但是我没有注意到这个文件夹只包含框架的别名,而不是框架本身。原始框架仍然在我的派生数据目录中,所以后来当我清除派生数据时,框架被删除了,但我的项目不知道这一点。

重新归档框架,遵循别名到实际框架,并将其复制到我的项目目录中,这是可行的。

在极少数情况下,此错误可以通过在[ProjectNavigator]->[项目]->[目标]->(架构)BaseSDK设置适当的平台来修复

当创建一个框架时,我不小心选择了错误的模板(因为我之前创建macOS框架),因为它被设置为喜欢我之前的选择。当添加目标时,很容易忽略配置平台,所以要仔细检查。

如果你使用CocoaPods,试着注释掉(#)新的pod,运行pod install,把它带回来,然后再次安装pod。有时somewhy pod脚本不能产生正确的依赖关系(或者与运行xCode冲突?)所以它有时确实有帮助

有几个潜在的错误配置可能会导致这个问题,

Please confirm that you have opened the .xcworkspace but not .xcodeproj file. Also make sure you have build Social first before you build TriviaApp. Make sure that iOS Deployment Target is set same for all modules with main app. For example is TriviaApps deployment target is set to 9.0, Socials deployment target also need to be set to 9.0. Make sure your main module (TriviaApp) and your used framework (Social) have same set of configurations. i.e. If your Project has three configurations, Debug, Release, ReleasePremium than your Social framework also need to have three configurations Debug, Release, ReleasePremium. Also make sure that the archive configuration is set same for both TriviaApp and Social. i.e. if your TriviaApps archive scheme is set to ReleasePremium, your Socials archive scheme also need to be set into ReleasePremium. Please assure that you do not need to import Social in each .swift files when its already added in the Bridging-Header.h. In case of issue came from Pod files, make sure you have uncommented #use_frameworks! into use_frameworks! from you Podfile. Sometime re installing pod works if Social has any dependency on pods. If none of the above steps works, delete your derived data folder and try re building.

TL;DR:检查Podfile中特定于目标的shared_pods

在绞尽脑汁尝试了上周贴在这里的每一个答案之后,我终于找到了一个解决方案。

我有两个独立的目标——一个用于发布,一个用于开发。开发目标是在发布目标之后很久才创建的,这导致我忘记了该目标的一些设置步骤。

我能够使用我的发布目标正确地编译我的项目,但是我的开发目标遇到了一个问题。

在第20次查看我的Podfile后,我注意到在我的shared_pods定义下只有以下内容:

target 'Release' do
  shared_pods
end

我需要做的是将我的第二个目标添加到我的Podfile中,这就解决了这个问题:

target 'Release' do
  shared_pods
end

target 'Development' do
    shared_pods
end

希望这能让一些人少受几天的困扰。