Unit Testing woes

0 views
Skip to first unread message

Bart van Deventer

unread,
Oct 26, 2009, 6:23:22 AM10/26/09
to Australian Cocoaheads
Hi all,

I'm having some trouble with setting up Unit Testing on a Mac project
I'm working on. I'm getting the following error when building the
Release Configuration:

--------
Ld build/Sample.build/Release/UnitTests.build/Objects-normal/x86_64/
UnitTests normal x86_64
cd ~/Projects/Sample
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/gcc-4.2 -arch x86_64 -bundle -isysroot /Developer/
SDKs/MacOSX10.6.sdk -L~/Projects/Sample/build/Release -F~/Projects/
Sample/build/Release -F/Developer/Library/Frameworks -filelist ~/
Projects/Sample/build/Sample.build/Release/UnitTests.build/Objects-
normal/x86_64/UnitTests.LinkFileList -mmacosx-version-min=10.6 -
bundle_loader ~/Projects/Sample/build/Release/Sample.app/Contents/
MacOS/Sample -framework Cocoa -framework SenTestingKit -o ~/Projects/
Sample/build/Sample.build/Release/UnitTests.build/Objects-normal/
x86_64/UnitTests

Undefined symbols:
"_OBJC_CLASS_$_SampleAppDelegate", referenced from:
__objc_classrefs__DATA@0 in TestSampleAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
--------

It seems to only occur for the x86_64 build, the i386 and ppc builds
link ok:

--------
Ld build/Sample.build/Release/UnitTests.build/Objects-normal/i386/
UnitTests normal i386
cd ~/Projects/Sample
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/gcc-4.2 -arch i386 -bundle -isysroot /Developer/
SDKs/MacOSX10.6.sdk -L~/Projects/Sample/build/Release -F~/Projects/
Sample/build/Release -F/Developer/Library/Frameworks -filelist ~/
Projects/Sample/build/Sample.build/Release/UnitTests.build/Objects-
normal/i386/UnitTests.LinkFileList -mmacosx-version-min=10.6 -
bundle_loader ~/Projects/Sample/build/Release/Sample.app/Contents/
MacOS/Sample -framework Cocoa -framework SenTestingKit -o ~/Projects/
Sample/build/Sample.build/Release/UnitTests.build/Objects-normal/i386/
UnitTests

Ld build/Sample.build/Release/UnitTests.build/Objects-normal/ppc/
UnitTests normal ppc
cd ~/Projects/Sample
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/gcc-4.2 -arch ppc -bundle -isysroot /Developer/SDKs/
MacOSX10.6.sdk -L~/Projects/Sample/build/Release -F~/Projects/Sample/
build/Release -F/Developer/Library/Frameworks -filelist ~/Projects/
Sample/build/Sample.build/Release/UnitTests.build/Objects-normal/ppc/
UnitTests.LinkFileList -mmacosx-version-min=10.6 -bundle_loader ~/
Projects/Sample/build/Release/Sample.app/Contents/MacOS/Sample -
framework Cocoa -framework SenTestingKit -o ~/Projects/Sample/build/
Sample.build/Release/UnitTests.build/Objects-normal/ppc/UnitTests
--------

I've managed to recreate the problem in a sample project that is
little more than Xcode's Cocoa Application template with a Unit Test
target configured and a single test case.
Get it at: http://dev-enter.com/

FYI, the issue exists in both Xcode 3.2 and 3.2.1, but I'm unable to
test on anything else.

Has anyone else seen this before? I wasn't able to find anything on
Stackoverflow or Google about it.

Any help would be appreciated.

Bart van Deventer

unread,
Oct 26, 2009, 6:25:30 AM10/26/09
to Australian Cocoaheads
Ack

http://dev-enter.com/Sample.dmg was the link should have said.

Matt Gallagher

unread,
Oct 26, 2009, 7:20:44 AM10/26/09
to cocoah...@googlegroups.com
Hi Bart,

The linker can't find the symbols it needs to link against because
they're not visible.

The easiest fix is to turn off "Symbols Hidden by Default" for your
"Sample" target (Target Settings->Build->Release Configuration-
>Symbols Hidden by Default->Off).

Cheers,
Matt.

Bart van Deventer

unread,
Oct 26, 2009, 7:55:26 AM10/26/09
to cocoah...@googlegroups.com, cocoah...@googlegroups.com
Thanks Matt,

That seems to work.
The same setting applied to all architectures for all configurations
though. Any idea why it only failed in this one case?

Cheers,
Bart

Matt Gallagher

unread,
Oct 26, 2009, 8:11:53 AM10/26/09
to cocoah...@googlegroups.com
The reason why it fails for x86_64 is because x86_64 (and iPhone 32-
bit) links against a different runtime (the "modern" runtime) for
Objective-C and can now hide entire classes when "Symbols Hidden by
Default" is enabled. Previous runtimes (the "legacy" runtime used on
all other platforms) didn't allow classes to be hidden.

Cheers,
Matt.
Reply all
Reply to author
Forward
0 new messages