Launching the Terminal app from Xcode on OS X with System Integrity Protection

If you occasionally use Xcode to create command line tools or applications, chances are that you’ve set up a scheme to launch those applications in the Terminal app from within Xcode, something like this:

Launch terminal

You then pass your app as an argument, like this:

App passed as argument

If you’ve recently upgraded your OS X installation to El Capitan you might have found Xcode is now refusing to launch the Terminal app and is giving you the message “Message from debugger: cannot attach to process due to System Integrity Protection”.

System Integrity Protection is a new security feature introduced in El Capitan. It is intended to stop malware from either modifying system critical parts of the file system or from attaching to system critical processes and injecting code.

On the whole, this is a good thing. Unfortunately the Terminal app is considered to be a system critical process so Xcode is no longer able to attach to it.

There are a couple of workarounds:

  1. You can disable System Integrity Protection. You’ll find details for this in the Apple documentation
  2. You can just build your app in Xcode and then launch it manually from the Finder.

However, both of these are hellish compromises to have to make. There is a third way. Xcode refuses to attach to Terminal because it’s an app that’s shipped with OS X. So the solution is to make it look like a user-installed app. Here’s how:

  1. Find the terminal app in Finder. It’s usually located at Applications > Utilities
  2. Copy it
  3. Paste the copy inside Applications (but outside of Utilities)
  4. Rename it, e.g. (This is important so you can easily identify that you are attaching to a copy and not the original)
  5. Now edit your scheme to launch this version of Terminal:
    Launch alternative version of terminal app

You should now find that your application launches quite happily again from within Xcode.


This entry was posted in Application Development and tagged , , , . Bookmark the permalink.

Leave a reply