Launch GUI app on iOS 5 through the command line (jailbreak)
Those launch
/launchctl
commands didn't work for me either. What did work was to install the command-line utilty open
from Cydia and just execute
open com.apple.calculator
Notice the lowercase c in calculator,
that was the bundle identifier for my calculator app.
Here's the developer's website for Cydia stuff:
http://kramerapps.com/cydia/
This links to the repo site:
http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=openData
Update: For iOS 6.x, this current version of open
doesn't seem to work. See @Nate's answer to another question linked below in the comments.
Update 2: The open
package in Cydia has been updated and now works with iOS 6.
Update 3: Here is the source for the package: https://github.com/conradev/Open.
If you look at the open.m
file, you can see that the function SBSLaunchApplicationWithIdentifier
from the SpringBoardServices
private framework is what actually opens the app.
Launch command line from jailbroken application ios 7
Thanks to others members and some search, I've found the answers to the 2 questions:
(Big thanks to @Nate for this repply), it's possible to use NSTask in ios by importing the header file into the application project. The syntax is the same as the use in mac os x application but you can find some help here
An app placed into /Applications/ haven't the admin rights. For doing this, you have to:
1) In the main() function add setuid(0);
and setgid(0);
2) Build the app normally.
3) If you build an app named HelloWorld, Xcode will create a
HelloWorld.app directory, with a file named HelloWorld inside it, which
is executable. Rename this executable to, for example, MobileHelloWorld
4) 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.
5) In terminal, navigate to the app bundle.
6) chmod 0775
the original executable file and chmod 6775
the copied
executable file.
7) Copy the app bundle to /Applications
to a device. Restart SpringBoard
and you should be good to go. If the app doesn't launch then repeat step 5
& 6 on the device.
For this questions, all credits goes to (again :P) @Nate (here) and @JonasG (here)
Opening application via ssh on iOS devices
You can do this with the open
utility that's available on the Cydia store. Download open
from Cydia, and then you can use it to start any installed app at the command line, using its bundle ID (e.g. com.mycompany.MyAppName).
See this answer
iOS: Deploy and run app on device through command-line without jailbreaking
You can run instruments on the command line to launch your app (and run your automated tests) in the simulator. From what I understand this works with a real device as well.
See this question for more information:
UIAutomation through command line on a real device
retrieve app's author - jailbreak iOS 6
I haven't yet jailbroken my iOS 6 device or run class-dump
on all the iOS 6 frameworks, so I can't tell you if there's another private API to do exactly what you used to be able to do.
Your suggestion about inspecting the contents of app folders (e.g. /var/mobile/Applications/*/*.app/
) and reading the iTunesMetadata.plist files sounds reasonable. Reading each app's Info.plist would also give you the CFBundleIdentifier
, which would normally at least contain the publisher's domain name (e.g. com.mycompany.MyAppName
).
For apps that don't come from the app store (and don't have iTunesMetadata.plist), you could try another technique (in addition to reading Info.plist):
Cydia packages are maintained with dpkg
utilities. You can list all installed packages with the command dpkg -l
. You can invoke this command either with
system("dpkg -l >> /tmp/output.log 2>&1");
piping the output into a temporary file, or with NSTask
. NSTask
is part of OS X APIs, and is not in the iOS public APIs. But, if you add the NSTask.h header to your project yourself, you can certainly use it as a private API in a non-App Store app, to run a command and capture output programmatically.
At the command line, running dpkg -l
would give you:
ii libhide 2.1 Library to hide icons. If you are a developer wanting to use this library, code samples included in /usr/lib
ii libxml2-lib 2.6.32-3 represents the library for libxml2
ii lsof 33-4 shows what files programs have open
ii lzma 4.32.7-4 slower, but better, compression algorithm
ii make 3.81-2 dependency-based build environments
ii mobilesubstrate 0.9.3999.1 powerful code insertion platform
ri ncurses 5.7-12 feature-complete terminal library
ii network-cmds 307.0.1-6 arp, ifconfig, netstat, route, traceroute
so, your app could parse that output, to read package names from the second column.
Then, you could use the apt-cache show
command to get the information from the package's DEBIAN/control file, which would have something like this:
iPhone-3G:~ root# apt-cache show sqlite3
Package: sqlite3
Version: 3.5.9-12
Architecture: iphoneos-arm
Maintainer: Jay Freeman (saurik) <saurik at saurik dot com>
Installed-Size: 348
Pre-Depends: dpkg (>= 1.14.25-8)
Depends: sqlite3-lib
Replaces: sqlite3 (<= 3.5.9-11)
Filename: debs/sqlite3_3.5.9-12_iphoneos-arm.deb
Size: 71928
MD5sum: 6d47c112692ac00af61bd84e3847aa42
Section: Data_Storage
Priority: standard
Description: embedded database used by iPhoneOS
Name: SQLite 3.x
Tag: purpose::library, role::developer
I know this is more work than just using author
from SBApplication
, but maybe it's good enough? Hopefully, some one else will chime in with another answer ...
Related Topics
Uitextfield in Uialertcontroller (Border, Backgroundcolor)
Aes/Cbc/Pkcs5Padding in iOS Objective C Result Differs from Android
Playing Back Audio Using Avaudioplayer iOS 7
Error: Cuicatalog: Invalid Asset Name Supplied: (Null), or Invalid Scale Factor:2.000000
Dial a Phone Number with an Access Code Programmatically in iOS
Modify Uiimage Renderingmode from a Storyboard/Xib File
Ios: Capture Image from Front Facing Camera
Uiview's Border Color in Interface Builder Doesn't Work
Xcode 4: Creating a Uiview Xib, Not Properly Connecting
Custom Cordova Plugin: Add Framework to "Embedded Binaries"
Google Places Autocomplete on iOS - Can't Load Search Results - Try Again
Parse Multipart Response for Image Download in iOS
Why Is This Code Not Recognising the Nsstring as Being Equal
Back Button Callback in Navigationcontroller in iOS
Uicollectionview Insert Cells Above Maintaining Position (Like Messages.App)
How to Disable Horizontal Scrolling of Uiscrollview
Detect If the Application in Background or Foreground in Swift