I'm currently building an app for jailbroken device, and I need root privileges for my app so that I can perform some tasks ask root. I found a related question : Gaining root permissions on iOS for NSFileManager (Jailbreak). But I am really new to iOS, I don't understand and unable to complete task from step 4. Can anyone make it more detail please?
What step 4 is telling you:
Open the original executable file and delete its contents (the contents are now stored in the previously copied and renamed binary).
is simply that you have moved the executable file for your app to a new filename, and you should replace it with a script with the name of the original executable.
Example
If you build an app named HelloWorld, Xcode will create a
HelloWorld.app
directory, with a file namedHelloWorld
inside it, which is executable.The answer you link to suggests basically renaming the executable to something like
MobileHelloWorld
.Once you've done that, create a new file in the
HelloWorld.app
directory calledHelloWorld
, and edit it with a text editor to give it this content:
#!/bin/bash
dir=$(dirname "$0")
exec "${dir}"/MobileHelloWorld "$@"
That script will then be run when you tap the app's icon, because in the app's Info.plist file, the name of the executable is
<key>CFBundleExecutable</key>
<string>HelloWorld</string>
and HelloWorld
is now a shell script, which invokes MobileHelloWorld
, the renamed binary executable file.
来源:https://stackoverflow.com/questions/16892795/how-to-gain-root-privileges-for-ios-app