when I run strings against main executable I get the unwanted strings.
OK. Consider this:
-
Using Xcode 13.1, I created a new project from the iOS > App template (I assume you’re targeting iOS here), selecting the simplest options (Storyboard, Objective-C).
-
I did a Product > Archive to create a release build.
-
I use the Xcode organiser to export that.
-
I unpacked the .ipa
.
-
I poked at the main executable with strings
:
% strings Test676234.app/Test676234 | grep quinn
%
My home directory path is /Users/quinn
, meaning that there are no home directory paths encoded in my app.
So, this doesn’t happen always, which means there’s something about your project that’s triggering it. Tracking that down can be tricky. To explore this, I added the following to the app’s main
function:
printf("%s\n", __FILE__);
I now get a hit from strings
:
% strings Test676234.app/Test676234 | grep quinn
/Users/quinn/Desktop/Test676234/Test676234/main.m
To debug this further I used the Write Link Map File build setting (LD_GENERATE_MAP_FILE
) to enable a link map. I then went through the Product > Archive cycle again, which created a link map file Test676234-LinkMap-normal-arm64.txt
. In that file I see this:
0x100007F67 0x00000032 [ 3] literal string: /Users/quinn/Desktop/Test676234/Test676234/main.m
The [ 3]
indicates that this string literal came from the third .o
file. At that top I saw this:
[ 3] /Users/quinn/Library/Developer/Xcode/DerivedData/Test676234-ajppxbraomjtoldtyvugwlwsxkqv/Build/Intermediates.noindex/ArchiveIntermediates/Test676234/IntermediateBuildFilesPath/Test676234.build/Release-iphoneos/Test676234.build/Objects-normal/arm64/main.o
confirming that this is main.o
, which the output from building main.m
.
Now, this is an easy case, where the string is passed as a string literal to the linker. That’s not always going to be true:
-
In some cases the string might be embedded in a large block of code or data that’s passed to the linker. You can track that down by finding the offset of the string in the file, mapping that offset to an address (using the segment info printed by otool -l
), and then finding that address in the link map.
-
In some cases the string might be in segments actually generated by the linker. I don’t have any quick suggestions for how to deal with that case.
Still, my general advice here holds: First find where the string is coming from, then try to track down the relevant knobs to twiddle in order to disable it.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"