You are currently viewing the BOOK: Professional iPhone and iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Well that was fun… I guess. Having never done Unit Testing before, trying to reconcile the book's instructions with Xcode 4's integrated Unit Test was a journey. Didn't succeed on the first try, so went back and did it in Xcode 3.
There are a few minor issues with the instructions.
1. On page 432 User Interaction should be disabled for the textFields
2. p. 437 dealloc should also have [pickerViewController release];
3. p. 440 PickerViewController.m should implement a -dealloc method releasing the instance variables.
4. p. 442 step 3 is a little muddled, since the name key is linked with the age value and the age key is not mentioned at all. Fortunately, the screen shot (Figure 12-15) does clarify what is intended.
5. If the step 3 is not understood, step 5 is a non sequitur
As far as the Unit Test section, Xcode 4 handles everything for you and my mistake was to try to find a way to apply the book's steps in Xcode 4. There is no need to. The question I had about Xcode 3 (which does not seem relevant for Xcode 4) is, the steps in the book involve creating a separate profile for the Unit Test (which I did). Would an existing profile work?
A plus for Xcode 4 is that the tests can be run in the simulator, the bundle identifier does not need to be changed and other than implementing the tests, the bundles, targets and templates are all created for you. Unfortunately, for me 2 errors are coming up when attempting to run the tests on a device which do not appear when running the tests in the simulator. (Both from the book project and an unaltered template project) The tests complete successfully in the simulator but log the following on the iPad:
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.1 (8G4)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
I can't find a DevToolsBundleInjection.framework anywhere. "Symbols" does not even have a subdirectory called "Developer"
and
gdb-arm-apple-darwin(48411,0x7fff704d4ca0) malloc: *** error for object 0x10161d418: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
and a broken pipe error
'putpkt: write failed':
Hope to resolve this soon, and curious as to whether this is something others have run into.
I have uploaded the project that works on the current release of Xcode 4.
Quote:
NOTE: You are going to have to change the bundle id's and get your own provisioning profile for this to work for you. This currently is for my device, so it will fail if is not changed.
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
warning: Couldn't get real path for inserted library /Developer/Xcode4/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
warning: Couldn't get real path for inserted library /Developer/Xcode4/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
target remote-mobile /tmp/.XcodeGDBRemote-1320-29
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11523 thread 0x0]
[Switching to process 11523 thread 0x0]
sharedlibrary apply-load-rules all
warning: Unable to read symbols for /Developer/Xcode4/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection (file not found).
warning: Unable to read symbols for /Developer/Xcode4/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit (file not found).
warning: Unable to read symbols for /Developer/Xcode4/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/usr/lib/info/dns.so (file not found).
Test Suite 'All tests' started at 2011-05-26 16:50:20 +0000
Test Suite '/var/mobile/Applications/4AC66F56-838A-4434-8FCA-D70B6A566293/UnitTests.app/UnitTestsBundle.octest(Tests)' started at 2011-05-26 16:50:20 +0000
Test Suite 'AppTests' started at 2011-05-26 16:50:20 +0000
Test Case '-[AppTests testAppDelegate]' started.
2011-05-26 11:50:20.994 UnitTests[1160:307] -[AppTests testAppDelegate] setUp
2011-05-26 11:50:21.021 UnitTests[1160:307] -[AppTests testAppDelegate] tearDown
Test Case '-[AppTests testAppDelegate]' passed (0.043 seconds).
Test Case '-[AppTests testNamesCount]' started.
2011-05-26 11:50:21.039 UnitTests[1160:307] -[AppTests testNamesCount] setUp
2011-05-26 11:50:21.061 UnitTests[1160:307] -[AppTests testNamesCount] tearDown
Test Case '-[AppTests testNamesCount]' passed (0.037 seconds).
Test Case '-[AppTests testPickerSelection]' started.
2011-05-26 11:50:21.078 UnitTests[1160:307] -[AppTests testPickerSelection] setUp
2011-05-26 11:50:21.111 UnitTests[1160:307] -[AppTests testPickerSelection] tearDown
Test Case '-[AppTests testPickerSelection]' passed (0.057 seconds).
Test Case '-[AppTests testViewController]' started.
2011-05-26 11:50:21.138 UnitTests[1160:307] -[AppTests testViewController] setUp
2011-05-26 11:50:21.156 UnitTests[1160:307] -[AppTests testViewController] tearDown
Test Case '-[AppTests testViewController]' passed (0.031 seconds).
Test Suite 'AppTests' finished at 2011-05-26 16:50:21 +0000.
Executed 4 tests, with 0 failures (0 unexpected) in 0.168 (0.185) seconds
Test Suite '/var/mobile/Applications/4AC66F56-838A-4434-8FCA-D70B6A566293/UnitTests.app/UnitTestsBundle.octest(Tests)' finished at 2011-05-26 16:50:21 +0000.
Executed 4 tests, with 0 failures (0 unexpected) in 0.168 (0.216) seconds
Test Suite '/Developer/Library/Frameworks/SenTestingKit.framework(Tests)' started at 2011-05-26 16:50:21 +0000
Test Suite 'SenInterfaceTestCase' started at 2011-05-26 16:50:21 +0000
Test Suite 'SenInterfaceTestCase' finished at 2011-05-26 16:50:21 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.011) seconds
Test Suite '/Developer/Library/Frameworks/SenTestingKit.framework(Tests)' finished at 2011-05-26 16:50:21 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.036) seconds
Test Suite 'All tests' finished at 2011-05-26 16:50:21 +0000.
Executed 4 tests, with 0 failures (0 unexpected) in 0.168 (0.300) seconds
Program ended with exit code: 0
Last edited by gbacklin; May 30th, 2011 at 10:07 AM.
The Following User Says Thank You to gbacklin For This Useful Post:
Hi Gene, I got mine working after a doing a clean, deleting the app and restarting both Xcode and my iPhone. Subsequent tests won't work without repeating the 4 steps above. Can't explain why though.
Vernon
Console Output:
Code:
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
target remote-mobile /tmp/.XcodeGDBRemote-6578-22
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x0]
[Switching to process 11779 thread 0x0]
sharedlibrary apply-load-rules all
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection (file not found).
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit (file not found).
Test Suite 'All tests' started at 2011-05-29 16:18:34 +0000
Test Suite '/Developer/Library/Frameworks/SenTestingKit.framework(Tests)' started at 2011-05-29 16:18:34 +0000
Test Suite 'SenInterfaceTestCase' started at 2011-05-29 16:18:34 +0000
Test Suite 'SenInterfaceTestCase' finished at 2011-05-29 16:18:34 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.002) seconds
Test Suite '/Developer/Library/Frameworks/SenTestingKit.framework(Tests)' finished at 2011-05-29 16:18:34 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.006) seconds
Test Suite '/var/mobile/Applications/7062E42B-69B3-4BA3-A6F3-BAD0D3F4AC6D/UnitTestsTests.octest(Tests)' started at 2011-05-29 16:18:34 +0000
Test Suite 'UnitTestsTests' started at 2011-05-29 16:18:34 +0000
Test Case '-[UnitTestsTests testAppDelegate]' started.
Test Case '-[UnitTestsTests testAppDelegate]' passed (0.000 seconds).
Test Case '-[UnitTestsTests testNamesCount]' started.
Test Case '-[UnitTestsTests testNamesCount]' passed (0.000 seconds).
Test Case '-[UnitTestsTests testPickerSelection]' started.
Test Case '-[UnitTestsTests testPickerSelection]' passed (0.001 seconds).
Test Case '-[UnitTestsTests testViewController]' started.
Test Case '-[UnitTestsTests testViewController]' passed (0.000 seconds).
Test Suite 'UnitTestsTests' finished at 2011-05-29 16:18:34 +0000.
Executed 4 tests, with 0 failures (0 unexpected) in 0.002 (0.005) seconds
Test Suite '/var/mobile/Applications/7062E42B-69B3-4BA3-A6F3-BAD0D3F4AC6D/UnitTestsTests.octest(Tests)' finished at 2011-05-29 16:18:34 +0000.
Executed 4 tests, with 0 failures (0 unexpected) in 0.002 (0.010) seconds
Test Suite 'All tests' finished at 2011-05-29 16:18:34 +0000.
Executed 4 tests, with 0 failures (0 unexpected) in 0.002 (0.031) seconds
Program ended with exit code: 0
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
target remote-mobile /tmp/.XcodeGDBRemote-7539-21
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
gdb-arm-apple-darwin(7751,0x7fff71102ca0) malloc: *** error for object 0x10045fac8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
FYI, I downloaded Apple's Sample code on UnitTests and also received:
Code:
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
warning: Couldn't get real path for inserted library /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/Developer/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
the DevToolsBundleInjection.framework only seems to come up in Xcode 3 Tools:
/Developer/XCode3/Library/PrivateFrameworks/DevToolsBundleInjection.framework
There is however in Xcode 4 :
/Developer/Xcode4/Library/PrivateFrameworks/IDEBundleInjection.framework
Last edited by gbacklin; May 30th, 2011 at 11:28 AM.