views:

888

answers:

2

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!

+1  A: 

Are you using blocks for anything? Try converting the block to a regular method.

John Franklin
Pardon the ignorance, but what are blocks? Perhaps one of the open-source libraries I'm using *does* use them... How can I search for that?
Clint Harris
+9  A: 

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_library /usr/lib/libSystem.B.dylib in your Xcode build settings.

Brad Larson
Ah, thanks Brad! I was just coming back to share the same solution (after some trial and error)... For anyone else who might come across this and need help setting up the weak link, here's a screenshot: http://img.skitch.com/20100722-f65bkarx79gk8nye52ji834cbn.pngAlso, note that it doesn't seem to be specific to the LLVM compiler--I'm just using GCC 4.2.
Clint Harris
@Clint Harris - I think for the LLVM compiler you still need to force the weak-linking using the compiler flag, because it doesn't respect the setting within Xcode's project window there.
Brad Larson
What does "block" mean in this context? Block to me means a block of code, which I suppose is hardly what you mean here.This solution did fix it for me too btw. Thanks a lot!
quano
@quano - A block is a new C language construct introduced in Snow Leopard and iOS 4.0. See here for a good introduction to them: http://developer.apple.com/iphone/library/featuredarticles/Short_Practical_Guide_Blocks/index.html
Brad Larson
Odd, I'm not using any of those, and all my libraries I'm using are working with iPhone OS 3, so I don't understand why it would require me to specify linker flags for things I'm not even using. Oh well, I'm just happy it works. Thanks again.
quano