我的应用在 xcode 11.4 中找不到 sirikit intentdefinition 类

My app does not find sirikit intentdefinition classes in xcode 11.4

我的应用程序自推出以来就支持几个 siri 快捷方式,但已经很久没有碰过它了。我的项目在 11.3.2 中编译和构建,但在 11.4 中没有。

我得到的错误是不再找到应该从我的 intentdefinition 文件中生成的 类,我在我的 intenthandlers 中引用的

例如,在我的意图定义文件中,我有一个名为 "MyStatus" 的自定义意图。

然后我有一个 MyStatusIntentHandler:

#import "MyStatusIntent.h"
@interface MyStatusIntentHandler<MyStatusIntentHandling> : NSObject

在 11.4 中,我得到一个 "MyStatusIntent.h" 文件未找到。在 11.3.1 及更早版本中,它构建良好。

我不太擅长项目配置和结构,所以我有点不知道从哪里开始挖掘。如果有人有任何指示,以及 11.4 中的哪些内容可能是新的并给我带来问题,我会洗耳恭听。

我也有这个问题。 更新 XCode 后,从 *.intentdefinition 文件获取构建失败,"error: use of unresolved identifier" for 类。 通过终端构建,我收到了这条消息:

2020-03-26 17:11:21.874 xcodebuild[28391:166707]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEIntentBuilder/IDEIntentBuilder-16029/IntentsBuildSystem/XCCompilerSpecificationIntents.m:46
Details:  Code generator extension identifier unexpectedly nil for <DVTDeclaredPrimitiveFileDataType:0x7f888398b950:49:'com.apple.sirikit.intentdefinition':'Intent Definition':-*-*-------**-----*--*----*----------------------*-------------->
Object:   <XCCompilerSpecificationIntents: 0x7f88838a4540>
Method:   -createCommandsforInputs:withMacroExpansionScope:
Thread:   <NSThread: 0x7f8892390940>{number = 13, name = (null)}
Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
** BUILD FAILED **

现在我降级 Xcode 并向 https://feedbackassistant.apple.com/feedback/7640678

添加反馈

我已经四处寻找,也与 Apple 支持人员进行了交谈。原来,这与"legacy build system"有关。

在 xcode 项目设置中切换到新的构建系统后,我可以再次构建项目。我会争辩说,如果他们仍然支持遗留系统(他们这样做),它应该可以工作,但是哦,好吧。

在此处了解如何切换: https://help.apple.com/xcode/mac/current/#/dev396bc94c7

我在混合 swift+objc 项目中遇到过类似的问题。

我的项目中有一个文件 'Intents.intentdefinition' 用于单独的 Siri Extension 目标。 此外,此文件包含在应用程序目标的编译中(用于使用生成的 类 添加带有 UI 的意图)。

Siri 扩展目标构建成功。

但应用程序构建失败并出现错误:"'AnyIntent.h' 未找到",尽管已生成这些文件(我已检查)。

我只通过更改 Siri 扩展目标的构建设置解决了这个问题

Intent Class Generation Language (INTENTS_CODEGEN_LANGUAGE)
from Automatic to Swift

之前生成的intents头文件全部导入我改成了

#import <SiriIntents-Swift.h>

在尝试为 iOS 14 小部件添加 ConfigurationIntent 时在 XCode 12.4 上偶然发现了这个问题,在我的情况下,问题不在于代码生成器是出错了。结果它实际上工作得很好,但是它创建的 classes 的名称以“Objective-C Class 前缀”为前缀,(因为一些 Obj-C 遗留项目设置,或其他)和 XCode 生成的引用它的样板代码忽略了该步骤,并一直在寻找无处可寻的 ConfigurationIntent class。更改 INTENTS_CODEGEN_LANGUAGE 也无济于事。

反正最后不得不深究:

DerivedData/<ProjectName>/Build/Intermediates.noindex/<ProjectName>.build/Debug-iphoneos/<TargetName>/DerivedSources/IntentDefinitionGenerated/Intents

这是我找到我的 class 文件的地方,它的实际名称为 <ObjCPrefix>ConfigurationIntent。我用这个替换了对ConfigurationIntent的引用,错误终于消失了。