2

I have setup a SiriKit target within my application recently, but I cannot reference any app code within it.

I have added my app's target to the SiriKit target's Build Targets->Target Dependencies section, but I still get the following errors:

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)

Where is the name of a app class I am trying to reference in the IntentHandler.m class.

I am able to import the app code class I need to use just fine, but if I try to use it in actual code it results in the error.

Everything "seems" fine with the code too, which is odd. Syntax highlighting works, ctrl+click brings me to the appropriate class, etc, so it's clearly finding the class at some point, just not where it matters most!

My code is like this:

#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
Zach
  • 3,909
  • 6
  • 25
  • 50

1 Answers1

1

Here the class Helper.swift can be access from my app and extension. Do as follows.

1.

enter image description here

  1. Go to file inspector in right hand side of Xcode.

enter image description here

  1. My code in extension.

enter image description here

Note: In obj-c you need to do above steps for .h and .m files.

Community
  • 1
  • 1
Karthick Selvaraj
  • 2,387
  • 17
  • 28
  • Presumably that means any dependencies the Helper.swift file uses will also have to be included to the SiriKitDemoExtension target, right? Doesn't including the SiriKitDemo as a target dependency include all files included with that target? – Zach Nov 09 '16 at 13:51
  • Yes we need to add the dependencies file of Helper.swift to sirikitDemoExtension target, otherwise it will throw an error. – Karthick Selvaraj Nov 10 '16 at 05:41