3


私はiPhoneでデーモンを起動する方法を探していて、Antアプリケーションのソースコードから学習してXcodeで小さなテストアプリケーションを作成しました。これにより、使用する必要があることlaunchctlがわかりましたが、残念ながら機能しません。

私はiPodTouchにSSHを使用してアプリケーションをインストールしました/Applications/。次に、アカウントを介してSSHを使用してアプリケーションを起動するmobileと、ログに次のように表示されます。

Script started on Thu Feb 24 19:33:28 2011
bash-3.2$ ssh mobile@192.168.1.8
mobile@192.168.1.8'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起動してから10秒ごとに表示されます。

**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

4

2 に答える 2

7

あなたは一生懸命働いています。アプリの識別子とパスを含む.plistファイルを作成し、それを/ System / Library/LaunchDaemonフォルダーに追加するだけです。次に、アプリが/Applicationsフォルダーにあることを確認します。再起動すると、電話が起動するたびに機能します。

グーグル「クリスアルバレスデーモン」と彼のチュートリアルを見てください...

于 2011-03-12T18:04:48.123 に答える
-1

launchDがGUIレベルのアプリをトリガーできるとは思いません。「アクア」レベルのものはすべて「StartupItem」または「LoginItem」である必要があります。それらがどこから開始され、誰が所有しているかに基づいて、rootとして開始することはできますが、launchdはそのようなものには影響しません...起動したい場合はメニューバーアイコンを使用することもできないと思います扱う....

また、ジェイルブレイクされたiPhoneについて話している場合は、「モバイル端末」からGUIアプリを開きたい場合は、Cydiaで「それを行う」アプリを探す必要があります。実行可能ファイルを起動するほど簡単ではありません。ファンキーなスプリングボードの相互作用があります。そのユーティリティが処理します。それは呼び出されます......「AppsThruTerm」(bigbossリポジトリ)がインストールされると..コマンドで「アプリ」を起動しますatt blahblahblah

于 2011-07-11T20:23:24.897 に答える