我最近在我的应用程序中设置了一个 SiriKit 目标,但我无法在其中引用任何应用程序代码。
我已将我的应用程序的目标添加到 SiriKit 目标的 Build Targets->Target Dependencies 部分,但我仍然收到以下错误:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_<CLASSNAME>", referenced from:
objc-class-ref in IntentHandler.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我试图在 IntentHandler.m 类中引用的应用程序类的名称在哪里。
我可以导入我需要使用的应用程序代码类,但如果我尝试在实际代码中使用它会导致错误。
代码的一切“似乎”都很好,这很奇怪。语法突出显示有效,ctrl+click 将我带到适当的类,等等,所以很明显在某些时候找到了类,而不是最重要的地方!
我的代码是这样的:
#import "IntentHandler.h"
#import "<CLASSNAME.h>
@interface IntentHandler () <INSearchForPhotosIntentHandling>
@end
@implementation IntentHandler
- (id)handlerForIntent:(INIntent *)intent {
return self;
}
#pragma mark - INSearchForPhotosIntentHandling
- (void)handleSearchForPhotos:(INSearchForPhotosIntent *)intent completion:(void (^)(INSearchForPhotosIntentResponse *response))completion {
NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSStringFromClass([INSearchForPhotosIntent class])];
Object test = [[<CLASSNAME> instance] getObjectWithName:@"test"];
// do stuff with the test Object, which may require me to send the response as INSearchForPhotosIntentResponseCodeFailureRequiringAppLaunch
// but for now just return INSearchForPhotosIntentResponseCodeContinueInApp.
INSearchForPhotosIntentResponse *response = [[INSearchForPhotosIntentResponse alloc] initWithCode:INSearchForPhotosIntentResponseCodeContinueInApp userActivity:userActivity];
completion(response);
}
@end