1

I wrote a launch.plist for daemon and put it into /Library/LaunchDaemons/ (iOS 6.1.3) when I try to unload/load daemon from my UIApplication with this code:

system("launchctl unload /Library/LaunchDaemons/launch.plist");
system("launchctl load /Library/LaunchDaemons/launch.plist");

not works (I haven't warning/error output from console) but if I can to unload/load it from ssh works correctly.

The same code works perfectly on iOS 5.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    You need to be root in order to launch daemons with launchctl. – creker Jan 04 '14 at 14:32
  • Thanks for reply! Yes I know and app has root privilege, in fact it works correctly on other device with iOS 5 :( – user3025315 Jan 04 '14 at 15:49
  • Check out the answer here http://stackoverflow.com/questions/9749760/install-app-into-jailbroken-ios-roots-applications-folder These steps are necessary if you want to launch application from SpringBoard with root privileges. – creker Jan 04 '14 at 17:09
  • My app works except for launch daemon. I use this code: `-(void) launchctlDaemon{ NSLog(@"launchctl start"); system("launchctl unload /Library/LaunchDaemons/launch.plist"); system("launchctl load /Library/LaunchDaemons/launch.plist"); NSLog(@"launchctl end"); }` And this is the console output: `iPad : launchctl start iPad : launchctl end` No error and no app crash – user3025315 Jan 04 '14 at 17:18
  • 1
    `system` function has return value which will tell you if there is an error. Empty console doesn't mean there is no error. As for your app, SpringBoard can't launch apps with root privileges, even is you set them using `chown`. Your app will work but without root privileges. I provided you with the link that tells you what you need to do. I don't how it worked on iOS 5 but on any iOS version these steps are necessary if you want to launch apps from SpringBoard with root privileges. And without root privileges you can't use launchctl. – creker Jan 04 '14 at 20:59
  • I tried your solution but same result... The app works but no launchctl. – user3025315 Jan 05 '14 at 11:41
  • system("killall -9 SpringBoard") works but launchctl no... Any other solution? – user3025315 Jan 06 '14 at 12:03
  • 'killall' works even without root. Try to use 'kill' - it doesn't work without root. Also try to emulate what your application does in the terminal. If it works then it's definitely have something to do with privileges. Your code is fine, I use this exact same code in my applications on iOS 6. – creker Jan 06 '14 at 14:59
  • This is launch app: `-rwxr-xr-x 1 root wheel` and this launched app: `-rwsr-sr-x 1 root wheel` Maybe i have to install any package from cydia? – user3025315 Jan 07 '14 at 21:00

0 Answers0