Reputation: 8607
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?
Upvotes: 25
Views: 8560
Reputation: 47
you must be Project->info checked "Use Base Internationalization"
Next use the top answer method to create
Upvotes: 0
Reputation: 61
I've recently Localised the intents for my App, however after the original localisation, I added another Intent.
In Xcode 10.2.1 at least that I've checked, there is an "Export for Localization" option when you select the top level of your project. It will ask you to save the output. When you investigate your output, you should see an .xcloc folder for EACH of the languages you support. Dig down to the .xliff under "Localized Contents" and open it.
There you will find your treasure trove of the items and you're looking for and you're looking for items that don't have a 'target'
The engineers at Apple at dub dub showed me this, however I personally wasn't happy of this process, as you have to edit it, and then re-import it (assuming you send off your files to a translator and get an .xliff back.
The annoyance though with Intents is the fact that it uses arbitrary IDs and not something legible
I haven't found an easier way (yet) to locate the missing translations. Hope this helps!
Upvotes: 0
Reputation: 817
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
Upvotes: 7
Reputation: 113757
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
Upvotes: 3
Reputation: 987
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.
Upvotes: 32