iOS守护程序应用程序无法启动(越狱) - 如何调试?

Ron*_*ald 5 iphone debugging daemon jailbreak ios

我正在为越狱的iPhone构建一个守护程序应用程序,并按照几个问题和答案中的描述在stackoverflow和当然Chris Alvares的网页http://chrisalvares.com/blog/38/creating-an-iphone-守护程序部分-4 /

Xcode和项目由Jailcoder打补丁,使其在我的设备上运行.

其中一篇文章指出,现在不再需要使用开放式工具链模板.将应用程序上传到/ Applications目录并在/ System/Library/LaunchDaemons中添加plist文件就足够了.

我已经执行了上述步骤但是守护程序没有启动,或者至少在我检查时没有运行.在Xcode管理器中可用的设备日志中,不能在任何地方找到应用程序的名称或其包ID.我至少会期待一个错误,并说明它无法启动的原因.

plist文件的内容复制到/ System/Library/LaunchDaemons:

    <?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>Disabled</key>
        <false/>
        <key>Label</key>
        <string>dmn.NoUIDaemon.plist</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/Applications/NoUIDaemon.app/NoUIDaemon</string>
            <string></string>
            <string></string>
        </array>
        <key>StandardErrorPath</key>
        <string>/dev/null</string>
    </dict>
    </plist>
Run Code Online (Sandbox Code Playgroud)

问题:有没有办法调试它为什么不启动守护程序应用程序?或者我可能错过了将应用程序上传到/ Applications并将plist文件添加到LaunchDaemons目录的步骤?

编辑:

我的主要例程的内容:

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}
Run Code Online (Sandbox Code Playgroud)

启动/Applications/NoUIDaemon.app/NoUIDaemon时出错:

R-iPod:/ root# /Applications/NoUIDaemon.app/NoUIDaemon
-sh: /Applications/NoUIDaemon.app/NoUIDaemon: Bad CPU type in executable
Run Code Online (Sandbox Code Playgroud)

请注意,当我从Xcode在我的设备上运行它时,该应用程序可以正常工作.

虽然守护程序无法手动启动,但Nate的问题答案如下:

1)LaunchDaemons中的plist文件确实命名为dmn.NoUIDaemon.plist

2)我在标签内容中忘记了.plist部分的'错误',所以我尝试了两个值,最后有和没有.plist,没有差异.

3)在使用reboot命令安装app和plist文件后,我重新启动了设备

4)我确保所有权限都相同(0775)

5)当坏CPU问题得到解决并且仍然无效时,将尝试此操作

最终编辑:

要在跳板上隐藏您的守护程序应用程序图标,请将以下内容添加到.app中的Info.plist:

<key>SBAppTags</key>
<array>
    <string>hidden</string>
</array>
Run Code Online (Sandbox Code Playgroud)

Nat*_*ate 6

正如我在评论中所说,首先尝试确保您的守护程序可执行文件是可运行的:

  1. 登录到您的设备为root,通过ssh
  2. /Applications/NoUIDameon.app/NoUIDaemon在命令行执行命令
  3. 检查它是否正在运行 ps -Aef | grep NoUIDaemon

如果它没有运行,我会检查以确保您的构建过程是伪代码签署NoUIDaemon可执行文件.越狱手机不需要有效签名,但仍需要签名.此外,如果它没有运行(或保持运行),则可能有助于您从守护程序的主程序(例如main.m)发布代码:

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

如果确实有效,并且在手动启动时运行(但不是自动启动),请检查:

  1. 是上面的plist文件命名dmn.NoUIDaemon.plist
  2. 我认为这在Chris的博客中实际上是一个错误,但是Label你的plist中的值应该是<string>dmn.NoUIDaemon</string>,而不是<string>dmn.NoUIDaemon.plist</string>.我不认为这会阻止你的守护进程运行,我认为它只是与系统启动守护进程的命名约定一致.
  3. 我不认为只安装plist文件/System/Library/LaunchDaemons足以启动守护进程.您可能需要重新启动手机,或者手动启动守护程序launchctl load -w /System/Library/LaunchDaemons/dmn.NoUIDaemon.plist
  4. 检查以确保dmn.NoUIDaemon.plist的文件权限和所有权与其他启动守护程序plist相同/System/Library/LaunchDaemons.
  5. 我不确定这是否有必要,但我认为守护进程的名称(Label和plist文件的名称)应该与NoUIDaemon-Info.plist文件中指定的包ID相匹配.所以,Info.plist应该有:
    <key>CFBundleExecutable</key>
    <string>NoUIDaemon</string>
    <key>CFBundleIdentifier</key>
    <string>dmn.${PRODUCT_NAME:rfc1034identifier}</string>
Run Code Online (Sandbox Code Playgroud)

要么

    <key>CFBundleExecutable</key>
    <string>NoUIDaemon</string>
    <key>CFBundleIdentifier</key>
    <string>dmn.NoUIDaemon</string>
Run Code Online (Sandbox Code Playgroud)

更新:

另外,我认为您的守护程序的主程序不应该调用UIApplicationMain.它不应该是UIApplication.它应该是一个后台进程,对吧?如果你看看Chris博客的第1页,它会显示一个例子.以下是我的一个例子:

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;
}
Run Code Online (Sandbox Code Playgroud)

此外,这是我的守护程序的plist文件(Info.plist)的副本,其中包含您的守护程序名称:

<?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>
Run Code Online (Sandbox Code Playgroud)