ofxiPhone touch and accel example not compiling


I am trying to make the Touch and Accel example work in XCode 3 and 4 in Snow Leopard. I am getting the same error on compile:

Command /Applications/XCode3/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

I have redownloaded oF 7 with iPhone several times. I cannot get the thing to work at all.

Any help will be greatly appreciated.

Just a few questions to try & help: there’s no other error log at all? And just to make sure: you can compile all the other example without a problem? Usually GCC spits out a little more information about what’s going on before exiting, so I’m surprised that it’s just quitting. Also, are you running into emulator or loading it onto a device?


Thanks. Today, after some sleep I redownloaded the oF_iphone version, unzipped, copy/pasted the accel example. The thing compiled for simulator with 963 warnings. When I tried to throw it in my iPhone 3G (OS 3.1.3) I got a crash (replaced the uber-long path with path_to and omitted 411 warnings):

CodeSign build/Debug-iphoneos/TouchAndAccelExample.app  
cd /path_to/xcode/of_preRelease_v007_iphone/apps/mga/TouchAndAccelExample  
setenv PATH "/Applications/XCode3/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/XCode3/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"  
setenv _CODESIGN_ALLOCATE_ /Applications/XCode3/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate  
/usr/bin/codesign -f -s "iPhone Developer: Mauricio Giraldo (HVJ85G6YW3)" --resource-rules=/path_to/xcode/of_preRelease_v007_iphone/apps/mga/TouchAndAccelExample/build/Debug-iphoneos/TouchAndAccelExample.app/ResourceRules.plist --entitlements /path_to/xcode/of_preRelease_v007_iphone/apps/mga/TouchAndAccelExample/build/TouchAndAccelExample.build/Debug-iphoneos/TouchAndAccelExample.build/TouchAndAccelExample.xcent /path_to/xcode/of_preRelease_v007_iphone/apps/mga/TouchAndAccelExample/build/Debug-iphoneos/TouchAndAccelExample.app  
/path_to/xcode/of_preRelease_v007_iphone/apps/mga/TouchAndAccelExample/build/Debug-iphoneos/TouchAndAccelExample.app: object file format invalid or unsuitable  
Command /usr/bin/codesign failed with exit code 1  

Thanks for the help!

I’m not a super-savvy iPhone developer but that’s to do with your developer identity. Check the CODE_SIGN_IDENTITY property in your build settings. Is your provisioning profile selected there? This technote explains a little bit more http://developer.apple.com/library/ios/#technotes/tn2242/-index.html

By default the OF download has the developer identity set to “iphone dev”, which isn’t going to work if you don’t have an identity by that name. I’ve only done iPhone dev for jailbroken devices so I don’t really know the “right” way to do that, but I’m guessing there’s tons of info on how to generate an identity that can be used.

Thanks. Will look into that. I have only done iOS dev the “right” way, using the standard XCode workflow and using plain old Objective-C. I changed the code signing ID to the one I use with Apple. I want to try oF and Box2D but I a ripping my hair off. What about the 411 warnings? Should I worry about that? Things like:

arm-apple-darwin10-gcc-4.2.1: -lpthread: linker input file unused because linking not done  

Those can be ignored. They do need to get cleaned up but they’re not going to affect your application at all, other than increasing the compile time a little bit.

Thanks. I have:

  • created a new app id in the apple site
  • redownloaded the provisioning profile
  • erased all profiles in the phone
  • added the new profile
  • changed the code sign id in the project and in the target

No cigar. I even went over to XCode 4 to see if it worked there. It doesn’t crash but it doesn’t do anything on the phone either. I get a “Finished running App on Phone” in the status window (the thing that looks like the iTunes playing window).

I think that the problem might be related to this:


The funny thing is, since XCode modifies the project file just by using it, it does not compile on XCode 3 any more.

What would you recommend me do? I just need to use Box2D so I guess I could just somehow add that to a plain vanilla XCode-created iOS app. Any ideas on that?

Sorry, but since it’s not gcc that’s bombing out any more, I’m totally stumped. You haven’t changed anything in either of the projects you’re trying to run? Maybe something in here helps? http://stackoverflow.com/questions/8052925/xcode-4-2-ios5-codesign-failed-with-exit-code-1

Thanks. Gonna try “normal”. All these permission thing are a bit insane. I am giving another try to this and copied the empty example to try and isolate the fact that my iPhone is OS 3.1.3. When I try to send this app to the phone I get:

