Bring App to foreground
Yes, you can technically use Xcode for jailbreak development (but you don't have to). If you want your app to be installed outside the normal sandbox, and in /Applications/, then you'd build with Xcode without code signing, fake code sign (or use self-signed certificate), and then copy/install the app to your device, using scp
or something similar (maybe have a script for this).
You can google search on tools like "Theos", "Logos", or "iOSOpenDev", too. More here
Also, see this page for information about fake code signing with Xcode.
In terms of bringing an app to the foreground, there's at least a couple ways to handle that:
One would be to use Cydia to install the (free) utility open
. With open
, you can issue a command line call to open any app, by using its bundle ID (e.g. open com.mycompany.MyAppName
). If you want to do this programatically, issue that command within a system()
call:
#import <stdlib.h>
int returnCode = system("/usr/bin/open com.mycompany.MyAppName");
Another alternative is to see this answer by @WrightsCS. Make sure to read the comments, too, about where this goes.
Update: in terms of putting your app into the background, you can kill your app completely with either exit(0)
or [[UIApplication sharedApplication] terminateWithSuccess]
. Or, see this answer for a solution to programmatically simulate a home button press, which will send the app to the background without killing it.
You won't be able to use NSTimer
, because timers don't fire while your app is in the background. However, you can use GCD blocks to run your background work, and make the system()
call with open
to bring you back to the foreground.
See this answer, probably scrolling all the way to the bottom of his post
or look at this similar answer, which was actually posted at the bottom of the question
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.
NSTask or equivalent for iPhone
It wasn't removed in 3.0, it was never there. There is no way to run separate processes on the iPhone. GDAL appears to be under an MIT style license and has a library interface, so directly linking it into an iPhone app shouldn't have any legal or technical issues.
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)
How to remove iPhone app via command line
if you want to delete an application downloaded from an App Store you can do so right in the Springboard (on your iPhone). If you can't do that, you can delete it in a folder (/private)/var/mobile/Applications/ there are apps installed from App Store or synced. (in /Applications/ you will find Cydia, Camera, Safari, etc...)
To do so, you will first have to find out what is the "hashed" name of the Applications in that folder, because you won't find "InfinityBlade.app" in there, you will find some random letters and numbers.
You can also delete it by installing a program called iFile from the Cydia and then by checking in the settings "Show application names" or something like that and then again by going to (/private)/var/mobile/Applications/ where you should see now the real name of the applications and then simply delete it by the gesture "slide from left to right with your finger" and click delete.
Hope this works for you, it should work 100% ;-)
Update: This is a link where is sort of described what I meant with the iFile, just don't go into /var/stash/Applications but /var/mobile/Applications
http://www.youtube.com/watch?v=ftssbPYiBDw
Force app to close and run in background
You can force an iOS app into the background by sending a registered URL to another app to handle, such as a web site URL to Safari.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: myWebsiteURL ]];
Many many apps that call Safari to handle URLs are approved by Apple.
To get any time in the background, an app has to be appropriately configured using one of the allowed background modes (audio, location or VOIP); or the app can request a few minutes of extra time in the background before being suspended by calling the beginBackgroundTaskWithExpirationHandler method
Related Topics
How to Force My Keyboard to Be Up on My Program's Start in Swift
How to Control Shadow Spread and Blur
Macos on Vmware Doesn't Recognize iOS Device
Saving PDF Files with Swift in iOS and Display Them
iOS Avplayer Trigger Streaming Is Out of Buffer
Notify Watchkit App of an Update Without the Watch App Requesting It
Disable the Uitableview Highlighting But Allow the Selection of Individual Cells
Xcode & Swift - Detecting User Touch of Uiview Inside of Uiscrollview
How to Set the Title of a Navigation Bar Programmatically
Cellforitematindexpath Not Called But Numberofitemsinsection Does
How to Return Value After the Execution of the Block? Swift
React Native Change Default iOS Simulator Device
Width and Height Equal to Its Superview Using Autolayout Programmatically
Find Where Object Is Retained with Arc
iOS How to Asynchronously Download and Cache Images and Videos for Use in My App
iOS Tesseract Ocr Image Preperation
How to Obtain Country, State, City from Reversegeocodecoordinate