Upgrading to XCode 3.2.3 and iPhone 3.2/4.0 SDK has introduced a strange bug into my build process.
I have a static library, Compton, which itself depends on three20. I build Compton as a dependency of the client apps that it powers.
When I compile Compton as its own project in either simulator or device mode, 3.2 or 4.0 SDK, everything compiles fine, no errors.
When I compile a client app that references Compton using the 3.2 or 4.0 SDK, simulator, targeting the iPhone or iPhone / iPad on 3.2, everything works great, no compile errors, and the app runs as expected in the simulator.
When I compile the exact same project changing nothing except the build settings from simulator to device, however, I get the following linking errors that I cannot seem to banish after hours of messing with #import
statements, search paths, build settings, etc. The part I'm really frustrated with is that the simulator versions are building and running fine, it seems like a tiny little config problem. I'm pasting the errors below, it looks like the Compton classes, from the perspective of building my project in device mode, can't "see" some of the three20 headers.
I'm using the trunk version of three20, pulled today.
Here is the output from the linking errors:
Ld build/NewBlankComptonTemplate.build/Debug-iphoneos/NewBlankComptonTemplate.build/Objects-normal/armv7/NewBlankComptonTemplate normal armv7
cd /Users/wiley/iphone_projects/ComptonQuizzes/NewBlankComptonTemplate
setenv IPHONEOS_DEPLOYMENT_TARGET 4.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -L/Users/wiley/iphone_projects/ComptonQuizzes/NewBlankComptonTemplate/build/Debug-iphoneos -F/Users/wiley/iphone_projects/ComptonQuizzes/NewBlankComptonTemplate/build/Debug-iphoneos -filelist /Users/wiley/iphone_projects/ComptonQuizzes/NewBlankComptonTemplate/build/NewBlankComptonTemplate.build/Debug-iphoneos/NewBlankComptonTemplate.build/Objects-normal/armv7/NewBlankComptonTemplate.LinkFileList -dead_strip -ObjC -miphoneos-version-min=4.0 -framework Foundation -framework UIKit -framework CoreGraphics -framework AudioToolbox -framework AVFoundation -framework CFNetwork -framework MediaPlayer -framework MessageUI -framework MobileCoreServices -framework QuartzCore -framework StoreKit -framework SystemConfiguration -lxml2 -lz.1.2.3 /Users/wiley/iphone_projects/ComptonQuizzes/libs/Compton/src/build/Debug-iphoneos/libCompton.a -o /Users/wiley/iphone_projects/ComptonQuizzes/NewBlankComptonTemplate/build/NewBlankComptonTemplate.build/Debug-iphoneos/NewBlankComptonTemplate.build/Objects-normal/armv7/NewBlankComptonTemplate
Undefined symbols:
"_OBJC_CLASS_$_TTStyleSheet", referenced from:
objc-class-ref-to-TTStyleSheet in AppDelegate.o
"_OBJC_CLASS_$_TTURLAction", referenced from:
objc-class-ref-to-TTURLAction in AppDelegate.o
"_OBJC_CLASS_$_TTRoundedRectangleShape", referenced from:
objc-class-ref-to-TTRoundedRectangleShape in libCompton.a(ComptonStyleSheet.o)
"_OBJC_METACLASS_$_TTDefaultStyleSheet", referenced from:
_OBJC_METACLASS_$_ComptonStyleSheet in libCompton.a(ComptonStyleSheet.o)
"_OBJC_CLASS_$_TTView", referenced from:
objc-class-ref-to-TTView in libCompton.a(ComptonQuizStartController.o)
"_OBJC_CLASS_$_TTShapeStyle", referenced from:
objc-class-ref-to-TTShapeStyle in libCompton.a(ComptonQuizStartController.o)
"_OBJC_CLASS_$_TTInnerShadowStyle", referenced from:
objc-class-ref-to-TTInnerShadowStyle in libCompton.a(ComptonQuizStartController.o)
"_OBJC_METACLASS_$_TTViewController", referenced from:
_OBJC_METACLASS_$_ComptonFeedbackController in libCompton.a(ComptonFeedbackController.o)
_OBJC_METACLASS_$_ComptonCatalogController in libCompton.a(ComptonCatalogController.o)
_OBJC_METACLASS_$_ComptonQuizStartController in libCompton.a(ComptonQuizStartController.o)
_OBJC_METACLASS_$_PILAppAdViewController in libCompton.a(PILAppAdViewController.o)
_OBJC_METACLASS_$_ComptonQuizController in libCompton.a(ComptonQuizController.o)
"_OBJC_CLASS_$_TTURLCache", referenced from:
objc-class-ref-to-TTURLCache in libCompton.a(ComptonFeedbackController.o)
"_OBJC_CLASS_$_TTSolidBorderStyle", referenced from:
objc-class-ref-to-TTSolidBorderStyle in libCompton.a(ComptonQuizStartController.o)
"_OBJC_CLASS_$_TTViewController", referenced from:
_OBJC_CLASS_$_ComptonFeedbackController in libCompton.a(ComptonFeedbackController.o)
_OBJC_CLASS_$_ComptonCatalogController in libCompton.a(ComptonCatalogController.o)
_OBJC_CLASS_$_ComptonQuizStartController in libCompton.a(ComptonQuizStartController.o)
_OBJC_CLASS_$_PILAppAdViewController in libCompton.a(PILAppAdViewController.o)
_OBJC_CLASS_$_ComptonQuizController in libCompton.a(ComptonQuizController.o)
"_OBJC_CLASS_$_TTNavigator", referenced from:
objc-class-ref-to-TTNavigator in AppDelegate.o
"_OBJC_CLASS_$_TTPostController", referenced from:
objc-class-ref-to-TTPostController in libCompton.a(ComptonFeedbackController.o)
"_OBJC_CLASS_$_TTRoundedRightArrowShape", referenced from:
objc-class-ref-to-TTRoundedRightArrowShape in libCompton.a(ComptonStyleSheet.o)
"_OBJC_CLASS_$_TTButton", referenced from:
objc-class-ref-to-TTButton in libCompton.a(ComptonFeedbackController.o)
"_OBJC_CLASS_$_TTSolidFillStyle", referenced from:
objc-class-ref-to-TTSolidFillStyle in libCompton.a(ComptonQuizStartController.o)
"_OBJC_CLASS_$_TTWebController", referenced from:
objc-class-ref-to-TTWebController in AppDelegate.o
"_TTScreenBounds", referenced from:
-[ComptonCatalogController viewDidLoad] in libCompton.a(ComptonCatalogController.o)
-[PILAppAdViewController viewDidLoad] in libCompton.a(PILAppAdViewController.o)
"_OBJC_CLASS_$_TTDefaultStyleSheet", referenced from:
_OBJC_CLASS_$_ComptonStyleSheet in libCompton.a(ComptonStyleSheet.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
Can anyone help me figure out what may be going wrong here?
Update: I've eliminated the duplicate symbol linking error by using the fork of three20 and process described here and removing the -all_load linker flag on three20 and Compton. The really crazy problem that I'm stuck on remains: I can compile and run the app fine in the simulator, but when compiling for the device, I get the above linking errors.
Update 2: I've resolved the issue, added an answer and accepted it. The problem was indeed a build config setting - if you're using the 4.0 SDK, you need to set "Architectures" to "Optimized (armv7)".
I've now resolved this issue, the answer came through on the Apple Developer Forums. If you set the base SDK to > 3.2, you need to set the "Architectures" option in Build settings to Optimized (armv7).
The code now compiles and just fine on the simulator and the device.
From what I can tell, you built libCompton while liking it directly to three20, this is going to cause nothing but hell. Linking static libraries together and trying to use that in the final project isn't going to be fun. Link three20 against your application as well, and it should resolve your issues, compton should just need the headers in order to compile, it will just require those symbols to be present at final linking in your app.