Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

iphone - how to implement application tests in xcode4?

I'm trying to add some Tests for my application. Following the Document from Apple, I add two testing bundles to my project. The logic tests are no problem, but when I try to make the application tests on a device I always get the error that the logic tests don't run on a device.

In Xcode 3 there is no problem with that. Only Xcode 4 throws this error...

Any suggestions?

Thanks, Tim

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

i was also having problems with setting up application tests in xcode4. A solution that worked for me was as follows:

Assuming you have an application target called "MyApp"

  1. Add a new target of type "other/Cocoa Unit Testing Bundle" to the project e.g "MyAppTesting". Here all Unit test files are located.
  2. Go to MyAppTesting Build Phases and add MyApp as Target Dependency. This assures that MyApp is build before building the MyAppTesting target.
  3. Open the Build Settings of MyAppTesting and change
    • Bundle Loader: $(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp
    • Test host: $(BUNDLE_LOADER)
    That causes the tests to run within MyApp.
  4. Open the Build Settings of MyApp and change
    • Symbols Hidden by default: NO (for both)
    • Strip debug Symbols during Copy: Debug:NO
    By doing so you do not have to include every .m-file into the test target.

To run the test on a device plugin the device and select the scheme "MyAppTesting on device" and run as test. Assure that the mentioned scheme has set "Debug" within Test/Build Configuration which should be default.

Best regards.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...