Mac - 使用 pyinstaller 本地化 plist
Mac - Localize plist using pyinstaller
我有一个 mac 使用 pyinstaller 创建的应用程序。我已将 "NSCalendarsUsageDescription"、"NSContactsUsageDescription" 添加到 Info.plist
。
这适用于默认英语。
现在我想添加 Infoplist.string
个文件来本地化上述字符串。我尝试在 build app/Contents/Resources
中复制 fr.lproj/Infoplist.string
。
这没有用。
我需要在 .spec
文件的某处添加此引用吗?或者我遗漏的任何其他内容。
编辑
我在 xcode 10 中创建了一个测试应用程序。在 Info.plist 中添加了 "NSCalendarsUsageDescription"
添加了以下代码
NSArray* dirs = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Calendars"] error:&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"}}
根据 https://developer.apple.com/videos/play/wwdc2018/718/,Mac Mojave 应该向用户提供同意提示,要求用户授予使用日历的权限。
我已经在这个应用程序上签名并尝试过了。仍然是同样的错误。
终于找到问题了。
添加时不带引号的 NSCalendarsUsageDescription 就可以了。不知道为什么它不能更早地正常工作。
关于已编辑的部分,我们需要从 Capabilities -> SandBoxing 启用日历访问。然后只有应用程序可以访问日历。
我有一个 mac 使用 pyinstaller 创建的应用程序。我已将 "NSCalendarsUsageDescription"、"NSContactsUsageDescription" 添加到 Info.plist
。
这适用于默认英语。
现在我想添加 Infoplist.string
个文件来本地化上述字符串。我尝试在 build app/Contents/Resources
中复制 fr.lproj/Infoplist.string
。
这没有用。
我需要在 .spec
文件的某处添加此引用吗?或者我遗漏的任何其他内容。
编辑
我在 xcode 10 中创建了一个测试应用程序。在 Info.plist 中添加了 "NSCalendarsUsageDescription" 添加了以下代码
NSArray* dirs = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"/Library/Calendars"] error:&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"}}
根据 https://developer.apple.com/videos/play/wwdc2018/718/,Mac Mojave 应该向用户提供同意提示,要求用户授予使用日历的权限。
我已经在这个应用程序上签名并尝试过了。仍然是同样的错误。
终于找到问题了。 添加时不带引号的 NSCalendarsUsageDescription 就可以了。不知道为什么它不能更早地正常工作。
关于已编辑的部分,我们需要从 Capabilities -> SandBoxing 启用日历访问。然后只有应用程序可以访问日历。