Safari
Safari

Reputation: 11935

iOS Static Library Xcode (linking errors)

I created a static library with Xcode I have compiled selecting a device.

I added this to my library test project in Xcode 4.6

but I always have 2 errors during the linking...

I followed this tutorial: Static Library iOS Tutorial

if I download the sample code I have the same errors:

ld: warning: ignoring file /Users/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a, missing required architecture i386 in file /Users/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a (2 slices) Undefined symbols for architecture i386: "_OBJC_CLASS_$_MathFunctions", referenced from: objc-class-ref in MathTestAppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Upvotes: 1

Views: 7237

Answers (4)

neeraj
neeraj

Reputation: 1221

You must have selected iOS simulator while building the project. Select iOS device and it should be fine.

Upvotes: 1

Safari
Safari

Reputation: 11935

I followed this step by step tutorial:

Tutorial

in particular I had to add these flags: -ObjC and -all_load

Upvotes: 1

Subbu
Subbu

Reputation: 2101

I had once made a static lirary , I had the same problem . Solution was to "Run the app on device " not on simulator , it works fine then !!! Hope this helps...

Upvotes: 1

user529758
user529758

Reputation:

Do read and try to understand the error message, it's a meaningful English phrase.

symbol(s) not found for architecture i386

So there's no compiled code for the i386 architecture in the library. This means that either it's compiled for ARM only (for actual iOS devices, like iPhone or iPad), or for the 64-bit simulator (x86_64). Use otool to find out the architectures present in the library.

Upvotes: 0

Related Questions