更改部署目标后,无法再将应用程序模块导入单元测试 [英] Can no longer import app module into unit tests after changing deployment target
问题描述
要在快速单元测试中对主应用程序目标的公共类进行单元测试,必须像这样将我的主应用程序模块导入测试:
For unit testing public classes of my main app target in my swift unit tests, I have to import my main app module in my tests like so:
#import MyAppModuleName
在我将部署目标从7.0更改为8.4之前,此方法一直很好.
This worked just fine until I changed my deployment target from 7.0 to 8.4.
现在,构建和运行我的应用程序仍然可以正常运行,但是运行单元测试已停止工作.编译器抱怨上面的导入语句:Swift Compiler Error: Module file's minimum deployment target is iOS8.4 v8.4
Now building and running my app still works perfectly, but running unit tests stopped working. The compiler complains about the above import statement: Swift Compiler Error: Module file's minimum deployment target is iOS8.4 v8.4
我不知道为什么.我忘了在其他地方更改部署目标吗?
I have no clue why. Did I forget to change the deployment target somewhere else?
我的工作区(Xcode 6.4.)包含我自己的项目和Pods项目(由cocoapods自动创建).我在应用程序和测试中同时使用了Swift和Objective-C.
My workspace (Xcode 6.4.) contains my own project and a Pods project (automatically created by cocoapods). I'm using both Swift and Objective-C in my app and in my tests.
这是我做的更详细的事情:
Here's what I did in more detail:
1)将我的项目,主要目标以及工作区中的Pods
项目的所有部署目标的部署目标从7.0更改为8.4.
1) Changed deployment target from 7.0 to 8.4 for my project, my main target, and also for the Pods
project in my workspace, and all the pods targets.
2)清理了构建文件夹(Shift + Alt + Cmd + K)并重新启动了Xcode.
2) Cleaned the build folder (Shift+Alt+Cmd+K) and restarted Xcode.
3)Cmd + U->错误
3) Cmd+U -> Error
将主应用程序的部署目标更改回7.0时,一切恢复正常.
When changing the main app's deployment target back to 7.0, everything works fine again.
有什么想法可以解决这个问题吗?
Any ideas where this problem is coming from?
推荐答案
您快到了,您只需要更新Project和两个目标的iOS部署目标即可.
You were almost there, you just need to update the iOS Deployment Target for your Project and both of your targets.
针对您的项目:
针对您的应用定位:
针对您的测试目标:
您可能应该清理并重建,而无需重新启动Xcode.我想如果您要定位8.1等,这也将起作用.
You should probably do a clean and rebuild, no need to restart Xcode. I guess this will also work if you want to target 8.1 etc.
这篇关于更改部署目标后,无法再将应用程序模块导入单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!