Reza Shirazian
Reza Shirazian

Reputation: 2353

"Unable to initialize 'OrderIntent'. Please make sure that your intent definition file is valid" error when creating an instant of custom intent

I have an Intents.intentdeinition file with a custom intent defined as OrderIntent.

enter image description here

When I try to instantiate this intent and set its parameter like this:

#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

I get a run time console message on OrderItemIntent *intent = [[OrderItemIntent alloc]init]; with this message:

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

The app continues to run however getCartIntent returns nil

I've tried recreating the intent definition file multiple times with various changes but still I can't get this to work.

Upvotes: 1

Views: 948

Answers (2)

heeween
heeween

Reputation: 11

I have met the same problem. Finally I find the reason.It is because I define the Intents.intentdeinition file not in the main project, but in a pod library.As in a pod library you should add the code in your podspec file s.resource = 'LCHomeModule/Classes/Intents.intentdefinition'

Upvotes: 1

hudson.lim
hudson.lim

Reputation: 1

Change the category dropdown to "Order" or "Start". It's unfortunately a beta (as of beta 3) bug as mentioned here: https://forums.developer.apple.com/thread/103656

Upvotes: 0

Related Questions