My Xcode is v10 and I'm developing a custom intent for SiriKit, targeting iOS 12.
In Xcode 10, custom intents are designed in .intentdefinition files, where you can define your own parameters for intent phrases as well as the title of the intent and Siri shortcut for that intent. Building a project with a .intentdefinition file makes Xcode automatically generate an INIntent derived class for that intent.
My issue is that in order to support other languages than English so that the intent's title is show in the system's language in General > Siri & Search when the user is able to manipulate shortcuts for custom intents, I need to provide localized intent title for my .intentdefinition file.
When I try to add another language for my .intentdefinition file in the File Inspector and then build the project I get:
duplicate output file '/Users/.../IntentDefinitionGenerated/Intents/MyCustomIntent.swift' on task: IntentDefinitionCodegen /Users/.../ru.lproj/Intents.intentdefinition
This is likely happening because Xcode sees multiple .intentdefinition files in .lproj
folders and tries to generate a same named class for each of them.
How do I localize my .intentdefinition file for iOS 12?
Intents are the actions that can be performed by the user with Siri. With the custom intents, we can have better control over Siri Shortcuts. We can also create a custom Intents UI that can display some relevant information to the user without opening the app.
Go to your Targets setting, Signing & Capabilities, and add Siri. Now right click on the project folder and click on New File. Then, filter for intent and click on next to create a SiriKit Intent Definition File, which we will need soon in the next steps.
The App Intents framework offers a programmatic way to make your app's content and functionality available to system services like Siri and the Shortcuts app. The programmatic approach lets you expose any of your app's capabilities, and not just ones that fall into specific categories.
Go to intentdefinition
file -> File Inspector
-> Select Localize
-> Now select current language for your intentdefinition
file.
This will convert your existing intentdefinition
file for current language.
Now again select the same intentdefinition
file, add other language -> it will create a new Intents.strings
file where you can customize the text for other locales.
It looks like you've already localized your Intent Definition file (since Xcode has put it into a ru.lproj
folder) so the problem might be that you've two copies of the file in the "Compile Sources" build phase.
Go here:
Project -> App target -> Build Phases -> Compile Sources
and look for duplicate entries. If you find a duplicate, delete one of the copies
You can also try Editor > Validate Settings…
to find duplicates
You can also try cleaning the build
I had the same issue as @desmond-hume. In my case, I have an old xcode project that already contained some localizations before "Base" was available. The initial .intentdefinition file must be added as the Base localization. From there, further localization can be added and Xcode will add only a .strings file for each localization.
Without a base localization, Xcode adds a new .intentdefinition for each localization which causes the "multiple commands produce...." error.
You can add a Base localization under the main project settings via a checkbox. Some old projects (like mine) may also run into this issue: iOS - Using Base localization pane is always empty
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With