iOS Daemon app will not start (Jailbreak) - how to debug?

≯℡__Kan透↙ 提交于 2019-12-03 03:37:49

As I said in my comment, first try to make sure your daemon executable is runnable:

  1. login to your device as root, via ssh
  2. execute the command /Applications/NoUIDameon.app/NoUIDaemon at the command line
  3. check to see if it's running with ps -Aef | grep NoUIDaemon

If it's not running, I would check to make sure that your build process is fake code-signing the NoUIDaemon executable. Jailbroken phones don't require a valid signature, but they still do require a signature. Also, if it doesn't run (or stay running), it might help for you to post the code from your daemon's main program (e.g. main.m):

int main(int argc, char *argv[]) {
   // what's in here?
}

If that does work, and it runs when you start it manually (but not automatically), then check:

  1. is the plist file above named dmn.NoUIDaemon.plist?
  2. I think this is actually an error in Chris's blog, but the Label value in your plist should be <string>dmn.NoUIDaemon</string>, not <string>dmn.NoUIDaemon.plist</string>. I don't think this would prevent your daemon from running, I think it's just being consistent with the naming convention of system launch daemons.
  3. I don't think just installing the plist file in /System/Library/LaunchDaemons is enough to start the daemon. You probably need to either reboot the phone, or manually launch the daemon with launchctl load -w /System/Library/LaunchDaemons/dmn.NoUIDaemon.plist
  4. check to make sure the file permissions and ownership of your dmn.NoUIDaemon.plist are the same as the other launch daemon plists in /System/Library/LaunchDaemons.
  5. I'm not sure if this is necessary, but I think the name of the daemon (the Label and the name of the plist file) are supposed to match the bundle ID specified in your NoUIDaemon-Info.plist file. So, the Info.plist should have:
    <key>CFBundleExecutable</key>
    <string>NoUIDaemon</string>
    <key>CFBundleIdentifier</key>
    <string>dmn.${PRODUCT_NAME:rfc1034identifier}</string>

or

    <key>CFBundleExecutable</key>
    <string>NoUIDaemon</string>
    <key>CFBundleIdentifier</key>
    <string>dmn.NoUIDaemon</string>

Update:

Also, I don't think your daemon's main program should have a call to UIApplicationMain. It's not supposed to be a UIApplication. It's supposed to be a background process, right? If you look on Page 1 of Chris's blog, it shows an example. Here's an example from one of mine:

int main(int argc, char *argv[]) {
   @autoreleasepool {
      SignalMonitor* daemon = [[SignalMonitor alloc] init];

      // start a timer so that the process does not exit.
      NSTimer* timer = [[NSTimer alloc] initWithFireDate: [NSDate date]
                                                interval: 1.0
                                                  target: daemon
                                                selector: @selector(setup:)
                                                userInfo: nil
                                                 repeats: NO];

      NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
      [runLoop addTimer: timer forMode: NSDefaultRunLoopMode];
      [runLoop run];
   }

   return 0;
}

Also, here's a copy of my daemon's plist file (Info.plist), with your daemon name in it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>NoUIDaemon</string>
        <key>CFBundleIdentifier</key>
        <string>dmn.NoUIDaemon</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>${PRODUCT_NAME}</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>1.0-0</string>
        <key>LSRequiresIPhoneOS</key>
        <true/>
        <key>LSApplicationCategoryType</key>
        <string></string>
</dict>
</plist>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!