Xcode build phase - xcode

Hey, I'm implementing MD5 checksum on my app(for preventing binary crack). I created a command line tool that will generate the hash for the binary and will add it to the .app folder. However, I didn't figure out how to add it as a build phase. I've read Apple's documentation with no luck. Could anyone explain me how to do that step by step?
Thanks!

To do any kind of post-processing, use a Run Script build phase (add such a phase to your target). Use the list of environment variables Xcode provides (you can see them when the phase runs by expanding the script's results in the build results window) to locate the binary. From there you know where its Resources file is. The rest is standard Unix command-line stuff (run the command line and put the file into the target folder).
Now for advice you didn't ask for: It's trivial to re-hash the modified binary and replace yours with the new one in the resources folder. Anyone experienced enough to crack binaries would likely just disable the call to your "verify the MD5 against a file" code anyway, eliminating the need to replace the saved hash altogether. Long story short: You're wasting your time with this approach. :-)

Related

Run a post-signing script in Xcode 12

Xcode 12 performs a binary signing after all steps of the build have ended, including any custom post-build steps.
However I need to run a script to be performed after signing (e.g. for copying the signed binary elsewhere - but also for other things).
After having read a few StackOverflow questions and replies, I tried the following (separately):
Create an aggregate target with two subtargets that (1) performs the build & sign, (2) runs the final post build.
Use the scheme's build post-action to run the final post build.
Both don't work out of the box, and the problems are:
Aggregate target solution (if it worked): means that I have to create and maintain such a target for all of my many projects.
Post-action: does not appear in the build transcript, which makes it very cumbersome to detect errors. Moreover, a failure in the post-action does not fail the build - which is an absolute no-no.
In both cases the custom user definitions are not passed into any of the steps, which renders my script useless, as it relies heavily on those definitions.
Is there any proper solution to the seemingly trivial request for a post-sign action?
The workaround I found was this: As a post-build step, copy the binary elsewhere, perform any required operations on it, and then manually sign it.
Xcode will sign the original binary which is of no use to me.

How to Hide the source code in xcode?

I am writing an app using applescriptobjc in xcode, and while making the archive I see the source code is still inside the package, is there a way to hide it or transform it completely to binary code?
Thanks
I may be a year late to the discussion but I asked the same question around the same time as you did last year and hope that the answer I got will satisfy your own question. Here is an extract answer from
my own question:
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.
As you can see, a simple way to do this is:
Open your final AppDelegate.applescript file in Script Editor on the mac.
Select: File > Export...
2.1. Don't change the file name but override the archive file
2.2. BEFORE SAVING: Choose Run-only checkbox from the save options but leave the File Format as Script
Now your file cannot be opened in plain text as it is set to Run-only. Please remember that it is not a 100% read-proof solution, but works great for small projects (provided you are not rushing the final export and don't forget to perform the above mentioned steps before handing it over to the customer).
I hope you can make the most of this answer and still deem it useful. Let me know how you get on or whether you have any more questions. Perhaps you have since found a far better solution (or just an alternative), if so, I am still looking for the next best thing in source code protection.
In Xcode 9.2. (and maybe earlier versions) you can find under Build Settings the item OSACompile and can choose to compile to an executable only directly from Xcode.

How can I completely compile a bash project to be distributed?

I am trying to compile a bash project into a distributable binary. I tried shc, and it worked, except all my source statements were broken. I have numerous source statements to keep the code base cleaner, but they are broken when compiled with shc. How can I compile down my bash project so that instead of having a bunch of .sh files, the end user can just have one single file?
Shc is an obfuscator, not a compiler. At the end of the day, it still invokes /bin/sh or whatever, and feeds it your original script. It has not a slightest idea what your script actually does. If it needs an additional file to source, you have to supply it at an appropriate location.
You may want to investigate things like SHAR. Build anarchive, then compile it with shc if you want.
It sounds like all you're missing is a facility to expand all your source statements. That should be fairly easy to write if your codebase is fairly consistent in its use of those statements: just write a script to expand them inline and away you go.
Alternatively, just put all your scripts into a single Zip file or tarball and tell the user to extract the contents of that one file, or if even that is too much I'm sure you can imagine a way to encode the zipped contents of all the non-main files into a giant comment at the bottom of the main file, and have it extract what it needs before proceeding.
Or, you know, use the appropriate installer for your system. Build an RPM for RHEL or a Debian package or a Windows MSI or whatever....

XCode: Possible to specify CFBundleIdentifier per-build-configuration?

I just can't figure out how to do this.
I have a special Build Configuration alongside Debug and Release. (Let's call it Foo)
My CFBUndleIdentifier is com.my-company.our-project.
However, when I build (and archive) for the Foo configuration, I want to use the bundle identifier com.my-company.foo.our-project
Is this possible? Everything I've tried has failed.
I spend much of my day building a white-label product, so I have to do this all the time.
The solution we came up with was to use an Xcode "Run Script" build phase as a "postflight" script.
In your project file, select the target, Build Phases, and then add a new "Run Script" build phase. I renamed the phase to "postflight" and ensured to move the phase to be the last thing done amongst all the build phases.
The essential thing the postflight script does is look for the built .app package, look for the Info.plist within it, and then change the CFBundleIdentifier within it for whatever our present build configuration is set for. Our script does a lot more than just this (other logic, post-processing, resource manipulations, etc.).
I can't provide too many specifics since my setup is customized for me, and yours is obviously customized for you. But that's the basic approach. Hopefully it'll work for you.

How to Debug Following Fortran Program

I am trying to compile the following software so that I can step through and debug it. I am only a novice programmer and I am trying to understand how this whole makefile business works with Fortran. I know that there is a ton of literature on makefiles but I just need to insert a simple debug flag and I think if someone provided me with the answer to this question that would be the best way for me to learn.
So the program I am trying to compile, TINKER, is actually made up of several packages, located at http://dasher.wustl.edu/tinkerwiki/index.php/Main_Page. I would like to compile and debug JUST ONE specific executable, "analyze". I contacted the developer and received the following reply but I am still stuck...
Since TINKER has lots of small source code files, what we do is
compile each of the small files to an object file using the "-c" flag.
Then we put all of these object code files (ie, the ".o" files) into
an object library. Finally, we link each of the TINKER top level
programs, such as "analyze", against the object library. There is a
Makefile supplied with TINKER that does this. We also supply
individual scripts called "compile.make", "library.make" and
"link.make" for various CPU/compiler combinations that can be run in
order to perform the steps I describe above. To build a "debuggable"
executable, you just need to include the appropriate debug flags
(usually "-g") as part of the compile and link stages.
I am currently running OSX 10.6.8. If someone could show me which folders I cd into, what commands I enter that would be so great!
Thanks!
My follow up question (once I can figure out how to answer the above via command line will concern how to import the same procedure but using the Photran IDE - http://wiki.eclipse.org/PTP/photran/documentation/photran5#Starting_a_Project_with_a_Hand-Written_Makefile)
The directions are at http://dasher.wustl.edu/tinkerwiki/index.php/Main_Page#Installing_TINKER_on_your_Computer
Maybe out of date? g77 is obsolete -- it would be better to use gfortran.
The key steps: "The first step in building TINKER using the script files is to run the appropriate compile.make script for your operating system and compiler version. Next you must use a library.make script to create an archive of object code modules. Finally, run a link.make script to produce the complete set of TINKER executables. The executables can be renamed and moved to wherever you like by editing and running the ‘‘rename’’ script."
So cd to the directory for the Mac -- based on "we also provide machine-specific directories with three separate shell scripts to compile the source, build an object library, and link binary executables." Then run the command scripts. Probably ./compile.make. Look around for the directories ... you can probably figure it out from the names. Or search for the file "compile.make".
Or find someone local to you who knows more about programming.

Resources