views:

1217

answers:

1

I can't find anywhere what the -all_load flag do when compiling Objective-C code.

I have some issues uploading binaries to Apple, the they say it's because I didn't use this flag, but my code compiles even without it.

Can some one help me with that?

Thanks

+6  A: 

It is probably related to this technical note http://developer.apple.com/mac/library/qa/qa2006/qa1490.html

IMPORTANT: For 64-bit and iPhone OS applications, there is a linker bug that prevents -ObjC from loading objects files from static libraries that contain only categories and no classes. The workaround is to use the -all_load or -force_load flags. -all_load forces the linker to load all object files from every archive it sees, even those without Objective-C code. -force_load is available in Xcode 3.2 and later. It allows finer grain control of archive loading. Each -force_load option must be followed by a path to an archive, and every object file in that archive will be loaded.

Shaji
Yes, this primarily comes into play with static libraries for the iPhone. If they are compiled without this linker flag, the categories are not included in the built binary and any application using these static libraries will have runtime errors when executed on iPhone OS hardware.
Brad Larson
shouldn't there be some warnings or errors of the missing method at compile time?
Guy Ephraim
No, because the categories exist at compile-time, they're just not being linked into the final binary. But because of the dynamic nature of Obj-C dispatches, the linker doesn't point calling code directly to the implementing method, so it never notices that it's missing. Then at runtime, you get the kaboom, the same as if you'd called it using "-performSelector:"
Sophistifunk