V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
ChrisFreeMan
V2EX  ›  iDev

各位大佬问一个 Xcode App Group 的问题

  •  
  •   ChrisFreeMan · 2022-07-17 00:24:41 +08:00 · 7344 次点击
    这是一个创建于 621 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想在 app 和 widget 之间通信,遂创建了 App Groups

    通过以下代码向容器写入数据

    UserDefaults(suiteName: AppConfig.appGroupName)!.set(newValue, forKey: "some Data Key")
    

    再通过以下代码获取数据

    UserDefaults(suiteName: AppConfig.appGroupName)!.string(forKey: "some Data Key") ?? "nil"
    

    虽然以上代码正常运行,但是在真机上 debug 环境的时候老是抛出以下警告信息

    2022-07-17 00:07:45.204039+0800 MyAPP[13503:1219072] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x2804ea800> (Domain: group.myGropName, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
    

    无法确认这是什么问题,网上搜了一圈也没找到,所以来这里求救

    6 条回复    2022-07-17 15:36:27 +08:00
    StevenRCE0
        1
    StevenRCE0  
       2022-07-17 01:12:40 +08:00
    检查一下 group 名字是不是对应。这有一个相关问题的串: https://stackoverflow.com/questions/38275395/failed-to-read-values-in-cfprefsplistsource-ios-10
    我也遇到过这个问题,忘了有没有修,反正最后去用 CoreData 和 transaction 做数据同步了……
    ChrisFreeMan
        2
    ChrisFreeMan  
    OP
       2022-07-17 01:25:49 +08:00
    @StevenRCE0 明天再试试,不行我也考虑换一种更靠谱的同步方式
    ChrisFreeMan
        3
    ChrisFreeMan  
    OP
       2022-07-17 01:27:28 +08:00
    @StevenRCE0 嗷对了,感谢回复
    StevenRCE0
        4
    StevenRCE0  
       2022-07-17 02:01:23 +08:00
    @ChrisFreeMan 阿果真的应该更新一下相关 API 了 xD
    uclort
        5
    uclort  
       2022-07-17 14:08:07 +08:00 via iPhone
    这个提示忽略就行了,存在长久了,老毛病,不影响真实使用。
    ChrisFreeMan
        6
    ChrisFreeMan  
    OP
       2022-07-17 15:36:27 +08:00
    @uclort swiftUI 这种推荐忽略的错误好多啊,强迫症看了都怕,又难受,又不知道会不会有什么坑
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1535 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 79ms · UTC 23:58 · PVG 07:58 · LAX 16:58 · JFK 19:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.