我目前在Swift编码,我有一个错误:
没有这样的模块
但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
框架是在Objective-C中,所以我为它写了一个桥标头。
请问,如何让Xcode识别框架?
我目前在Swift编码,我有一个错误:
没有这样的模块
但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
框架是在Objective-C中,所以我为它写了一个桥标头。
请问,如何让Xcode识别框架?
当前回答
我赢得了“没有这样的模块”错误的最愚蠢原因奖。在我的例子中,我手工构建了包含的框架,并将其复制到我的项目目录中。我的框架搜索路径设置正确,框架也被正确地添加到项目中。
当我归档我正在构建的框架时,我使用“Show in Finder”将我带到派生数据中的发布文件夹。但是我没有注意到这个文件夹只包含框架的别名,而不是框架本身。原始框架仍然在我的派生数据目录中,所以后来当我清除派生数据时,框架被删除了,但我的项目不知道这一点。
重新归档框架,遵循别名到实际框架,并将其复制到我的项目目录中,这是可行的。
其他回答
有几个潜在的错误配置可能会导致这个问题,
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.
我不太确定为什么Martin R在评论中对这个问题的回答被如此忽视:
确保您尝试简单地跳过导入框架,因为它已经与桥接头一起添加了。
希望这能有所帮助
此错误也可能由框架缺少模块映射引起。如果您试图导入的框架是您自己的框架,请检查框架本身的编译器警告。在我的情况下,我的框架正在构建和到位,但有一个构建警告:
警告:没有为目标'MyFramework'找到伞头,模块映射将不会生成
通过解决这个警告(与框架头不匹配模块名有关),我能够导入框架。
我在使用Cocoapods和Swift时也遇到了同样的问题。我没有注意到Podfile中的以下行:
# Uncomment this line if you're using Swift
# use_frameworks!
所以,我所要做的就是把它改成:
# Uncomment this line if you're using Swift
use_frameworks!
...啊,它起作用了:)
对我来说,使用M1机器唯一有效的方法是使用Rosetta运行Xcode。如果没有这些,我只能在真正的设备上运行应用,而不能在iOS模拟器上运行。构建应用程序可能会有点慢,但它绝对解决了这个问题。 如果你不知道如何打开Rosetta,下面是步骤:
Xcode辞职 在应用程序文件夹中找到Xcode,右键单击它并按下获取信息 使用Rosetta勾选打开,如下图所示 再次打开Xcode并运行你的应用
不确定是否需要删除派生数据和清理项目,但您也可以这样做。