How to use shared AppGroup UserDefaults in macOS and Xcode extension

Issue #201

  • Go to both app and extension target, under Capabilities, enable AppGroup

  • Specify $(TeamIdentifierPrefix)group.com.onmyway133.MyApp

  • $(TeamIdentifierPrefix) will expand to something like T78DK947F3., with .

  • Then using is like a normal UserDefaults

1
2
3
4
let defaults = UserDefaults(suiteName: "T78DK947F3 .group.com.onmyway133.MyApp")

defaults?.set(true, forKey: "showOptions")
defaults?.synchronize()

Comments