title: How can I stop my app from setting the "quarantine" bit?
body: <p>Ever since OS X 10.7.3, my text editor is setting the "quarantine" bit on any file it touches.</p>
  
  <p>My text editor is designed for working with shell scripts, and if the quarantine bit is set then a shell script cannot be executed from the command line, until you double click it in Finder and go through a "This application was downloaded from the internet" alert (or remove the quarantine bit with <code>xattr</code>).</p>
  
  <p>For example, I just created a "hello world" script in my app, it has been quarantined, and cannot be executed:</p>
  
  <pre><code>$ xattr -l foo
  com.apple.quarantine: 0006;4f51dd2f;Dux;
  $ chmod +x foo
  $ ./foo
  -bash: ./foo: Operation not permitted
  </code></pre>
  
  <p>If I remove the quarantine bit, the script works:</p>
  
  <pre><code>$ xattr -d com.apple.quarantine foo
  $ ./foo
  hello world
  </code></pre>
  
  <p><br>
  According to some forum posts, <em>TextEdit</em> also sets the quarantine bit on any shell script it creates.</p>
  
  <p>I'm using a simple <code>NSDocument</code> subclass to create the file:</p>
  
  <pre><code>- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
  {
    return [self.textStorage.string dataUsingEncoding:self.stringEncoding];
  }
  </code></pre>
  
  <p><br>
  How can I remove the quarantine bit from files created in my app? Other text editors, such a <em>TextWrangler</em>, do not set the quarantine bit.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>A little more info, this only occurs when creating a "script application" file, which is anything from perl scripts to html.</p>
  
  <p>And it only occurs when my app is sandboxed. Disabling sandboxing fixes the problem, but that's not a long term solution.</p>
  
  <p>I've filed a bug with Radar, it looks like there might be nothing to do but wait/hope that avenue gets it fixed.</p>