iOS 4 app crashes at startup on iOS 3.1.3: Symbol not found: __NSConcreteStackBlock - iphone

I'm running Xcode 3.2.3 with the iOS 4.0 SDK. I built my app with Base SDK = iphoneos4.0, Active SDK = iphoneos4.0, Deployment Target = 3.1.3, and Architecture = standard (arm6 arm7). Compiler = GCC 4.2. As I understand it, this is the correct way to build an app for both iOS 4 and 3.
The app runs fine on devices running iOS 4. But it crashes on startup when you try to run it on a device with iOS 3.1.3 (an iPod Touch 1G):
dyld: Symbol not found: __NSConcreteStackBlock
Referenced from: /var/mobile/Applications/192B30ED-16AC-431E-B0E9-67C1F41FD5DA/MyApp.app/MyApp
Expected in: /usr/lib/libSystem.B.dylib
It appears to be an issue with a fairly "low level" dynamically-linked library, BEFORE my main() function even gets called. I have even tried re-starting the device, etc., with no luck. Here's part of the the crash log:
Process: MyApp [60]
Path: /var/mobile/Applications/192B30ED-16AC-431E-B0E9-67C1F41FD5DA/MyApp.app/MyApp
Identifier: MyApp
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2010-07-22 17:16:17.942 -0400
OS Version: iPhone OS 3.1.3 (7E18)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000001, 0xe7ffdefe
Crashed Thread: 0
Dyld Error Message:
Symbol not found: __NSConcreteStackBlock
Referenced from: /var/mobile/Applications/192B30ED-16AC-431E-B0E9-67C1F41FD5DA/MyApp.app/MyApp
Expected in: /usr/lib/libSystem.B.dylib
Dyld Version: 149
Binary Images:
0x1000 - 0x80fff +MyApp armv6 <d5f0ff6f233b4b034c222c16438c88d9> /var/mobile/Applications/192B30ED-16AC-431E-B0E9-67C1F41FD5DA/MyApp.app/MyApp
0x2fe00000 - 0x2fe26fff dyld armv6 <544395a4b5546114b878d5131a84fd7f> /usr/lib/dyld
0x30410000 - 0x30536fff libSystem.B.dylib armv6 <0373fd64e915a17160732b29d343f95f> /usr/lib/libSystem.B.dylib
Thanks for any advice!

Ben Gottlieb pointed out yesterday that if you use blocks anywhere in your application, you'll see a crash similar to this on a pre-4.0 OS while building with the LLVM compiler. To work around this, you can specify the linker flag -weak-lSystem in your Xcode build settings.

Since most of these answers are specific to Xcode 3.x, just wanted to share what I did to fix this with Xcode 4.2.
Under your target in the "Build Phases" tab in the "Link Binary With Libraries" section I added "libSystem.dylib" and made it optional. This fixed the issue iOS 3.x devices while maintaining support for iOS 4.x and 5.0 devices.

If you happen to be using the cocos2d libraries, there is a cleaner way to do this, you should configure the cocos2d target's Deployment target to 3.0

Related

Armv7 + Arm64 fat build is incompatible with iPhone 4s

