Adding test target to an existing project is not working

你说的曾经没有我的故事 提交于 2019-12-30 18:25:13

问题


I need to add test cases to an existing project, so I tried adding a new test target via

  1. File -> New -> Target -> Cocoa Touch Testing Bundle
  2. From the test navigator filter bar.

Even after adding, the target is not getting listed in the test filter bar. May be because of this issue, Product -> Test option is diabled in my project. Also I could see some differnce between the build setting in my project and another sample project I started in Xcode 6.1 in which Product -> Test option is enabled and everything working fine for Test cases.

Please find the build settings screen shots.

Any help is appreciated.


回答1:


I had this exact problem. It turns out my existing project was creating my Cocoa Touch Testing Bundle with the .app extension when it should've been a .xctest extension.

You can fix this by going to your test target you created. Build Settings > Wrapper Extension and changing it from app to xctest.

You may have to restart Xcode after this change to select your test target.

UPDATE: I found out the reason the Testing Bundle was becoming a .app extension in the first place. I had to go to the main project Wrapper Extension and make sure it was blank instead of .app. Apparently that was forcing all targets to become .app extension as well.



来源:https://stackoverflow.com/questions/29789839/adding-test-target-to-an-existing-project-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!