3

I've been trying code coverage testing for Mac application on Xcode4.4.1, and the app is an 10.8 app so the app builds and runs only via Xcode4.4.1. But the /Developer/usr/lib/libprofile_rt.dylib library is not found while using Xcode4.4.1. Is there anyway or better tool to run Code coverage on Xcode4.4.1 ?

Looking for some code coverage tool to work for both mac and iOS app on Xcode4.4.1

Vijay
  • 878
  • 1
  • 7
  • 21

3 Answers3

4

You don't need to include *libprofile_rt.dylib* and use *-profile_rt* flag when running project in xCode 4.4.1 (works with iOS Simulator like a charm) Just set these flags:

Generate Test Coverage Files: YES
Instrument Program Flow: YES

Build and run. In case you runt Test-target of your app, *.gcda files are created automatically because tested app terminates, in case of running regular target, *.gcda files are created when you explicitly kill your app (the other approach is to set UIApplicationExitsOnSuspend = YES in .plist)

Please note, it was well tested on new project created with xCode 4.4.1

d.lebedev
  • 2,305
  • 19
  • 27
  • Apart from iOS app., is this solution achievable for Mac application? – Vijay Aug 23 '12 at 04:20
  • Ya I've verified this too,. it works. Seems like the DerivedData directory location had been changed to /User//Library/DerivedData for Xcode4.4.1 – Vijay Aug 23 '12 at 05:15
  • 1
    In xCode 4.4.1 I can't figure out how to add UIApplicationExitsOnSuspend. I've edited Info.plist to add UIApplicationExitsOnSuspend, but when I press the home button the logs say "Detected an attempt to call a symbol in system libraries that is not present on the iPhone: fopen$UNIX2003 called from function llvm_gcda_start_file in image MyApp. (lldb). I have created a new question [here](http://stackoverflow.com/questions/12152416/attempt-to-call-symbol-that-is-not-present-in-system-libraries-llvm-gcda-start) – Nicholas Albion Aug 28 '12 at 03:35
  • If I disable it, I'll get the linking errors, would I have to recompile the target with it disable so that when linking with the library, I won't need this dependency. – Brian Liang Jan 04 '13 at 05:01
3

You just need to set the following in Build Settings:
Generate Test Coverage Files: YES
Instrument Program Flow: YES

The .gcda files will only be output when the app exits so, for iOS builds, you should set 'UIApplicationExitsOnSuspend' to YES in the Info.plist.

Code coverage files will be output to <derived data>/Build/Intermediates/.build/<configuration>/<targetName>.build/Objects-normal/i386

StephenG
  • 76
  • 3
0

Seems like Code coverage using LLVM and CoverStrory is broken in Xocde4.4.1 ,

https://devforums.apple.com/message/717814#717814 - Is the link in apple dev forum discussing this issue.

Vijay
  • 878
  • 1
  • 7
  • 21