Search code examples
iphonelinkeri386iphone-accessory

iphone missing required architecture i386


I am getting this error for one of my project to use a static library. The project runs well in iOS device. But not in simulator. The static library is not mine, so I cannot recompile it for i386. But this is a hardware driver, for iPhone. So when running in Simulator I really do not need this library. Its like if the Accessory is present with the device then the app will have a different flow.

So I have to keep the reference to this file. But will only need in iOS device. Not needed when running in the simulator to run the app for UI and other testing purpose.

How can I avoid this error? Is there anyway to configure the target or scheme to avoid the object file/lib when running in simulator?

ld: warning: ignoring file 
/Framework/iSmartSDK/libiSmartSDK_Lib.a, missing required architecture i386 in file  
/Framework/iSmartSDK/libiSmartSDK_Lib.a (2 slices)
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_iSmart", referenced from:
      objc-class-ref in SmartCardReaderVC.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution

  • when you use it, the symbol IS referenced and the lib required. if you really dont need the the functionality, wrap its usage in a define. 'define it out':

    #if TARGET_OS_IPHONE
       iSmart *smart = ....
    #else
       NSLog(@"no ismart on mac");
    #endif
    

    NOTE: It's not enough to not assign/call a symbol. dont even use the symbol for declaring a variable**


    It might only be in the 1 file AFAICS .. #ifdef the whole file and maybe create a SmartReaderVC stub