Hide AppDelegate.scpt source code for macOS application – Xcode

applescriptapplicationsxcode

I have just finished building an Applescript Application with Xcode and I'm ready for exporting the whole thing.

As this app is not made for the App Store, but private distribution, I have followed this guide to export the .app to my mac.

Upon looking at the resources folder (Application.app/Contents/Resources) I am able to see the AppDelegate.scpt file containing the source code for this application.

This is my first application that I am exporting and my question is:
1. How do I hide/remove or garble the source code so that an ordinary user would not be able to see its contents?
2. What is the conventional way that everyday programmers export their application without revealing the source code (Xcode specific)?

Please help me understand so that I can deploy the app. Thanks in advance.

Best Answer

When you save the AppleScript file you have the option of checking "Run Only" - in that case the script is compiled into a new form that can be run exactly as the original script, but it is not meant for further editing/development.

It doesn't mean that the run-only file is complete protected or non-readable, but parts of your code, comments, etc. are not included or not easily readable.

If you want to do more you'll need a code obfuscator if you still want to use AppleScript - however I'm not sure if one exists on the market, or you need to develop your own.

Regarding the second part of your question - most programmers do not use AppleScript. For other languages such as Objective-C, C, C++, etc. the problem is not the same as their programs are ordinarily compiled before they can run, and in the process of compilation they are translated into a non-human readable form.

Some implementations of languages do not exhibit this behaviour - for example ordinary PHP scripts are interpreted or compiled at run-time. For PHP, Javascript, etc. you can buy obfuscators that helps "masking" or "hiding" the original source code while allowing the program to run.