My Unified API Xamarin app can be built in both Armv7 and Armv7+Arm64 thin and fat build architectures.
When I build it in Armv7 architecture I can deploy and run it on an iPhone4s. When I build it in Armv7+Arm64 architecture(s) I can deploy and run it on iPhone5 and above.
Why can't I deploy Armv7+Arm64 build to iPhone 4s?
This is the error I get:
Installing application bundle
writeDictToFile:1258 ==== Successfully wrote Manifest cache to /var/folders/9y/yvyksjvd38g_gnkndcw4y_100000gn/T/Xamarin.iOS_InstallShadowPath/d2d4e62f663137bab4687ec28f35467b/aead04c30517c7b5a662da00c34e58e38ac78222/ManifestCache.plist
error MT1006: Could not install the application '/Users/noammeirofek/RoX/bin/RumbleTouch.app' on the device Adi’s iPhone: AMDeviceSecureInstallApplicationBundle returned: 0xe8000087 (kAMDIncorrectArchitectureError).
The application was terminated by a signal: SIGHUP
I got the same error (which led me to your question), but under different circumstances - so I'm sorry but I cannot explain why ARMv7+ARM64 did not work for you when just ARMv7 did.
Are you sure you were deploying to an iPhone4s and not an iPhone5?
I am deploying to an iPad 3 and my architecture settings were ARMv7s + ARM64. I got the same error in your writeup. When I chose instead ARMv7 + ARM64, the app deployed.
Per Xamarin Studio (options, iOS Build, Advanced):
ARMv7s is the latest architecture supported only by the new A6 processor included in the iPhone5
You might want to choose ARMv7 + ARMv7s + ARM64 in the dropdown option called Supported architectureson the Advanced tab
According to this list of iOS devices, your original selection should have worked, because the iPhone4s has an ARMv7
I experimented with my app on an iPhone4 (I don't have an iPhone4s) and the deploy worked with ARMv7+ARM64 (your original setting), and did not work for ARMv7s+ARM64 (as expected) and did work with the all-inclusive ARMv7+ARMv7s+ARM64
I am also using a Unified 64bit API, Xamarin Studio, XCode 7 and my iPad has iOS 9.0 installed.

Can't debug on iOS 4.x devices

Whenever I try to debug on devices with iOS 4.x (iPhone 4 and 3GS) I get the following error:
error: failed to launch '/XXX/Library/Developer/Xcode/DerivedData/XXX-fytptbaixvmoweacfsniqxtvjkst/Build/Products/Debug-iphoneos/XXX.app/XXX'
-- Bad CPU type in executable
On devices with iOS 5.x it works.
I am using xCode 4.3.3 and my configurations are:
Architectures: Standard (armv7) (also tried armv6,armv7 to no avail)
Base SDK: Latest iOS (iOS 5.1)
Valid Architectures: armv6, armv7
Deployment Target: iOS 4.0
What do you think?
In your Xcode preferences, go to downloads tab and install "iOS 4.0 - 4.1 Device Debugging Support".
This package includes information and symbols that Xcode needs for
debugging your app on iOS devices running versions of iOS prior to iOS
4.2. If you intend to debug your app on a device running one of these versions of iOS you should install this package.

Can't deploy to iPhone(1st Generation) after updating from Xcode 4.1 to 4.2.1

After updating from 4.1 to 4.2.1, I was not able to deploy to my 1st generation iPhone. I received a message that a debugger for version 3.0 - 3.2 needs to be downloaded. I downloaded it.
After downloading the debugger, now Xcode displays the messages:
"Build succeeded" and "Finished running....".
But the application doesn't even launch!
There haven't been any code changes.
The only other change is that Xcode suggested I update the build settings to use the llvm 3.0 compiler (all I did was click OK).
Now It won't deploy to my first gen iPhone.! :C
It seems to deploy to my 4th generation iPod touch (iOS 5.01 (9A405)) without problem though.
Is there some kind of code change or setting change I need to make?
The last version of Xcode where I could deploy was 4.1 . After that I updated to 4.2.1
EDIT: I followed rckoenes advice below, and I added armv6 & armv7 to the architectures (and removed the variable that was already there). Now the application launches on my device, but almost immediately into the launch, the following error appears :
dyld: Symbol not found: __NSConcreteStackBlock
Referenced from: /var/mobile/Applications/921C1E7F-449D-4EA1-AEAA-70A1AF60C351/ProjectX.app/ProjectX
Expected in: /usr/lib/libSystem.B.dylib
I have tried the following:
under "Build Phases" for the targets, I have added libSystem.B.dylib under "Link Binary With Libraries".
But the error message still appears.
EDIT: Marking the library as optional in "Link Binary With Libraries" makes the error go away".
You probably need to add the armv6 to you Architectures list: http://triplesoftware.nl/2011/12/running-ios-5-build-apps-on-the-orignal-iphone-ipod-touch-and-iphone-3g/

Malformed metadata record for architecture i386

I just upgraded from Xcode 4 to Xcode 4.2 and now I'm getting the following error when building for the Simulator:
ld: in /Users/rstaicut/Library/Developer/Xcode/DerivedData/iphone/Build/Intermediates/iphone.build/QA Server-iphonesimulator/Project iPhone Debug.build/Objects-normal/i386/CartController.o, could not parse object file
/Users/rstaicut/Library/Developer/Xcode/DerivedData/iphone/Build/Intermediates/iphone.build/QA Server-iphonesimulator/Project iPhone Debug.build/Objects-normal/i386/CartController.o:
**Malformed metadata record for architecture i386**
**Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1**
One thing to note is that I've changed the compiler to LLVM GCC 4.2 for this upgrade and I'm using armv6 and armv7 for the architectures. I'm only getting this error for the Simulator, the build finishes for the device.
Any ideas what malformed metadata record could mean?
Got the simulator to finally work. These are the things I changed:
Under Project > Build Settings > Architectures > Valid Architectures I took out i386 and left only armv6 and armv7. Under architectures I only have armv6 and armv7
I changed the Compiler from LLVM GCC 4.2 to Apple LLVM compiler 3.0 (Under Project > Build Settings > Build Options > Compiler for C/C++/Objective-C
Changed the iOS Deployment target from iOS 3.1 to iOS 4.0
The last step was to press on "Validate settings" (the button in the middle on the bottom). It's going to ask you to change some settings for the compiler from LLVM GCC to Apple LLVM Compiler 3.0. Hit OK.
My simulator started magically working after that. No errors, though plenty of warnings due to the change in compiler.
Hope this helps anyone else who runs into this issue.

app not launching on iPhone (iOS 5)

Just installed and app on my iPod touch using a developer provisioning profile. The app works fine some time but after some time it fails to start on iPod (iOS 5) touch, just tries to launch but in half way through closes .... even the splash is also not visible.
I checked the crash log from device says something like this.
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000001, 0xe7ffdefe
Crashed Thread: 0
Dyld Error Message:
Library not loaded: /Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit
Referenced from: /var/mobile/Applications/DBC8A071-F305-4095-8FF5-76DDC99DDDEE/ApplicationName.app/ApplicationName
Reason: image not found
Dyld Version: 199.5
Binary Images:
0x1000 - 0x72fff +ApplicationName armv7 <1f10c6b4168c3503908fead68d17ddb5> /var/mobile/Applications/DBC8A071-F305-4095-8FF5-76DDC99DDDEE/ApplicationName.app/ApplicationName
0x2fe79000 - 0x2fe9afff dyld armv7 /usr/lib/dyld
From log it seems like its failing to load the SenTestingKit library but how it works for some time????
And if I remove this framework what should be the alternative for iOS 5.
Please shed some light on this rather strange issue.
You should only be linking to SenTesting in your Testing target.
First:
Try to delete the derived Data, then clean the project and restart Xcode. If its still not working, check the Target dependencies of your library.
Second: Try to mark the SenTestingKit as "optional".
There are some problems with loading libraries in iOS 5, so just try to clean the project in xCode 4 and build it again. That maybe help you, because after a cleaning all paths will be set up for new.