简体   繁体   English

Xcode 10 上的 SiriKit 自定义意图链接错误

[英]SiriKit custom intent linking error on Xcode 10

I have created a new Intent file, and now I have the following linker error:我创建了一个新的 Intent 文件,现在出现以下链接器错误:

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.当我将自定义.intentdefinition文件添加到没有Intents扩展名的项目时,我遇到了这个问题。 I solved it with these steps:我通过以下步骤解决了它:

  • Delete the .intentdefinition file删除.intentdefinition文件
  • Add a new target Intents Extension添加新的目标 Intents 扩展
  • Add a new target framework MyAppKit添加新的目标框架MyAppKit
  • Ensure that MyApp target was dependent on the new Intents Extension AND the MyAppKit framework确保MyApp目标依赖于新的 Intents 扩展和MyAppKit框架
  • Add a new .intentdefinition file, checking target membership for the MyAppKit target only.添加一个新的.intentdefinition文件,仅检查MyAppKit目标的目标成员资格。

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.我还没有完成扩展,所以肯定还需要其他步骤,例如提供实现自定义意图的 IntentHandler 的实现。

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 ) :来自 Apple 论坛 ( edford ) :

It looks like the Intent framework isn't being linked to the target.看起来 Intent 框架没有链接到目标。 In the Build Phases for the target, insure that Intents.framework is present in the Link Binary with Libraries phase.在目标的构建阶段,确保 Intents.framework 存在于 Link Binary with Libraries 阶段。

This solved my issue which was similar.这解决了我的类似问题。

This is a linking error: add Intents and IntentsUI framework to your target.这是一个链接错误:将 Intents 和 IntentsUI 框架添加到您的目标。

在此处输入图片说明

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.当我尝试在两个不同的目标(主应用程序和意图扩展)上使用生成的 Intent 代码而每个目标具有不同的部署版本和架构时,我发生了这个错误。

My main app is being deployed to ios 9.0 (armv7) and the intent extension needs to be at least ios 12.0 (arm64) .我的主应用程序正在部署到 ios 9.0 (armv7)并且意图扩展至少需要是 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.就我而言,我必须将主应用程序部署版本升级到ios 12.0 ,将架构类型升级到arm64以匹配意图扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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