Macos – When trying to edit OS X app (Unix Executable File)

macos

I want to know how to edit the binary file in a Mac app. The file I am attempting to edit is found in foo.app/Contents/MacOS/foo

Whenever I try editing it with TextMate, it saves fine. But then I try opening the app, it won't open or it crashes. I suspect this is the OS detecting a change in the app and disallowing execution afterwards? I'm editing simple stuff which would not affect successfully opening the app, such as a URL. Why is this happening and how can I fix it?

Best Answer

You really shouldn't be editing a binary executable with TextMate. If you must edit it, use a proper text editor like Hex Fiend (http://ridiculousfish.com/hexfiend/). Also, for simplicity you should make sure that whatever URL you are replacing you replace it with one of equal length. Binary files have physical offsets that are used when reading them into memory, and insertion and deletions can corrupt the binary.

If you need to replace a URL it should be easy enough to pad the URL with a / for example http://google.com/////.

Related Question