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

没有这样的模块

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

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

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


当前回答

如果你是面向tvOS这样的平台创造游戏,请确保你选择了一个Apple TV模拟器。

使用iOS模拟器创建tvOS应用时,我就犯了这个错误。花了大半个小时寻找各种构建问题……哎。

其他回答

有时你必须安装pod。

打开终端 cd项目 圆荚体安装 打开.xcworkspace和 构建是成功的

没想到这竟然起作用了。我的解决办法是……

构建设置->框架搜索路径->高亮调试->按delete ->它应该自动填写一个路径。->释放时执行同样的操作

结果:

对我来说,解决同样问题的方法是相对于工作空间目录设置派生数据位置,而不是保持默认值。 去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.

我在使用Cocoapods和Swift时也遇到了同样的问题。我没有注意到Podfile中的以下行:

# Uncomment this line if you're using Swift
# use_frameworks!

所以,我所要做的就是把它改成:

# Uncomment this line if you're using Swift
use_frameworks!

...啊,它起作用了:)