Add xctest dependency to Xcode 7 project

徘徊边缘 提交于 2019-12-12 02:45:56

问题


Created a new OS X library project, deleted the Objective-C stubs and add a Swift file (Empty.swift). In the same directory, added a unit test (new->Unit Test), EmptyTest.swift. The code generated won't compile because this OS X library project doesn't know how to resolve the dependency to XCTest.

XCTest is at this location /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/XCTest

The solution for command line tools is here (How can I run XCTest for a swift application from the command line?). How to add the dependency using Xcode 7?


回答1:


You can add Unit test case via new target instead of creating file in the same target

File - New - Target - OS X -Test - OS X Unit Testing Bundle

When you create new unit testing bundle it creates new unit test swift file with XCTest as dependancy When you run this target it don't show the error of XCTest

Update : If you want it in the same target. In the Build Settings find FRAMEWORK_SEARCH_PATHS and add $(PLATFORM_DIR)/Developer/Library/Frameworks in it after that if you build your app will build successfully




回答2:


Show the File Inspector and check the Target Membership on EmptyTest.swift. I'm betting you added it to the production target, when it should be in the test target instead.



来源:https://stackoverflow.com/questions/35686679/add-xctest-dependency-to-xcode-7-project

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