Xcode构建错误 - 缺少必需的架构i386

时间:2013-07-29 19:33:07

标签: ios xcode compiler-construction ios-simulator static-libraries

我知道这意味着第三方组件无法在模拟器上运行:

ld: warning: ignoring file /MyApp/SomeComponent.include/SomeComponent.framework/SomeComponent, missing required architecture i386 in file /MyApp/SomeComponent.include/SomeComponent.framework/SomeComponent (2 slices)
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_SomeComponent", referenced from:
      objc-class-ref in MyViewController.o
ld: symbol(s) not found for architecture i386

但是,我不想被排除在模拟器上再次运行应用程序。只有在按下应用程序某个部分的按钮时才需要第三方组件。我仍然希望能够在模拟器中运行应用程序的其余部分。

如果我在模拟器中运行,如何让编译器忽略它?

1 个答案:

答案 0 :(得分:1)

您可以使用该框架有条件地编译代码:

 #if !TARGET_IPHONE_SIMULATOR
 // Code using "SomeComponent" that should be compiled for iOS device only ...
 #endif

或者,您可以与框架“弱链接”(如中所述) "Using Weakly Linked Classes in iOS"并检查可用性 在运行时的类:

if ([SomeComponent class]) {
    // Create an instance of the class and use it.
} else {
    // Alternate code path to follow when the
    // class is not available.
}