Linker flags for iOS with Xcode

Where can I find documentation on compiler flags and linker flags that we can specify for our iOS projects in Xcode?

The real reason I want to learn more about possible flags is primarily because the Google Admob SDK says we MUST set the linker flag to -Objc, while the Facebook SDK suggests NOT setting it for small binary files. So, I was wondering if we can install Objc for a specific library (in this case google admob) and not configure it for another library (facebook)? I expected to find a man page or some other document about which compiler and linker options in the first place, and then zoom in on the Objc object. There are tons of documentation and stackoverflow messages, etc. How to set linker flags in Xcode. What is the list of possible linker flags that we can set, and what they mean each.

Surprisingly, the googling around me was embarrassing, since it was there on clang, llvm, llvm-gcc, etc., and the LLVM website lists several llvm commands, but I don’t see -Objc listed on any of the corresponding pages. Besides the question of whether the compiler and linker are clang or llvm, or what they are called, is there a place we could go to read the documentation about which Xcode is used by default to compile and link iOS projects? (say, both Xcode 4.6 and Xcode 5.0.2, if there are different sets of documents?) Thank you!

+8
ios objective-c linker xcode llvm
source share
2 answers

You can try man 1 ld . For the -ObjC flag, in particular, the description:

-ObjC Loads all the elements of static archive libraries that implement the Objective-C class or category.

EDIT

For your other question about the AdMob SDK and the SDK for Facebook, I would suggest adding -ObjC to the linker flags and see this , which explains why. Basically, Facebook suggests not using it because your executable will be larger due to additional object code loaded into your binary.

+10
source share

I had this problem when I put a function in my .hpp file.

 void logError(char const* szError) { ... } 

I had to add an inline string to make it work.

 inline void logError(char const* szError) { ... } 

Even better, do not define your functions inside your headers.

0
source share

All Articles