How to strip a macOS app to remove debug information? - macos

stripis a unix command to remove all the debug information from an executable, or other information that is not needed for execution. Is there a way to "strip" a macos app to make it smaller and make reverse engineering more difficult? I tried viewing package contents, and striping /macOS/MyGame executable, but then it claimed that it messed it up, and then refused to launch. How do I strip it without "invalidating the code signature" I already asked and I need help.

What is your purpose?
If you plan to distribute the app then using XCode's archiving options is the way to go.
strip command works in MACOS.
Here is a useful script:
https://gist.github.com/neonichu/1662881

Related

Debug xv6 on mac with CLion

I've looked through the internet and searched for solution for debugging xv6 on mac with CLion and didn't find one. as you know it's difficult (or maybe impossible, I didn't succeeded anyway) to make gdb work on macOS.
So, how can I do it? How can I debug xv6 with CLion on macOS?
NOTE that in order to be able to debug xv6-riscv you will need to use riscv64-unknown-elf-gdb instead of gdb
as following:
run make qemu-gdb clean in terminal (in the project's directory of course), pay attention for the port, it may be different for some reason, for me it was 25501.
All I needed to do is the following:
kernel is good for debugging proc.c, if you want to debug other file, (i.e. sh.c) you should put _sh instead.

Why is NSFileWrapper setting the quarantine bit in Sandbox

I can't figure out why my calls to NSFileWrapper's addRegularFileWithContents:preferredFileName: is setting the files quarantine bit (as seen when using xattr -l on the file) when in the sandbox only. My app saves files in the document bundle so this I think is the method I need to use but the quarantine bit is driving me crazy.
Maybe this is a feature of some sort but my app also chmod's these files as executable and runs them as shell scripts using NSTask. However with the quarantine bit on I get errors from the bash shell (this has been well documented on stack overflow).
Has anyone else experienced this and do you know if these are bugs or features? The only way to work around it for now is to know the shell of the file in advance and not rely on the interpreter at the top of the file (i.e. #!/usr/bin/php) but this an annoying hack to work around a problem that shouldn't be.

Mac SDL+OpenGL App refuses to launch from anything but terminal

We've got a fairly mature cross-platform game engine which we've had running on OSX for several years now without a hitch; we recently upgraded the game from SDL 1.2.15 to 2.0, and at some point in the conversion, I goofed something up and now we have a bizarre problem where the app launches just fine from the terminal, but when you launch the app from a double-click in the Finder, it just bounces once in the dock and just goes away.
We're baffled because insofar as I can tell, there's only a one-liner being printed in Console.app: Exited with code: 255 (naturally running from the terminal doesn't help here because we can't reproduce the problem there; the app runs fine when launched in a terminal).
So the only thing we can figure is it's either something we're goofing up in our main.cpp, or something we've hosed in how I set up the dylibs/frameworks. It's also possible that it's something to do with the working directory not being set right, but to the best of my abilities, I believe we're doing it right (regardless of your current working directory; the app attempts to forcibly set said directory to be in the Resources folder - this was necessary to get the game to launch, but I don't know if we're doing it wrong). This feels like a somewhat awkward fit for stackoverflow, for which I apologize, since it's not a simple "paste this code and ask what's wrong" job. I have two ways for you to reproduce it; firstly we are an open-source project, and you can get our source code (complete with a mac project file and all dependencies included in the repo, set up and ready-to-go exactly as I've perhaps erroneously created them), at our github page. The one change you'll need to do is open a file at the root level, named master-config.cfg, and remove the // comments from it (so the engine knows you want to launch a simple demo game shipped with the engine).
Alternately, I have a stripped down (~15mb zipped) binary you can directly download and try to run, if that's sufficient to diagnose the problem.
As said before, we're open-source, so we welcome any pull-requests for fixes!
You need to write a minimal Cocoa wrapper so that OS X will not SIGKILL you for not launching properly. I will give you a pull request with that wrapper.

OSX - How to debug distributed builds?

I sent my first desktop OSX app out to a small circle of testers today. One user cannot get past the splash screen.
I am wondering how one might debug something like this? Would I somehow write NSLogs to a file? Or does OS X have some sort of utility? I assume I need some sort of logging capability, right?
You can write your logs to file quite easily (not via NSLog, but just plain writing NSString to disk via writeToFile if you want to). You can also have your logs automatically uploaded to your server if you have one using NSURLConnection with a POST.
I prefer the latter because it requires little intervention from the testers, and happens automatically.
Distribution builds are not ment to be debugged or else it would have been development build.
You can how ever sync your device with itunes and then get the crash report(if you want to know the source of crash).from appdata.
reffer to this link. if you want to debug make a debug build with development provisoning. in your case ask the tester to send you the crash report and you keep the ipa or app file safe you will need it to read the crash report.

Scripting Bridge and Apple Mail

I'm am getting ready to attempt to implement Scripting Bridge for the first time, specifically to allow my program to construct and send emails to individual (or all) members of an opt-in email database.
Unfortunately, I'm already stuck on the first step... creating the Mail.h file.
According to Apple's documentation:
To create a header file, you need to run two command-line tools—sdef and sdp—together, with the output from one piped to the other. This is the recommended syntax:
sdef /path/to/application.app | sdp -fh --basename applicationName
However, when I attempt to execute this, I receive the following errors:
-bash: sdef: command not found
-bash: sdp: command not found
My guess is that I'm trying to execute programs that are (clearly) not installed on my system, which is a MacBook Pro running Lion (10.7.4)
A quick google search turned up an older version of sdef for v10.4, but I'm now wondering: Is this process still the recommended procedure, or is there another way I should be generating a Mail.h header file? Apple's documentation is rather vague on this point.
Any help would be appreciated.
After some additional research and experimentation, I was able to get everything working by allowing XCODE to create the header files, rather than doing it manually from the command line.
XCODE also uses the sdp and sdef commands, but had no problem accessing them. I am still not entirely certain why I could not run the commands in the bash shell, but I suspect they must be run from the root user perhaps?
In any event, here is a link to the Apple Documentation which outlines the steps I took to get everything working correctly:
https://developer.apple.com/library/mac/#samplecode/SBSystemPrefs/Listings/ReadMe_txt.html
You should be able to use sdef and sdp after installing the command line tools. These are an optional install since XCode 4.3.
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html#//apple_ref/doc/uid/1006-SW2

Resources