0

so i want to write a pretty simple command line tool for my personal use on my jailbroken iPhone, that i can run over ssh or any terminal app locally on the phone. If possible i would like to use Xcode with apples new Swift language.
I see that with Xcode i can create a 'Command Line Tool', but only for macOS (obviously).
I have been looking at iphonedevwiki.net and iosopendev.com, but everything there seems very outdated.
I did also stumpled across this, but this looks pretty abandoned too...
Does anyone have a idea on how i can accomplish my project the easiest way? Thank you for your help in advance.

Blubberlase
  • 29
  • 1
  • 8
  • Even if this is possible, I'm not sure it would be worth the trouble. I recommend just compiling via command line. Set an alias like `igcc='xcrun -sdk iphoneos gcc -arch armv7 -arch arm64'`, then compile with `igcc -o tool *.c`, sign with `codesign -s - tool` and you're done. – Siguza Nov 10 '16 at 17:41
  • @Siguza Thanks, this works for compiling Objective-C code for my iPad. I would like to use Swift. Do you know how to compile a swift code via command line for my iPad? Using swiftc to compile for my MacBook works fine, but swiftc doesnt accept any -arch argument when i try to compile for my iPad. Thanks – Blubberlase Dec 04 '16 at 15:32

1 Answers1

0

I know your question is posted long time ago. But it's easy to use Xcode to develop iOS command line tool.

  1. Just create a iOS single view app.
  2. Delete all other files while those two files remain (info.plist & main.m).
  3. Write your code in main.m (if you are using c interface, change main.m to main.mm to support c/cpp interface).
  4. Compile it with iPhone attached, choose real machine (Don't use simulator).
  5. Now, check your Products/xxx.app, show in finder, then show package content. Find the executable binary file, which is the same name as xxx.app.
  6. Copy that executable binary file to a folder, sign the file if needed.
  7. Copy that executable binary file to your iPhone, the terminal command is this:scp xxx root@yourDeviceip:/usr/bin (or you can just copy it to your iPhone with some Mac software).
  8. ssh root@yourDeviceIp, cd /usr/bin, use this command:chmod +x xxx to give executable right to the file (xxx is fileName).
  9. Now, just use your command line tool like others.

For those who want to sign the executable binary file, you may want this:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>com.apple.springboard.debugapplications</key>
        <true/>
        <key>get-task-allow</key>
        <true/>
        <key>task_for_pid-allow</key>
        <true/>
        <key>run-unsigned-code</key>
        <true/>
        <key>platform-application</key>
        <true/>
    </dict>
</plist>

Save the content above as ent.xml in the same folder with your executable binary file, then use ldid to sign it to the file, command is:ldid -Sent.xml xxx

LQMIKU
  • 1
  • 3