1

我知道这意味着第三方组件不会在模拟器上运行:Xcode的生成错误 - 缺少必需的i386硬件架构

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

您可以使用这一框架条件编译代码:

#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. 
} 
+0

我喜欢第二个选择更好,但我不得不使用第一个,因为我不知道如何使用第二行这一行:@interface MyViewController() soleil

相关问题