我有一个iOS应用程序,有一个NotificationServices扩展和CoreData。我正在使用app组(group.com.example.appName)
我为我的应用程序设置了多个配置,这样我就可以拥有一个dev和prod环境:
Debug Dev
Debug Prod
Release Dev
Release Prod我已经修改了我的方案,在构建设置下的目标中,我有以下产品包标识符:
Debug Dev - com.example.appName.dev
Debug Prod - com.example.appName
Release Dev - com.example.appName.dev
Release Prod - com.example.appName一切都很好,我可以建立两个版本的应用程序。问题是,我的NotificationExtension使用了应用程序组,也因为我喜欢在扩展中访问CoreData,我用:
let groupName = "group.com.example.appName"
let databaseIdentifier = "appName.sqlite"
let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupName)!.appendingPathComponent(databaseIdentifier)我如何才能更改dev环境的组名,使两个应用程序不能共享相同的数据库?
我需要创建另一个名为group.com.example.appName.dev的组吗?如果是这样,我如何指定dev环境使用这个组?
发布于 2022-04-25 09:43:05
你可以试试:
if let appDomain = Bundle.main.bundleIdentifier {
let databaseIdentifier = "\(appDomain).sqlite"
let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appDomain).appendingPathComponent(databaseIdentifier)
}https://stackoverflow.com/questions/71997410
复制相似问题