2016-11-09 68 views
1

我最近在应用程序中设置了SiriKit目标,但我无法引用其中的任何应用程序代码。如何引用应用程序代码形成SiriIntent扩展?

我已经加入我的应用程序的目标为诗丽吉目标构建Targets->目标相关部分,但我仍然得到以下错误:

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 +单击将我带到适当的类,等等,所以它显然在某个时刻找到类,而不是最重要的地方!

我的代码是这样的:

#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 

回答

0

这里的类Helper.swift可以从我的应用程序扩展访问。按照以下步骤操作

1.

enter image description here

  • 围棋在Xcode的右手侧到文件检查员。
  • enter image description here

  • 我的扩展代码。
  • enter image description here

    注:在OBJ-C,你需要做上面的.h和.m文件的步骤。

    +0

    推测这意味着Helper.swift文件使用的任何依赖项也必须包含在SiriKitDemoExtension目标中,对吧?不包括SiriKitDemo作为目标依赖项包括该目标中包含的所有文件? – Zach

    +0

    是的,我们需要将Helper.swift的依赖文件添加到sirikitDemoExtension目标中,否则会引发错误。 –

    相关问题