Ich konnte keine Antwort auf Google finden. Ich baue ein Befehlszeilendienstprogramm in Cocoa und wenn ich versuche, eine Instanz von NSWorkspace
zu erstellen, erhalte ich einen Compilerfehler. Dies ist der Code, den ich in main.m
bin der Umsetzung, das ist ziemlich einfach:Wie kann ich NSWorkspace in meinem Befehlszeilenprogramm arbeiten lassen?
NSArray *runningApps = [[NSWorkspace sharedWorkspace] runningApplications];
for (NSRunningApplication *app in runningApps) {
if (![app terminate])
[app forceTerminate];
}
Wenn ich versuche, das Programm zu kompilieren und führen Sie dieses ist, was ich bekommen:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_NSWorkspace", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ich verwendet habe, das gleiche Code in anderen Apps und hatte kein Problem. Ich weiß, NSWorkspace
ist in <Foundation/Foundation.h>
definiert und ich habe <Cocoa/Cocoa.h>
importiert, die Foundation umfasst. Irgendwelche Ideen, was das Problem sein könnte?
Danke das war genau das Problem. – sud0
Ich habe weder das Cocoa.framework noch das AppKit.framework zum Hinzufügen gefunden. Irgendwelche obwohl? – Tony