Dan*_*ark 7 ios coremidi ios-simulator
要让MIDI通过蓝牙工作,我需要使用CoreAudioKit框架.这很好用,但我无法在模拟器上编译.
ld: framework not found CoreAudioKit我认为它应该根据文档工作
我在代码中有这个,这就是我可以删除框架而没有问题的原因.
#if !TARGET_IPHONE_SIMULATOR
#import <CoreAudioKit/CoreAudioKit.h>
#endif
Run Code Online (Sandbox Code Playgroud)
我实际上会认为这会起作用,但我认为你可以用另一种方式解决它.这对我有用:
删除目标设置中对CoreAudioKit的所有引用构建阶段(使用库链接二进制文件)
确保手动输入的类似设置没有.例如,不要添加此设置:-weak_framework CoreAudioKit在其他链接器标志中
使用预处理程序标志有条件地编译模拟器的代码:
#import "ViewController.h"
#if !TARGET_IPHONE_SIMULATOR
@import CoreAudioKit;
#endif
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
#if !TARGET_IPHONE_SIMULATOR
if ([CABTMIDICentralViewController class]) { // maybe not needed?
CABTMIDICentralViewController *vc = [[CABTMIDICentralViewController alloc] init];
}
#endif
}
Run Code Online (Sandbox Code Playgroud)
注:上面我的例子,你可能并不需要以测试是否存在CABTMIDICentralViewController类.这取决于您的应用仅针对iOS 8+还是iOS 7.
根据@Yar和@JeremyHuddlestonSequoia的评论,请注意此解决方案要求您在项目构建设置中自动启用模块和链接框架.现在,这些Xcode设置默认为此技术的正确值,但如果您正在管理较旧的项目,请确保它们已启用.