简体   繁体   中英

SiriKit custom intent linking error on Xcode 10

I have created a new Intent file, and now I have the following linker error:

Undefined symbols for architecture arm64:

"_OBJC_METACLASS_$_INIntentResponse", referenced from:
      _OBJC_METACLASS_$_KWdsjkhfjkdhskfIntentResponse in KWdsjkhfjkdhskfIntent.o
  "_OBJC_CLASS_$_INIntentResponse", referenced from:
      _OBJC_CLASS_$_KWdsjkhfjkdhskfIntentResponse in KWdsjkhfjkdhskfIntent.o
  "_OBJC_CLASS_$_INIntent", referenced from:
      _OBJC_CLASS_$_KWdsjkhfjkdhskfIntent in KWdsjkhfjkdhskfIntent.o
  "_OBJC_METACLASS_$_INIntent", referenced from:
      _OBJC_METACLASS_$_KWdsjkhfjkdhskfIntent in KWdsjkhfjkdhskfIntent.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I had this problem when I added a custom .intentdefinition file to a project that did not have an Intents extension. I solved it with these steps:

  • Delete the .intentdefinition file
  • Add a new target Intents Extension
  • Add a new target framework MyAppKit
  • Ensure that MyApp target was dependent on the new Intents Extension AND the MyAppKit framework
  • Add a new .intentdefinition file, checking target membership for the MyAppKit target only.

After this, the link error went away. I haven't yet completed the extension, so there are certainly other steps required, such as providing an implementation of the IntentHandler that implements the custom intent.

The framework may not strictly be required here, but it is the recommended way I think, especially if you're planning to implement shortcuts that can be resolved in the background.

From Apple forums ( edford ) :

It looks like the Intent framework isn't being linked to the target. In the Build Phases for the target, insure that Intents.framework is present in the Link Binary with Libraries phase.

This solved my issue which was similar.

This is a linking error: add Intents and IntentsUI framework to your target.

在此处输入图片说明

This error occured to me when I was attempting to use the generated Intent code on two different targets (main app and intent extension) while each target had different deploy versions and architecture.

My main app is being deployed to ios 9.0 (armv7) and the intent extension needs to be at least ios 12.0 (arm64) .

To solve this the intent code generated must target only one architecture type. On my case I had to upgrade the main app deployment version to ios 12.0 and architecture type to arm64 to match the intent extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM