在调试iOS和Watch应用传递数据时,发现Xcode预览失败,并且报错内容为:
Embedded binary is not signed with the same certificate as the parent app. Verify the embedded binary target's code sign settings match the parent app's.
Embedded Binary Signing Certificate: Not Code Signed
Parent App Signing Certificate: - (Ad Hoc Code Signed)
经过查询发现问题报错的原因为:嵌入式二进制(也就是 Watch App 或者任何其他嵌入式目标)没有使用与父应用相同的证书进行签名。需要检查 Provisioning Profile 和 Signing Certificate。
经过仔细对比发现,在使用UserDefaults时,使用的suiteName有误导致的问题。
错误的App Groups:
if let appGroupDefaults = UserDefaults(suiteName: "group.com.yourcompany.piggybank"),
修改为正确的App Groups后,问题得到解决。
if let appGroupDefaults = UserDefaults(suiteName: "group.com.fangjunyu.piglet.watch"),
