简体   繁体   中英

How to import the Swift classes generated by the Intents Definition File from Objective-C?

After defining my Intents Definition File I can access the Swift generated classes in my Intents Extension

在此处输入图像描述

Also I've ensured the generated classes are members of the main app target.

在此处输入图像描述

In the intent handler I can see it's properly defined

在此处输入图像描述

Pointing to this declaration

在此处输入图像描述

I don't really understand where this file is located, is it generated at compile time? In any case, in my app delegate I would like to handle this intent like so

在此处输入图像描述

But it's not imported, how do I link it to the main app target?

It's generated.

Just define a protocol for the generated class

protocol CreateReminderConfig {}

And add the following in swift:

extension CreateReminderIntent: CreateReminderConfig {}

Then, compare the class to match the protocol instead of that class.

That class is generated and it might be not the same as a normal class in switch or the visibility/usage is limited.

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