title: Is sharing UserDefaults between iOS and tvOS still possible?
body: <p><strong>Is sharing UserDefaults between iOS and tvOS still possible?</strong> </p>
  
  <p>In my Xcode project I use <code>UserDefaults</code> to share data between my iOS target and my tvOS target. I always receive nil values from my <code>UserDefaults</code> when I try to get data back from my tvOS app. </p>
  
  <p>These are the steps I took to share data:</p>
  
  <p>1: Add App Groups for both targets. Both targets use the same App Group ID:
  <strong>group.nl.mycompany.myappname</strong>. </p>
  
  <p><em>I use the .nl domain but this should be fine since this also worked for my other projects.</em></p>
  
  <p>2: Confirm both targets have the same deployment target. <em>I tried using 10.0 and 11.0.</em></p>
  
  <p>3: Validate the myproject.entitlements that everything is set OK.</p>
  
  <p>4: Validate that on developer.apple.com the App Group is enabled for my bundle identifier.</p>
  
  <p>5: Both targets have the same bundle ID. I also tried using 2 different bundle identifiers.</p>
  
  <p>6: The way I write to <code>UserDefaults</code> from my iOS app:</p>
  
  <pre><code>guard let defaults = UserDefaults(suiteName: "group.nl.mycompany.myappname") else { return }
  defaults.set("Apple", forKey: "username")
  defaults.synchronize()
  </code></pre>
  
  <p>I confirm this works in my iOS app by getting the value like so:</p>
  
  <pre><code>guard let defaults = UserDefaults(suiteName: "group.nl.mycompany.myappname") else { return nil }
  defaults.synchronize()
  let name = defaults.string(forKey: "username")
  </code></pre>
  
  <p>This indeed returns "Apple".</p>
  
  <p>7: Opening my tvOS app and calling this code returns nil:</p>
  
  <pre><code>guard let defaults = UserDefaults(suiteName: "group.nl.mycompany.myappname") else { return nil }
  defaults.synchronize()
  let name = defaults.string(forKey: "username")
  </code></pre>
  
  <p>Is it possible that <code>UserDefaults</code> sharing has been removed? Something similar happened to sharing <code>UserDefaults</code> between your phone and watch link <a href="https://stackoverflow.com/a/41052513/6414904">here</a>. I also read that the maximum size of <code>UserDefaults</code> is <a href="https://stackoverflow.com/a/32781011/6414904">500kb</a> for the AppleTV but saving this simple string should be fine. </p>