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

没有这样的模块

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

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

请问,如何让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.

其他回答

我仍然不能从xcode存档,但fastlane为我做了这项工作

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

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.

我在开发自己的第一款应用时也遇到了同样的问题

使用.xcodeproj打开项目

Xcode辞职

从.xcworkspace重新打开项目

如果是周五下午或凌晨1点之后:

打开xcodeproj而不是xcworkspace将导致如下错误…

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

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