1

要将 ScriptingBridge 与 iTunes 一起使用,我使用了:

iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];

但是,当我运行应用程序时,(我已经将错误的来源追溯到上面的行),我得到一个构建失败,并且这些错误:

Apple Mach-O Linker (Id) Error
"_OBJC_CLASS_$_SBApplication", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64

Apple Mach-O Linker (Id) Error
Linker command failed with exit code 1 (use -v to see invocation)

我该如何解决这个问题?我从 Apple Developer Scripting Bridge 编程指南中复制并粘贴了该行,所以我无法想象它会导致问题。

4

2 回答 2

4

像这样的链接器错误表明您根本没有添加 ScriptingBridge.framework 作为链接到您的产品的框架。

于 2014-12-03T23:13:24.967 回答
-1

由于 SpringBoard 不是一个框架,并且您在编译时无法链接到它,因此您必须在运行时访问该类。我推荐的方法是这样的:

#import <objc/runtime.h>
SBApplication* iTunes = [objc_getClass("SBApplication") applicationWithBundleIdentifier:@"com.apple.iTunes"];
于 2012-03-30T00:58:29.060 回答