Installation
Step 1: Prerequresites
An iOS project with the MobileProtect SDK installed.
Step 2: add obfuscation build phases
Step 2.a: Build phases for projects with Cocoapods
For projects that use Cocoapods, add the following line to each target that is defined in the Podfile:
script_phase({name: "Data Theorem Static Obfuscation", script: "$PROJECT_DIR/datatheorem-obfuscate", execution_position: :after_compile})
For example:
target `MyApp` do pod 'Pod1' pod 'Pod2' script_phase({name: "Data Theorem Static Obfuscation", script: "$PROJECT_DIR/datatheorem-obfuscate", execution_position: :after_compile}) end
And add these lines at the end of the Podfile:
post_install do |installer| installer.pods_project.targets.each do |target| target.new_shell_script_build_phase("Data Theorem Static Obfuscation").shell_script = "$PODS_ROOT/../datatheorem-obfuscate" end end
Step 2.b: Build phases for projects without Cocoapods
For projects that do not use Cocoapods the build phases must be created manually. For each target in the project (app/framework), add a Run Script
build phase named Data Theorem Static Obfuscation
as the last build phase, containing the following script:
$PROJECT_DIR/datatheorem-obfuscate
Step 3: add the obfuscator binary
Place a copy of the datatheorem-obfuscate
binary at the root of the project folder (next to the project's .xcodeproj
or .xcworkspace
files).
Step 4: configuration
In the project's MobileProtect.config, add a key called StaticObfuscation
of type Dictionary
, and a child key Enabled
of type Boolean
that is set to YES
.
Finally clean the project once. Installation is now complete - the application will be statically obfuscated when it is next compiled.
Setup of static obfuscation is now complete.
Optional Configuration
The following configuration keys are supported:
Enabled
: a boolean value, set toYES
to enable static obfuscationClassExcludeList
: a path, relative to the project root, to a newline-separated list of class names, the selectors of which will be excluded from static obfuscationSelectorExcludeList
: a path, relative to project root, to a newline-separated list of selector names to exclude from static obfuscation
Excluding required selectors
Projects that refer to selectors directly will need to exclude these selectors from obfuscation, otherwise the app might crash. Selectors are referred to directly:
using the
@selector(...)
syntaxwhen using reflection
when using key-value observation
A typical crash due to obfuscation of required selectors looks like:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SomeClassName someSelector]: unrecognized selector sent to instance 0x123abc123'
To fix such a crash, either the class SomeClassName
must be added to a class exclude list (see the ClassExcludeList
configuration) or the selector someSelector
must be added to a selector exclude list (see SelectorExcludeList
).
Sometimes, the error will mention the obfuscated selector name, e.g.:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SomeClassName XJEJKANDFKW]: unrecognized selector sent to instance 0x123abc123'
In this case, the corresponding (non-obfuscated) selector can be determined from the mapping file.