Capabilities and Localization

Hi guys and girls,

I have already released few iOS builds, but now I got stuck with few problems.

  1. Automatic Capabilities is checked, but I always have to manually add in-app purchase, push notifications and access wifi state when viewing project in XCODE. I have found a suggestion to add a PostProccessBuild script in Editor folder, but it doesn’t seem to work for non-cloud building, or is it? Anyways I built with it, but still had to add capabilities manually.

  2. I just recently implemeneted Unity Localization preview package, v 0.9. It works for Android builds and is correctly switching languages out of the box. When switching the editor to iOS it also works well, but in XCODE I dont see any references to implemented localization and builds it just doesnt work.

I’m using 2020.1 Unity.

If you could share maybe some links to read or a particular solution - that would be great.
Thanks!

Look into : Unity - Scripting API: iOS.Xcode.ProjectCapabilityManager.AddPushNotifications (and the ProjectCapability Manager in general)

About languages, the Unity package probably doesn’t do anything. The solution is to make a strings file in XCode, localize it in XCode to the languages you want, then there will be a folder with localized files. Then use something that copy pastes that in XCode (we used native locale, but you can probably do it manually).

Also, you might need some cleanup, since Unity adds some garbage languages regardless of your settings.

We’re doing something like this

        var appLanguages = new string[] {"en","de","el","es","fr","it","ja","\"pt-BR\"","ru","\"zh-Hans\"","\"zh-Hant\""};
        Debug.Log ($"Setting PBXProject developmentRegion={appLanguages.First ()} knownRegions={string.Join (",", appLanguages)} projPath={projPath}");

        var projRaw = File.ReadAllText (projPath);
        projRaw = Regex.Replace (projRaw, "developmentRegion\\s*?=\\s*?English", $"developmentRegion = {appLanguages.First ()}");
        projRaw = Regex.Replace (projRaw, "knownRegions\\s*?=\\s*?\\(\\n[\\s\\S\\n]*?\\);", $"knownRegions = (\n\t\t\t\t{string.Join (",\n", appLanguages)}\n\t\t\t);");
        File.WriteAllText (projPath, projRaw);

Sorry for the stream of consciousness like instructions, but I spent like a week figuring how to automate most of the XCode bullshit that Unity just won’t do for you, and I kinda removed the info from my brain afterwards. But there’s enough in there to get you started I think.

2 Likes

Thanks for the advices, just got back from holidays to try it out. I think I managed the use of Capabilities with a script.

This looks a bit complicated to me. I make xcode project in Unity on Windows, then copy it to Mac without unity and build there.

Im not sure if I can use your advice about copy pasting strings from Unity to Xcode in my pipeline.