I’ve been experimenting with obfuscation for Assembly-CSharp.dll on Android and iOS.
For Android it was quite simple.
- extract the dll from the apk
- obfuscate it
- put it back in the apk
- re-sign it
For iOS it proved to be much more difficult. After Unity generates the XCode project, there is a corresponding .dll.s file for every managed .dll. After lots of googling I found that these .dll.s files are generated from the .dll files by a tool named mono-xcompiler. This tool is invoked by Unity during the build process.
So my strategy was:
- let Unity build an XCode project
- remove the old Assembly-CSharp.dll.s from Libraries/
- obfuscate Data/Managed/Assembly-CSharp.dll
- generate a new Assembly-CSharp.dll.s from the obfuscated Assembly-CSharp.dll using mono-xcompiler which comes with Unity
- let XCode build the app
However, building the app fails while XCode tries to compile Assembly-CSharp.dll.s into Assembly-CSharp.dll.o.
I don’t have access to the build environment atm, so I can’t give you the exact CompileC command, but the error was something like
/path/to/Assembly-CSharp.dll.s:[numbers]:[number]: error: invalid symbol redefinition
plt__class_init_____:
^
/path/to/Assembly-CSharp.dll.s:[numbers]:[number]: error: invalid symbol redefinition
plt__class_init_____:
^
/path/to/Assembly-CSharp.dll.s:[numbers]:[number]: error: invalid symbol redefinition
plt__class_init_____:
^
I suspect one of the following:
-
I used Eazfuscator.NET to obfuscate the Assembly-CSharp.dll on Windows, however the file was surrounded only by iOS-versions of dependency DLLs so it should be fine. Still, it might be a problem.
-
I might have used mono-xcompiler in a wrong way:
export MONO_PATH=[xcode-project]/Data/Managed
export GAC_PATH=[xcode-project]/Data/Managed
export GC_DONT_GC="yes please"
mono-xcompiler --aot=full,static,nodebug,asmonly,outfile="../Libraries/Assembly-CSharp.dll.s" "Managed/Assembly-CSharp.dll"
- mono-xcompiler or .dll.s-files might be unable to handle an obfuscated .dll. This would totally suck.
Any ideas? Any information about mono-xcompiler or .dll.s that might be helpful?
Can you assist me in running these lines. I don't know how to start. Where do i have to put these. It doesn't look like regular terminal commands: export MONO_PATH=[xcode-project]/Data/Managed export GAC_PATH=[xcode-project]/Data/Managed export GCDONTGC="yes please" Thanks, Peter. :-)
– TriplePAF