title: How to get Access-control list(POSIX ACL) for file in XCode project
body: <p>I can not get ACL for a file in XCode. It fails all the time.
  My code:</p>
  <pre><code>acl_type_t opt = ACL_TYPE_ACCESS;
  
  const char *path_p = path.fileSystemRepresentation;
  acl_t acl = acl_get_file(path_p, opt);
  if (acl == NULL) {
      NSAssert(NO, @&quot;acl_get_file %s&quot;, path_p);
      return;
  }
  </code></pre>
  <p>Found <a href="https://man7.org/tlpi/code/online/dist/acl/acl_view.c.html" rel="nofollow noreferrer">an example</a> that does the same, but it does not work in my case.</p>
  <p><a href="https://en.wikipedia.org/wiki/Access-control_list" rel="nofollow noreferrer">ACL</a> - Access-control list.(To read what is ACL you can write &quot;man acl&quot; or &quot;man chmod&quot; in the terminal app.)</p>
  <blockquote>
  <p>A filesystem ACL is a data structure (usually a table) containing entries that specify individual user or group rights to specific system objects such as programs, processes, or files.</p>
  </blockquote>
  <p>I used NSOpenPanel to get access:</p>
  <pre><code>NSOpenPanel *openPanel = [NSOpenPanel openPanel];
  openPanel.directoryURL = [NSURL fileURLWithPath:@&quot;/&quot;];
  openPanel.canChooseDirectories = false;
  openPanel.canChooseFiles = !openPanel.canChooseDirectories;
  
  [openPanel beginSheetModalForWindow:self.view.window completionHandler:^(NSModalResponse result) {
      [openPanel orderOut:nil];
      
      if (result == NSModalResponseOK &amp;&amp; openPanel.URL != nil) {
          //My code getting ACL for openPanel.URL.path
      }
  }];
  </code></pre>
  <p>And then I check modification access for file(I have no idea how to check ACL access. looks like I don't have it)</p>
  <pre><code>NSURL *url = [NSURL fileURLWithPath:path];
  NSError *error = nil;
  __auto_type resourceValues = [url resourceValuesForKeys:@[NSURLIsUserImmutableKey, NSURLIsWritableKey] error:&amp;error];
  NSParameterAssert(error == nil);
  NSParameterAssert(!resourceValues.fileIsImmutable);
  if ([resourceValues[NSURLIsWritableKey] isKindOfClass:[NSNumber class]]) {
      NSParameterAssert([(NSNumber *)resourceValues[NSURLIsWritableKey] boolValue]);
  } else {
      NSParameterAssert(NO);
  }
  NSParameterAssert([[NSFileManager defaultManager] isWritableFileAtPath:path]);
  </code></pre>
  <p>What I see in the console:</p>
  <pre><code>12/14/20 5:59:15.383 PM ACLTest[915]: acl_get_file /Users/test/Desktop/untitled folder
  </code></pre>
  <p>What did I try:</p>
  <ul>
  <li>Gave my app &quot;Full Disk Access&quot;</li>
  <li>Launched my app on 10.10 &amp; 10.15</li>
  <li>Wrote the same code in &quot;Console Project template&quot;</li>
  <li>Tried to use each enum element from acl_type_t</li>
  <li>Unsuccessfully Googled without any useful results</li>
  </ul>
  <p>I got the data I need in the Terminal app(I do know how to launch the script from the app, but suppose it might violate some Apple policies. And have some extra complexion for users. So my aim is to get info from code without launching additional scripts):</p>
  <pre><code># ls -le
  total 64
  drwxrwxr-x@  8 &lt;UserName&gt;  staff    256 Dec 14 16:29 &lt;Folder Name&gt;
   0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown
  </code></pre>