title: Changing UserDefaults with defaults write
body: <p>I am trying to test changes to my <code>UserDefaults</code> after using <code>defaults write</code> on the command line.</p>
  <p>If in swift I write:</p>
  <pre><code>UserDefaults.standard.set(&quot;Hello&quot;, forKey:&quot;test&quot;)
  </code></pre>
  <p>and on the command line I enter:</p>
  <pre><code>defaults read ~/Library/Containers/[app]/Data/Library/Preferences/[app].plist test
  </code></pre>
  <p>where <code>[app]</code> is my application, the result is correct.</p>
  <p>If, how ever, I then enter:</p>
  <pre><code>defaults write ~/Library/Containers/[app]/Data/Library/Preferences/[app].plist test &quot;Goodbye&quot;
  </code></pre>
  <p>and in swift:</p>
  <pre><code>print(&quot;Test: \(UserDefaults.standard.string(forKey: &quot;test&quot;))&quot;)
  </code></pre>
  <p>The change seems to be ignored. Using <code>defaults read</code> does give the new value.</p>
  <p>What is missing her?</p>
  <p>Running on am iMac with MacOS 10.15.6 and XCode 11.7. I am using sandboxing, and the location was obtained from the SO question <a href="https://stackoverflow.com/questions/7982740/where-is-a-mac-applications-nsuserdefaults-data-stored#answer-12637976">Where is a Mac Application&#39;s NSUserDefaults Data Stored?</a> .</p>