Hey, do you know Alfred app for Mac that can help you to control iPhone using your Mac computer? Have you ever thought about launching apps on your iPhone (iPad or iPod Touch) from the Mac? Because I thought about that, that’s why I browsed the net and found that it was possible. All you need is to be acquainted with SSH and OpenSSH. Also you need to know how to use Python for scripting. I show you how to give commands in command line to launch apps and restart SpringBoard on iPhone from your computer using Alfred app for Mac. Alfred-app-for-Mac 0 So before we start let’s see what you need before using Alfred app for Mac on your computer.

Requirements

  • Jailbroken iPhone if you need jailbreak the use Absinthe tool and perform jailbreak quick.
  • OpenSSH allows Mac to give commands to you iPhone. If you need to install OpenSSH use this link that will help you to do it.
  • APT 0.7 Strict, go to Cydia => Manage => Packages and there it must be installed. It’s for increasing amount of commands that you can give.
  • Install Python on iPhone  - Java library for scripting SSH sessions. You can make scripts for commands. You need these scripts because each of it gives you root access to iPhone. So you need to use Python to write scripts.
  • Mac

How to Launch Apps on iPhone Using Alfred App for Mac

Step 1. Download Alfred app for Mac for free. Step 2. Now download these two files: enchanter-core-0.6.jar enchanter-python-0.6.jar Step 3. Copy these files on your Mac here:
/System/Library/Java/Extensions/
Note: You may need to enter password to pass authentication in your Mac. Step 4. Create a directory to keep your scripts for Python. For example you can call it control-iphone and put ~/control-iphone/script.py into Alfred extensions. Note: Each iOS device must use different scripts so you need to create a folder for each of them. Well, the main part of this tutorial has just begun. Now I will show you how to create a script. I took as an example to show you how to make Respring script to restart Springboard.

How to create a script to use Alfred app for Mac

Step 1. Use TextWrangler (or BBEdit if you have) to create a new file called
respring.py
and save it in control-iphone folder you have previously created. Open this file and will see this:
conn.connect("highPhone.local", 22, "root", "alpine");
conn.waitFor("root# ");
conn.sendLine("killall SpringBoard");
conn.waitFor("root# ");
conn.sendLine("exit");
conn.disconnect();
Step 2.  Put your iPhone details in the first line. It can be IP address of your iPhone or its local domain.
  • It is very good if you now the iPhone’s name. But what is really great if it doesn’t have spaces. For example, myiPhone.local.
  • Now put SSH port number which is 22.
  • Also you need to put root name which you used to login as a root and root password. As you may know, the root password is alpine if you didn’t change it. If you want to change it the go here and change your root password.
Step 3. Now you need to use Terminal. Open Terminal and type this:
 ssh root@your_iPhone_ip_address
and press Enter. Type your root password (then type Yes if needed). Note: When you see DNS Spoofing warning - remove known_hosts file in ~/.ssh and try again Step 3. Step 4. If you see myiPhone:~ root# it would be meant that you may send commands. Step 5. Type this command to respring:
killall SpringBoard
After that the new root# will appear. You can use myiPhone:~ root# or root#, it doesn’t matter. Now you can add exit command to close the SSH session. Step 6. Now you need to create Alfred Extension. Launch Alfred app for Mac and go to preferences. alfred app for mac 1 To create an extension just click on Shell Script feature and you can call it iPhone Respring. Step 7. Now you need to change the icon; just drag and drop a image file onto the icon. You can locate a collection of images here:
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
Step 8. Now click the Create button. Also you can write a title and a description and make sure the checkbox for Silent and Action is unchecked. Step 9. To verify if everything is all right the command should be like this:
java -jar /System/Library/Java/Extensions/enchanter-python-0.6.jar ~/alfred-iphone/respring.py”
alfred app for mac You can try it in new Terminal window without log in trough SSH. Save your just created extension. Step 10. Now create AppleScript extension to add Growl support. Just paste a code below before extension:
try
tell application "Growl"
set the allNotificationsList to ¬
{"Alfred iPhone"}
set the enabledNotificationsList to ¬
{"Alfred iPhone"}
register as application ¬
"Alfred iPhone" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Terminal"
end tell
end try
Step 11. Now you need to launch Python. Just add this:
do shell script "java -jar /System/Library/Java/Extensions/enchanter-python-0.6.jar ~/alfred-iphone/respring.py"
tell application "Growl"
notify with name ¬
"Alfred iPhone" title ¬
"Success!" description ¬
"You have successfully restarted your iPhone SpringBoard." application name "Alfred iPhone" image from location ¬
"file:////System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.iphone-4-black.icns"
end tell
Note: Use AppleScript Editor which is on your Mac to create, compile and rut this script. You can use this editor to write every script you want. For example to update or upgrade Cydia sources write ‘apt-get update’ or ‘apt-get upgrade’. So it can be extended by adding Cydia packages for command line. Also you can open any url in Safary. Just type this:
openURL 
or launch app adding this:
launch com.Apple.Calculator
Take a look how to write launchcalculator.py to use it with Python:
conn.connect("highPhone.local", 22, "root", "alpine");
conn.waitFor("root# ");
conn.sendLine("launch com.Apple.Calculator");
conn.waitFor("root# ");
conn.sendLine("exit");
conn.disconnect();
If you know how to use AppleScript editor you can easily add Alfred query options to the extension. So if you named your extension Respring you have query options for iPad and iPhone just like you have extension called iPhone with such query options as respring, reboot, update. Take a look at queries examples which Alfred AppleScript Extesion use:
on alfred_script(q)
try
tell application “Growl”
set the allNotificationsList to ¬
{“Alfred iPhone”}
set the enabledNotificationsList to ¬
{“Alfred iPhone”}

register as application ¬
“Alfred iPhone” all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application “Terminal”
end tell
end try
if q is “respring” then
do shell script “java -jar /System/Library/Java/Extensions/enchanter-python-0.6.jar ~/alfred-iphone/respring.py”
tell application “Growl”
notify with name ¬
“Alfred iPhone” title ¬
“Success!” description ¬
“You have successfully restarted your iPhone SpringBoard.” application name “Alfred iPhone” image from location ¬
“file:////System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.iphone-4-black.icns”
end tell
else if q is “update” then
tell application “Growl”
notify with name ¬
“Alfred iPhone” title ¬
“Updating” description ¬
“Looking for new Cydia packages.” application name “Alfred iPhone”
end tell
do shell script “java -jar /System/Library/Java/Extensions/enchanter-python-0.6.jar ~/alfred-iphone/update.py”
tell application “Growl”
notify with name ¬
“Alfred iPhone” title ¬
“Success!” description ¬
“You have refreshed your Cydia updates.” application name “Alfred iPhone” image from location ¬
“file:////System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.iphone-4-black.icns”
end tell
else if q is “upgrade” then
do shell script “java -jar /System/Library/Java/Extensions/enchanter-python-0.6.jar ~/alfred-iphone/upgrade.py”
tell application “Growl”
notify with name ¬
“Alfred iPhone” title ¬
“Success!” description ¬
“You have updated your Cydia packages.” application name “Alfred iPhone” image from location ¬
“file:////System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.iphone-4-black.icns”
end tell
end if
end alfred_script
So as you see you can create your own scripts to us Alfred app for Mac and launch iPhone apps. I hope it was not difficult for you. But if it was then let me know using comment section below and I’ll try to help you. All you need is to be acquainted with Terminal, OpenSSH and have basic knowledges of SSH clints . Update: You can also use the link to find out how to use Alfred app snippets on your Mac.