ioslinkerlayar

Missing symbols from LayarSDK in the simulator


I'm including the Layar SDK framework into my app (version 8.0) and everything works fine on a device.

However, I can't run the app on a simulator anymore - I don't mind Layar not working (there's no camera after all!) but I do need it to compile for continual integration, automated tests etc (not to mention developing on the train top/from work!)

The linker gives me these errors :

ld: warning: ignoring file /Users/username/Documents/appname/libs/MPOAuth/libMPOAuthMobile.a, missing required architecture i386 in file /Users/username/Documents/appname/libs/MPOAuth/libMPOAuthMobile.a (2 slices)
ld: warning: ignoring file local/LayarSDK/LayarSDK.framework/LayarSDK, missing required architecture i386 in file local/LayarSDK/LayarSDK.framework/LayarSDK (2 slices)
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_LayarSDK", referenced from:
    objc-class-ref in MYAppDelegate.o
ld: symbol(s) not found for architecture i386

Checking, the LayarSDK doesn't contain i386, it only contains armv7 and armv7s.


Solution

  • My solution is pretty clumsy - if anyone has a better idea, please let me know!

    I compile this file (LayarSimulatorStub.m) into my app :

    #if TARGET_IPHONE_SIMULATOR
    
    #import <Foundation/Foundation.h>
    
    @interface LayarSDK : NSObject
    
    @end
    
    @implementation LayarSDK
    
    + (id)layarSDKWithConsumerKey:(id)a andConsumerSecret:(id)b andDelegate:(id)c { return nil; }
    - (id)init { return nil; }
    - (id)initWithConsumerKey:(id)a andConsumerSecret:(id)b andDelegate:(id)c { return nil; }
    
    @end
    
    #endif
    

    Now, there is an i386 symbol LayarSDK. It just returns nil from all it's constructors. The app now compiles with Layar disabled.

    The conditional compilation means that it's not present for the device architectures so there are no linker errors.