如何在Xcode项目中使用具有多个环境的AppGroup?
我有一个带有通知服务的iOS应用程序和Coredata。我使用的是应用程序组(group.com.example.appname)
我对应用程序设置了多个配置,以便我可以拥有一个开发和产品环境:
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
一切正常,我能够构建两个应用程序的版本。问题是我正在使用应用程序组进行通知extension,还因为我希望Coredata可以在我正在初始化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的组?如果是这样,我该如何指定开发环境使用此组?
I have an iOS app with a NotificationServices extension and CoreData. I am using app groups (group.com.example.appName)
I have setup multiple configurations for my app so that I can have a dev and prod environment:
Debug Dev
Debug Prod
Release Dev
Release Prod
And I have modified my Scheme and in the target under build settings I have the following Product Bundle Identifiers in Packaging:
Debug Dev - com.example.appName.dev
Debug Prod - com.example.appName
Release Dev - com.example.appName.dev
Release Prod - com.example.appName
Everything works fine and I am able to build two versions of the app. The problem is that I am using app Groups for my NotificationExtension and also because I like CoreData to be accessible in the extension I am initializing my CoreData stack with:
let groupName = "group.com.example.appName"
let databaseIdentifier = "appName.sqlite"
let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupName)!.appendingPathComponent(databaseIdentifier)
How would I be able to change the group name for the dev environment so that the same database is not shared with the two apps?
Do I need to create another group called group.com.example.appName.dev? And if so how do I specify that the dev environment uses this group?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试:
you can try it: