2011-02-24 95 views
3


我一直在寻找一种方式来发动对iPhone守护进程守护进程,我从ants application的源代码学习,它告诉我,我应该创建了Xcode的一个小测试应用程序使用launchctl但不幸的是,它不工作。制作用于越狱的iOS

我已经安装在/Applications/我与我的iPod Touch SSH应用程序,我然后用SSH启动它通账号mobile和我的日志这样说:

Script started on Thu Feb 24 19:33:28 2011 
bash-3.2$ ssh [email protected] 
[email protected]'s password: 
iPod-van-Henri:~ mobile$ cd /Applications 
iPod-van-Henri:/Applications mobile$ cd DaemonUtility.app/ 
iPod-van-Henri:/Applications/DaemonUtility.app mobile$ ./DaemonUtility 
2011-02-24 19:35:08.022 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:09.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:10.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:11.021 DaemonUtility[1369:107] Read 0 bytes 
Bug: launchctl.c:2367 (24307):13: (dbfd = open(g_job_overrides_db_path, O_RDONLY | O_EXLOCK | O_CREAT, S_IRUSR | S_IWUSR)) != -1 
launchctl: CFURLWriteDataAndPropertiesToResource(/private/var/stash/Applications.pwn/DaemonUtility.app/com.developerief2.daemontest.plist) failed: -10 
launch_msg(): Socket is not connected 
2011-02-24 19:35:12.039 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:13.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:14.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:15.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:16.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:17.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:18.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:19.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:20.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:21.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:22.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:23.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:24.021 DaemonUtility[1369:107] Read 0 bytes 
2011-02-24 19:35:25.021 DaemonUtility[1369:107] Read 0 bytes 
^C 
iPod-van-Henri:/Applications/DaemonUtility.app mobile$ exit 
logout 
Connection to 192.168.1.8 closed. 

bash-3.2$ exit 
exit 

Script done on Thu Feb 24 19:34:49 2011 

当我与root(做启动它它与su),我得到守护进程运行,但它什么都不做。

我的守护进程,因为它的推出应该显示UIViewAlert每十秒钟:

**main.m (Daemon)** 
// 
// main.m 
// DaemonTest 
// 
// Created by ief2 on 23/02/11. 
// 

#import <UIKit/UIKit.h> 

@interface DAAppDelegate : NSObject <UIApplicationDelegate> { 
    NSDate *_startupDate; 
    NSTimer *_messageTimer; 
} 
@property (nonatomic, retain) NSDate *startupDate; 
@end 

@interface DAAppDelegate (PrivateMethods) 
- (void)showMessage:(NSTimer *)timer; 
@end 

@implementation DAAppDelegate 
@synthesize startupDate=_startupDate; 

- (void)dealloc { 
    [_startupDate dealloc]; 
    [_messageTimer dealloc]; 

    [super dealloc]; 
} 

- (void)applicationDidFinishLaunching:(UIApplication *)theApplication { 
    UIAlertView *myView; 
    myView = [[UIAlertView alloc] initWithTitle:@"Daemon Launched" 
             message:@"The daemon was launched" 
             delegate:nil 
           cancelButtonTitle:@"OK" 
           otherButtonTitles:nil]; 
    [myView show]; 
    [myView release]; 

    self.startupDate = [NSDate date]; 

    NSTimer *myTimer = [NSTimer scheduledTimerWithTimeInterval:10 
                 target:self 
                 selector:@selector(showMessage:) 
                 userInfo:nil 
                 repeats:YES]; 
    _messageTimer = [myTimer retain]; 
} 

- (void)applicationWillTerminate:(UIApplication *)theApplication { 
    [_messageTimer invalidate]; 

    UIAlertView *myView; 
    myView = [[UIAlertView alloc] initWithTitle:@"Daemon Terminated" 
             message:@"The daemon was terminated" 
             delegate:nil 
           cancelButtonTitle:@"OK" 
           otherButtonTitles:nil]; 
    [myView show]; 
    [myView release]; 
} 

- (void)showMessage:(NSTimer *)timer { 
    NSTimeInterval mySec; 
    mySec = [self.startupDate timeIntervalSinceNow]; 
    NSString *format = [NSString stringWithFormat: 
         @"The daemon has been running for %llu seconds", 
         (unsigned long long)mySec]; 
    UIAlertView *myView; 
    myView = [[UIAlertView alloc] initWithTitle:@"Daemon Message" 
             message:format 
             delegate:nil 
           cancelButtonTitle:@"OK" 
           otherButtonTitles:nil]; 
    [myView show]; 
    [myView release]; 
} 
@end 


int main(int argc, const char **argv) { 
    NSAutoreleasePool *mainPool = [[NSAutoreleasePool alloc] init]; 

    UIApplicationMain(argc, (char **)argv, nil, @"DAAppDelegate"); 

    [mainPool drain]; 
    return 0; 
} 

完整的应用程序的源代码可以在我的电脑上找到:
http://81.82.20.197/DaemonTest.zip

谢谢你在前进,
ief2

回答

6

你正在努力工作。您只需创建一个.plist文件,其中包含应用标识符和路径,并将其添加到/ System/Library/LaunchDaemon文件夹。然后确保您的应用程序位于/ Applications文件夹中。重新启动,每次手机启动时它都会工作。

谷歌“克里斯·阿尔瓦雷斯守护进程”,并期待在他的教程...

+0

我跟随克里斯·阿尔瓦雷斯守护教程启动您的“应用程序”。但是,我成功运行守护进程失败。它给出了一个错误。 – 2013-03-10 18:57:01

-1

我不认为的launchd可以触发GUI级别的应用程序。任何“Aqua”级别的应该是“StartupItem”或“登录项目”。你仍然可以以root身份启动它们,根据它们的起始位置,以及他们拥有谁,但launchd不会触及那些东西......我不认为如果你想launchd到,你甚至可以有一个菜单栏图标处理它....

此外,如果你是谈越狱的iPhone ...如果你婉从打开一个GUI应用程序的“MobileTerminal来”你应该看看在Cydia的应用说:“这是否” 。它不像启动可执行文件那么简单..有一些时髦的跳板交互..该实用程序照顾。它callled ......“AppsThruTerm”(BigBoss的回购)一旦安装..你用命令att blahblahblah