0

I have a library that used with iOS and it works with iPhone simulator and the device. When I run the file command on the library I get:

libXXX.a (for architecture armv6):  current ar archive random library
libXXX.a (for architecture i386):   current ar archive random library

Now I want to use the same library for my OSX app. I set the architecture to 32-bit i386. However I get a few compilation errors:

Undefined symbols for architecture i386:
  ".objc_class_name_RTMPClient", referenced from:
      pointer-to-literal-objc-class-name in AppDelegate.o

I'm not sure if the error is because library was originally developed for iOS (the headers all had UIKit references I had to delete but seemed extraneous as there was no UI functionality .. it was just a library for opening/connecting to RTMP servers) -- or is it a linking error? In general can you use i386 architecture libraries developed for iPhone with Mac apps?

user491880
  • 4,709
  • 4
  • 28
  • 49

1 Answers1

1

OK, you are a little confused with your terminology.

IOS:

Apps are built primarily using the Foundation and UIKit frameworks for iOS devices on the ARM architecture. i386 is the simulator, which builds against a set of private Xcode frameworks to get it to run "properly". Static libraries must be compiled against both and bundled into an "universal binary package" so they can run on both platforms.

OS X:

Apps are built in Cocoa and Appkit for the i386 architecture. However, they are not linked against those same Xcode frameworks, and so they cannot be run on an iOS device, and must be executed in the OS X environment.

To make a framework "completely device agnostic", one must compile a library for each flavor of hardware and bundle them all together.

So it is a linker error because you are including the RTMPClient file as part of the library but it is compiled for the wrong architecture, or not "universal".

CodaFi
  • 43,043
  • 8
  • 107
  • 153
  • Yes -- I guess my question is -- is there anyway to get it to work on Mac OSX? I'm guessing they compiled a version for the iOS simulator so perhaps because it is i386 I can some how make it work? – user491880 Jun 03 '12 at 07:21
  • [YES!](http://stackoverflow.com/questions/3745907/library-for-both-ios-and-os-x-apps) – CodaFi Jun 03 '12 at 21:26