Search code examples
macoslocalizationplistpyinstallermacos-mojave

Mac - Localize plist using pyinstaller


I have a mac app created using pyinstaller. I have added "NSCalendarsUsageDescription", "NSContactsUsageDescription" to Info.plist. This works fine for default english language.

Now I want to add Infoplist.string files to localize above strings. I tried copying fr.lproj/Infoplist.string in build app/Contents/Resources. This did not work.

Do I need to add this reference in .spec file somewhere? Or anything else I am missing.

EDIT

I created a test app in xcode 10. Added "NSCalendarsUsageDescription" in Info.plist Added following code

NSArray* dirs = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Calendars"] error:&error];

It gives error

Error Domain=NSCocoaErrorDomain Code=257 "The file “Calendars” couldn’t be opened because you don’t have permission to view it." UserInfo={NSUserStringVariant=(
    Folder
), NSURL=file:///Users/insync/Library/Calendars, NSFilePath=/Users/insync/Library/Calendars, NSUnderlyingError=0x600000c5c870 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

According https://developer.apple.com/videos/play/wwdc2018/718/ , Mac Mojave should give a user consent prompt asking user to give permissions to use Calendars.

I have signed this app and tried. Still same error.


Solution

  • Finally found the issue. NSCalendarsUsageDescription when added without quotes did the trick. Not sure why it did not work earlier properly.

    About Edited part, we need to enable Calendar access from Capabilities -> SandBoxing. Then only app can access Calendars.