创建即时定制意图

时间:2018-06-27 21:23:06

标签: ios objective-c xcode10 ios12 sirishortcuts

我有一个Intents.intentdeinition文件,其自定义意图定义为OrderIntent

enter image description here

当我尝试实例化此意图并按如下所示设置其参数时:

#import "TransactionCart+Intents.h"
#import "OrderItemIntent.h"

@implementation TransactionCart (Intents)

- (nonnull INIntent *)getCartIntent;
{
    ItemObject *item = self.itemManager.selectedItem;
    OrderItemIntent *intent = [[OrderItemIntent alloc] init];
    intent.quantity = item.quantity;
    intent.name = item.name;
    return intent;
}
@end

我在OrderItemIntent *intent = [[OrderItemIntent alloc]init];上收到一条运行时控制台消息,并显示以下消息:

Unable to initialize 'OrderItemIntent'. Please make sure that your intent definition file is valid.

该应用程序继续运行,但是getCartIntent返回nil

我已经尝试过多次进行各种更改来重新创建意图定义文件,但是仍然无法正常工作。

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。终于找到原因了,因为我定义了 Intents.intentdeinition 文件不在主项目中,而是在 pod 库中。在 pod 库中,您应该将代码添加到 podspec 文件 s.resource = 'LCHomeModule/Classes/Intents.intentdefinition'

答案 1 :(得分:0)

将类别下拉列表更改为“订单”或“开始”。不幸的是,这里提到的是一个beta(自beta 3起)错误:https://forums.developer.apple.com/thread/103656