[macOS] Cannot include multilanguage permissions requests
Problem Description
To support permissions requests (Camera, Microphone, etc) on different languages for macOS you need to add to application resources languages folders (en.lproj, fr.lproj etc) with InfoPlist.strings files. It described here https://stackoverflow.com/questions/56048180/how-to-localize-info-plist-content-in-visual-studio.
But trying to add such directories to package AIR app cause error. So you cannot localize permissions requests for your apps.
Tested with AIR 33.1.1.929 with different AIR applications.
Trying to add purposeStrings.xml (which works with iOS) doesn't work - application not use it.
Trying to add purposeStrings.xml related content to application descriptor XML to macOS InfoAdditions section also doesn't work - packaging error.
Steps to Reproduce
Try to package macOS application with code below and include localization directories (en.lproj and fr.lproj for example).
Packaging command:
adt -package -storetype pkcs12 -keystore cert.p12 -storepass pass -keypass pass -target bundle macos_multiple_languages_bug macos_multiple_languages_bug-app.xml macos_multiple_languages_bug.swf en.lproj fr.lproj
Application example with sources attached. macos_multiple_languages_bug.zip
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Camera;
import flash.events.MouseEvent;
public class MacOSMultipleLanguagesBug extends Sprite {
public function MacOSMultipleLanguagesBug() {
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.addEventListener(MouseEvent.CLICK, click);
}
private function click(e:MouseEvent):void {
trace("click", Camera.permissionManager.permissionStatus);
Camera.permissionManager.requestPermission();
}
}
}
Actual Result: You will get packaging error:
unexpected failure: Cannot invoke "java.util.List.listIterator()" because "<parameter2>" is null
java.lang.NullPointerException: Cannot invoke "java.util.List.listIterator()" because "<parameter2>" is null
at com.adobe.air.Utils.validateMacResourceAgainstSupportedLanguages(Utils.java)
at com.adobe.air.nai.AppBundlePackager.validateAssetFile(AppBundlePackager.java)
at com.adobe.air.nai.NativePackager.access$000(NativePackager.java)
at com.adobe.air.nai.NativePackager$AIRForNAIPackager.validateAssetFile(NativePackager.java)
at com.adobe.air.ApplicationPackager.createPackage(ApplicationPackager.java)
at com.adobe.air.nai.NativePackager.createPackage(NativePackager.java)
at com.adobe.air.nai.AppBundlePackager.createPackage(AppBundlePackager.java)
at com.adobe.air.ADT.parseArgsAndGo(ADT.java)
at com.adobe.air.ADT.run(ADT.java)
at com.adobe.air.ADT.main(ADT.java)
If you try to package via Animate you will get error:
unexpected failure: null
java.lang.NullPointerException
at com.adobe.air.Utils.validateMacResourceAgainstSupportedLanguages(Utils.java)
at com.adobe.air.nai.AppBundlePackager.validateAssetFile(AppBundlePackager.java)
at com.adobe.air.nai.NativePackager.access$000(NativePackager.java)
at com.adobe.air.nai.NativePackager$AIRForNAIPackager.validateAssetFile(NativePackager.java)
at com.adobe.air.ApplicationPackager.createPackage(ApplicationPackager.java)
at com.adobe.air.nai.NativePackager.createPackage(NativePackager.java)
at com.adobe.air.nai.AppBundlePackager.createPackage(AppBundlePackager.java)
at com.adobe.air.ADT.parseArgsAndGo(ADT.java)
at com.adobe.air.ADT.run(ADT.java)
at com.adobe.air.ADT.main(ADT.java)
Expected Result: Application will be packaged. If you launch it with French locale device and click anywhere on stage - localized permission request will be prompted.
Known Workarounds
Package AIR application without these resources and then add it to .app resources and sign application again.
So I think there are two options here. Firstly though - the application descriptor XML needs to have the below line added to it to proceed:
<supportedLanguages>en fr</supportedLanguages>
Then if I try building with the folders and InfoPlist.string files, it tells me:
The path en.lproj/InfoPlist.strings is restricted. Choose another name for this file.
So the two options:
- we can remove the restriction on that file path, so that you can add the manual string files in locale-specific folders or
- we can instead add support for that purposeStrings.xml mechanism so that iOS and macOS platforms work the same..
Any preference?
@ajwfrost, I thing for now purposeStrings.xml support for macOS could be preferable. So we can reuse iOS mechanism.
Second this, good to keep the approach similar if possible.
Yes that's what I thought. But it's a bit harder to do ... and I'm actually struggling to find documentation on the purposeStrings mechanism! The only reference I can find is to your comment https://github.com/airsdk/Adobe-Runtime-Support/issues/345#issuecomment-643022825 but the release notes have now disappeared so I'm glad you copied that snippet...
thanks
Gosh, was always a bit of a mysterious one, took a bit of pestering for Adobe to do it and obviously never got properly documented. Will try and gather what I can and put it up on airsdk.dev.
Issue still exists with latest AIR SDK 50.2.4.5.