Ld build/emptyExample.build/Debug-iphoneos/emptyExample.build/Objects-normal/armv6/emptyExample normal armv6  
cd /Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/apps/mga/emptyExample  
setenv PATH "/Applications/XCode3/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/XCode3/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"  
/Applications/XCode3/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 -arch armv6 -isysroot /Applications/XCode3/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/apps/mga/emptyExample/build/Debug-iphoneos -F/Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/apps/mga/emptyExample/build/Debug-iphoneos -filelist /Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/apps/mga/emptyExample/build/emptyExample.build/Debug-iphoneos/emptyExample.build/Objects-normal/armv6/emptyExample.LinkFileList -dead_strip -ObjC ../../../libs/freetype/lib/iphone/freetype.a ../../../libs/FreeImage/lib/osx/freeimage.a ../../../libs/FreeImage/lib/iphone/freeimage.a ../../../libs/glew/lib/osx/glew.a ../../../libs/cairo/lib/osx/cairo.a ../../../libs/poco/lib/iphone/PocoFoundation.a ../../../libs/poco/lib/iphone/PocoNet.a ../../../libs/poco/lib/iphone/PocoXML.a ../../../libs/poco/lib/iphone/PocoUtil.a ../../../libs/tess2/lib/iphone/tess2.a ../../../libs/glu/lib/iphone/glu.a ../../../libs/glu/lib/iphone/glu-iphone.a -miphoneos-version-min=3.1 /Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/libs/openFrameworksCompiled/lib/iphone/libofxiPhone_iphoneos_Debug.a -framework Foundation -framework UIKit -framework CoreGraphics -framework OpenGLES -framework QuartzCore -framework AudioToolbox -framework OpenAL -framework CoreLocation -framework CoreGraphics -framework AVFoundation -framework CoreMedia -framework CoreVideo -framework MapKit -o /Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/apps/mga/emptyExample/build/emptyExample.build/Debug-iphoneos/emptyExample.build/Objects-normal/armv6/emptyExample  
ld: warning: ignoring file ../../../libs/FreeImage/lib/osx/freeimage.a, missing required architecture armv6 in file  
ld: warning: ignoring file ../../../libs/glew/lib/osx/glew.a, file was built for archive which is not the architecture being linked (armv6)  
ld: warning: ignoring file ../../../libs/cairo/lib/osx/cairo.a, file was built for archive which is not the architecture being linked (armv6)  
ld: warning: ignoring file ../../../libs/glu/lib/iphone/glu.a, file was built for archive which is not the architecture being linked (armv6)  
ld: warning: ignoring file /Users/mga/Desktop/stuff/xcode/of_preRelease_v007_iphone/libs/openFrameworksCompiled/lib/iphone/libofxiPhone_iphoneos_Debug.a, file was built for archive which is not the architecture being linked (armv6)  
Undefined symbols for architecture armv6:  
  "ofBackground(int, int, int, int)", referenced from:  
      testApp::setup()     in testApp.o  
  "_ofxAccelerometer", referenced from:  
      testApp::setup()     in testApp.o  
  "ofSetupOpenGL(int, int, int)", referenced from:  
      _main in main.o  
  "_ofxiPhoneAlerts", referenced from:  
      testApp::setup()     in testApp.o  
  "ofRunApp(ofBaseApp*)", referenced from:  
      _main in main.o  
  "ofxAccelerometerHandler::setup()", referenced from:  
      testApp::setup()     in testApp.o  
  "_ofEvents", referenced from:  
      void ofRegisterTouchEvents<testApp>(testApp*)in testApp.o  
ld: symbol(s) not found for architecture armv6  
collect2: ld returned 1 exit status  

It is ignoring some classes due to it not having armv7 but then crashes with ofBackground.

Aaaaaaaaaa I think I found the solution!


The answer includes doing what I mention above and found in this link:


But I only did this part since there was no file to rename:

sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin  

My solution also had to do with this an .xcodeproj file damage (wtf?):


I hope this now paves the way for me to work in the iPhone using oF!

Glad you got that sorted out. Hopefully everything goes smoothly for you from here on out.

I have no idea how codesign could get corrupted, but hopefully if someone else runs into the same problem they’ll find this.

Ok I managed to produce an empty example in the iPhone 3G. Now I am trying to make the Touch+Accel example work there too.

So far I have done this:

I am getting a non-crashing (the app is still open but stuck in the OF logo view) error:

warning: Unable to read symbols for /Library/MobileSubstrate/MobileSubstrate.dylib (file not found).  
warning: Unable to read symbols for /Library/MobileSubstrate/MobileLoader.dylib (file not found).  
2011-12-27 00:31:35.407 Maraca[4262:207] MS:Notice: Installing: com.company.app [example] (478.52)  
dyld: lazy symbol binding failed: Symbol not found: ___sync_fetch_and_add_4  
  Referenced from: /var/mobile/Applications/E46CA3BE-26C0-44F2-A124-7821287F8EB4/example.app/example  
  Expected in: /usr/lib/libSystem.B.dylib  
dyld: Symbol not found: ___sync_fetch_and_add_4  
  Referenced from: /var/mobile/Applications/E46CA3BE-26C0-44F2-A124-7821287F8EB4/example.app/example  
  Expected in: /usr/lib/libSystem.B.dylib  
Previous frame inner to this frame (gdb could not unwind past this frame)  

Any ideas?

I really want this to work in my iPhone 3G since 1) I can’t upgrade it to 4+ and have it be remotely usable, 2) I can’t upgrade because I fear I can lose connectivity since I am on T-Mobile in the US (long story), 3) it should work in this phone since I only want to use the accelerometer and some audio/touch and 4) I can’t buy a new phone right now.

Thanks for the help!