How to gain root privileges for iOS app? - ios

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 named HelloWorld 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 called HelloWorld, 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.

Related

How to move a file 'to a directory that's on your PATH'?

Im trying to install a JSON formatter for Cucumber but am having trouble configuring it. The steps (listed here) go like this:
1. Download cucumber-json-formatter-darwin-amd64 and rename it to cucumber-json-formatter
2. Move it to a directory that's on your PATH
3. Make it executable with chmod +x cucumber-json-formatter
4. Verify that you can run it: cucumber-json-formatter --help
I have the file downloaded and renamed correctly. However, I am stuck on the second step of moving it to a directory thats on my PATH.
Doing some research, I know what the folder structure looks like but I'm not sure exactly what the step is instructing. How would I achieve this step? Can it be in ANY directory on my PATH? I am currently using a Mac if that makes any difference for the solution.
Move it to a directory that's on your PATH
PATH refers to the machine's environment variable named PATH. Any time the OS is asked to execute something PATH is searched.
On Windows open System Properties dialog, click Environment Variables button and Path is listed there. You can add a new entry for the location of cucumber-json-formatter or you can move it to an existing Path entry.

iOS build script fails on defaults read command

I have an iOS app with a Build phase script that reads a plist file using the following command:
defaults read "/full/path/to/plist/file" CFBundleExecutable
...but it fails with the following error message:
The domain/default pair of (/full/path/to/plist/file.plist, CFBundleExecutable) does not exist
The full path of the file is correct and I double checked that the file indeed contains the key CFBundleExecutable. I also tried with other keys such as CFBundleName. Running the command both with and without .plist at the end of the full path fails.
I also ran the command in Terminal to see if it works generally, but the command fails there as well.
It turns out that macOS (or the defaults command line tool) seems to have a bug. Folders that are "special" such as Documents and Desktop act differently within the command line environment and as such I observed the following:
If Info.plist is located in a subfolder of Desktop or Documents the defaults read command will fail
As soon as you place Info.plist in any other folder (such as a Developer folder) the same defaults read command will succeed
I am not sure if this is due to the fact that both of these folders require special permissions (macOS asks if an app requests access to either of these) or if it is because they are part of iCloud Drive and perhaps there is some weird symlinking in the background.
Either way, if you run into a similar error, just try to place your project in a subfolder of ~/Developer (or any other non-default, non-special folder).

Xcode .bundle and .dylib

Is there a way to combine .bundle and .dylib into one file. I have written a tweak and a preference bundle for it. How do I have them to be installed as one?
you have to pack all the tweak files in a DEB package
for example create a directory named Tweak
and inside it create another directory named DEBIAN in debian directory create a text file called control
inside control
Package: com.example.tweak
Name: Tweak
Version: 1.0
Architecture: iphoneos-arm
Author: Sull <email#email.com>
Depiction: http://yourdepiction.com/example
Description: Example description here.
Homepage: http://example.com
Maintainer: Sull <email#email.com>
Section: Tweaks
*When done editing your control file, go to the end of the last line and press the enter/return key, now save the file. You always have to go to the last line and press enter or you'll run into errors when building.
as you said you have a Preferences bundle and a Dylib so the Tweak directory should look like this
/Tweak
----/DEBIAN
--------/control
----/Library
--------/MobileSubsttrate
------------/DynamicLibraries
----------------/tweak.dylib
----------------/tweak.plist
--------/PreferenceLoader
------------/Preferences
----------------/tweakPref.plist
--------/PreferenceBundles
------------/tweakPref.bundle
now run the command dpkg -b /Tweak in terminal
Assuming the Tweak folder is in root
You can ignore these warnings they are completely normal.
warning, Tweak/DEBIAN/control' contains user-defined fieldName'
warning, Tweak/DEBIAN/control' contains user-defined fieldAuthor'
warning, Tweak/DEBIAN/control' contains user-defined fieldSponsor'
dpkg-deb: ignoring 3 warnings about the control file(s)
there will be a file named Tweak.deb you can install it to the iPhone via terminal or apps like iFile

Get XCODE to Copy run script converted files to iOS resources bundle?

I have a script which converts wav files to caf files, and I'd like to get them copied to my iOS app automatically. The script looks like this:
Xcode doesn't copy it automatically, and i can't find a way to add it to my Copy Build Phase section. It appears that I need to add a line in the script to copy it directly to the app bundle, or to make the destination the app bundle itself.
What would that script/change be? I'm not sure what shell vars to use for the cp command.
Thanks - Henry
The environment variable you're looking for is "BUILT_PRODUCTS_DIR" and you can find the definition of this, and plenty of other useful Xcode-specific environment variables on this handy Apple documentation page.
And what you'd probably want to do is test for the existence of successfully converted files, and if they exist, then copy those files into the "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}" directory.

Chrome Cordova Translation Issue

Im trying to translate my chrome app to ios. I run the command cca create myapp --copy-from=manifest.json Some errors exist cp: copyFileSync: could not write to dest file (code=ENAMETOOLONG): $PATH_TO_PROJECT/project/platforms/ios/www/platform/..../www/platform/config.xml
where .... is 40 repeated directories of /www/platform
The translation succeeds and im able to run my project with android however, when trying to run in xcode i see an almost identical error saying File name too long.
Anyone have simmilar issues? Anyone able to get ios translations to run?
This is the result of a bug in the way we "import" your project when you specify --copy-from or --link-to arguments to cca create when your import directory is the same as your output directory.
Since the import in your example is a parent folder of the output, it copies itself over and over, recursively until the system kills the process. We have added protection against doing this (by warning during cca create if we detect this case), but that version hasn't released to npm just yet (sorry!).
The fix for the issue is simple: just create your project in another directory that is outside of your packaged app! i.e., either:
# From within packaged app directory
cca create ../myapp --copy-from=./manifest.json
or
# From outside packaged app directory
cca create myapp --copy-from=$APP_DIR/manifest.json

Resources