iOS Daemon应用程序不会启动(越狱) - 如何调试? [英] iOS Daemon app will not start (Jailbreak) - how to debug?

查看:260
本文介绍了iOS Daemon应用程序不会启动(越狱) - 如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为越狱的iPhone建立一个守护程序应用程序,并遵循这些指导方针,这些指导原则在这里介绍了stackoverflow和Chris Alvares的网页: http://chrisalvares.com/blog/38/creating-an-iphone-daemon-part-4/



Xcode,该项目由Jailcoder修补,使其在我的设备上运行。



这里的其中一个帖子表示,现在不再需要使用打开的工具链模板。将应用程序上传到/ Applications目录并在/ System / Library / LaunchDaemons中添加plist文件应该是足够的。



我已经执行了上述步骤,但守护程序未启动,或至少在我检查时不运行。在Xcode管理器中可用的设备日志中,应用程序的名称或其包ID不会在任何位置找到。我至少会期待一个错误,为什么它不会启动。



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

 <?xml version =1.0encoding =UTF-8?> 
<!DOCTYPE plist PUBLIC - // Apple // DTD PLIST 1.0 // ENhttp://www.apple.com/DTDs/PropertyList-1.0.dtd\">
< plist version =1.0>
< dict>
< key>已禁用< / 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>

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



编辑: p>

我的主程序的内容:

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

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

  R-iPod:/ root#/Applications/NoUIDaemon.app/NoUIDaemon 
-sh:/ Applications / NoUIDaemon.app/NoUIDaemon:可执行文件中的CPU类型不正确

请注意,该应用没有问题,我从Xcode在我的设备上运行它。



Eventhough守护进程无法手动启动,Nate的问题的答案:



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



2)我在Label中遗忘了.plist部分的错误内容,所以我已经尝试了两个值,有和没有.plist在最后,没有差异。



3)我已经重新启动设备,安装两个应用程序和plist文件使用重新启动命令



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



5)当坏CPU问题解决并且仍然不起作用时,请尝试此方法



FINAL EDIT:



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

 < key> SBAppTags< / key> 
< array>
< string> hidden< / string>
< / array>


解决方案

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


  1. root 登录到您的设备,通过 ssh

  2. 执行命令 /Applications/NoUIDameon.app/NoUIDaemon 命令行

  3. 检查是否正在运行 ps -Aef | grep NoUIDaemon

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

  int main(int argc,char * argv []){
//这里有什么?
}

如果这样工作,并且手动启动时运行(但不是自动),然后检查:


  1. 是上面命名为的plist文件dmn.NoUIDaemon我认为这实际上是Chris的博客中的一个错误,但是 Label ?您的plist应该是< string> dmn.NoUIDaemon< / string> ,而不是< string> dmn.NoUIDaemon.plist< / string> / code>。我不认为这将阻止您的守护进程运行,我认为这只是与系统启动守护程序的命名约定一致。

  2. 我不认为只是安装plist文件 / System / Library / LaunchDaemons 足以启动守护进程。您可能需要重新启动手机,或者使用 launchctl手动启动守护程序load -w /System/Library/LaunchDaemons/dmn.NoUIDaemon.plist

  3. 检查以确保您的dmn.NoUIDaemon.plist的文件权限和所有权与 / System / Library / LaunchDaemons 中的其他启动守护程序一致。

  4. 我不知道这是否必要,但我认为守护进程的名称(标签和名称plist文件)应该与您的NoUIDaemon-Info.plist文件中指定的软件包ID相匹配。所以,Info.plist应该有:





 < key> CFBundleExecutable< / key> 
< string> NoUIDaemon< / string>
< key> CFBundleIdentifier< / key>
< string> dmn。$ {PRODUCT_NAME:rfc1034identifier}< / string>

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

更新:



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

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

//启动一个计时器,使进程不退出。
NSTimer * timer = [[NSTimer alloc] initWithFireDate:[NSDate date]
interval:1.0
target:daemon
selector:@selector(setup :)
userInfo :nil
重复:否];

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

return 0;
}

此外,这是我的守护进程的plist文件(Info.plist)的副本,你的守护进程名称在其中:

 <?xml version =1.0encoding = UTF-8?> 
<!DOCTYPE plist PUBLIC - // Apple // DTD PLIST 1.0 // ENhttp://www.apple.com/DTDs/PropertyList-1.0.dtd\">
< plist version =1.0>
< dict>
< key> CFBundleDevelopmentRegion< / key>
< string>英文< / 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>


I'm building a daemon app for a jailbroken iPhone and followed the guidelines as described in several questions and answers here on stackoverflow and ofcourse Chris Alvares' webpage at http://chrisalvares.com/blog/38/creating-an-iphone-daemon-part-4/

Xcode and the project are patched by Jailcoder to make it run on my device.

One of the posts on here stated that nowadays it is no longer needed to use the open toolchain template. Uploading the app to the /Applications dir and adding a plist file in /System/Library/LaunchDaemons should be sufficient.

I have performed the above steps but the daemon is not started, or at least not running when i check. In the device logs that are available in Xcode organizer the name of the app or its bundle id are not to be found anywhere. I would at least expect an error with a reason why it won't start.

The contents of the plist file copied to /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>

Question: is there a way to debug why it won't start the daemon app? Or have i maybe missed a step besides uploading the app to /Applications and adding the plist file to the LaunchDaemons dir ?

EDIT:

Contents of my main routine:

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

Error when launching /Applications/NoUIDaemon.app/NoUIDaemon :

R-iPod:/ root# /Applications/NoUIDaemon.app/NoUIDaemon
-sh: /Applications/NoUIDaemon.app/NoUIDaemon: Bad CPU type in executable

Note that the app does work without a problem when i run it on my device from Xcode.

Eventhough the daemon cannot be started manually, the answers to Nate's questions:

1) The plist file in LaunchDaemons is indeed named dmn.NoUIDaemon.plist

2) I made the 'mistake' of forgetting the .plist part in the Label contents, so i have tried it with both values, with and without .plist at the end, no difference ofcourse.

3) I have rebooted the device after installing both the app and the plist file using the reboot command

4) I've made sure all the permissions are the same (0775)

5) Will try this when the Bad CPU issue is resolved and it still doesn't work

FINAL EDIT:

To hide your Daemon app icon on the springboard, add the following to the Info.plist in your .app:

<key>SBAppTags</key>
<array>
    <string>hidden</string>
</array>

解决方案

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>

这篇关于iOS Daemon应用程序不会启动(越狱) - 如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