title: How to remove sandbox without xcode
body: <p><a href="https://stackoverflow.com/questions/65874089/open-a-short-video-using-quicktime-player/65874325?noredirect=1#comment116470286_65874325">Earlier I asked a question regarding <code>generateCGImagesAsynchronously</code></a>. Thankfully it got answered and works great.</p>
  <p>The issue is that it <strong>only</strong> works as a Cocoa app on xcode. I am now trying to move this logic to an executable Swift package but <code>AVFoundation</code> code, such as <code>generateCGImagesAsynchronously</code>, won't work. That is, no error is raised but those functions seem to be mocked. I presume this <em>might</em> have to do with my package being sandboxed? I was able to remove the sandbox from the Cocoa app I previously wrote the code for, but I can't figure out how to do that for this executable.</p>
  <p>I am new to Swift and trying to understand it and it's kind of frustrating to think that what I want my code to do is dependent on the IDE I am using.</p>
  <p>If anyone can point me in the direction of where to read in the docs, or some other sources, on how to make programs without using xcode, that would be great. Thanks!</p>
  <p>Here is my code:</p>
  <pre><code>import Darwin
  import Foundation
  import AppKit
  import AVFoundation
  import Cocoa
  
  
  @discardableResult func writeCGImage(
      _ image: CGImage,
      to destinationURL: URL
  ) -&gt; Bool {
      guard let destination = CGImageDestinationCreateWithURL(
          destinationURL as CFURL,
          kUTTypePNG,
          1,
          nil
      ) else { return false }
      CGImageDestinationAddImage(destination, image, nil)
      return CGImageDestinationFinalize(destination)
  }
  
  
  func imageGenCompletionHandler(
      requestedTime: CMTime,
      image: CGImage?,
      actualTime: CMTime,
      result: AVAssetImageGenerator.Result,
      error: Error?
  ) {
      guard let image = image else { return }
      let path = saveToPath.appendingPathComponent(
          &quot;img\(actualTime).png&quot;
      )
  
      writeCGImage(image, to: path)
  }
  
  
  let arguments: [String] = Array(CommandLine.arguments.dropFirst())
  
  // For now, we assume the second arg, which is the
  // path that the user wants us to save to, always exists.
  let saveToPath = URL(fileURLWithPath: arguments[1], isDirectory: true)
  
  let vidURL = URL(fileURLWithPath: arguments[0])
  let vidAsset = AVAsset(url: vidURL)
  let vidDuration = vidAsset.duration
  
  let imageGen = AVAssetImageGenerator(asset: vidAsset)
  var frameForTimes = [NSValue]()
  let sampleCounts = 20
  let totalTimeLength = Int(truncatingIfNeeded: vidDuration.value as Int64)
  let steps = totalTimeLength / sampleCounts
  
  for sampleCount in 0 ..&lt; sampleCounts {
      let cmTime = CMTimeMake(
          value: Int64(sampleCount * steps),
          timescale: Int32(vidDuration.timescale)
      )
      frameForTimes.append(NSValue(time: cmTime))
  }
  
  imageGen.generateCGImagesAsynchronously(
      forTimes: frameForTimes,
      completionHandler: imageGenCompletionHandler
  )
  
  </code></pre>