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:

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

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:

You can disable System Integrity Protection. You’ll find details for this in the Apple documentation

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:

Find the terminal app in Finder. It’s usually located at Applications > Utilities

Copy it

Paste the copy inside Applications (but outside of Utilities)

Rename it, e.g. MyTerminal.app (This is important so you can easily identify that you are attaching to a copy and not the original)

Now edit your scheme to launch this version of Terminal:

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