您的位置:首页 > 移动开发

IOS越狱开发(二)———APP开机自动启动并隐藏图标

2013-10-20 19:36 821 查看
上一章已经提到了通过越狱开发可以获取Root权限***系统级应用程序,当然也可以设置开机启动项,如果想更高级点还可以app自动启动后,在桌面隐藏APP图标,让用户无法关闭app(非常强盗啊!)

第一步:实现APP自动启动。

参看帖子:http://blog.csdn.net/lynjay/article/details/7936488完成环境搭建。

1、新建工程:xcode-》file-》new-》project-》iOSOpenDev-》logos tweak, 取名叫AutoRun,这个工程里面有两个文件很重要就是AutoRun.xm和AutoRun.mm文件,其中AutoRun.mm文件的内容是编译器根据AutoRun.xm自动填充的,暂时不管AutoRun.mm文件,现在我们主要是对于AutoRun.xm文件的编辑

2、按照错误提示,添加libsubstrate.dylib库到工程中,然后删除错误提示代码

3、在添加UIKit.framework

4、在AutoRun.xm文件里面添加以下代码
#import <UIKit/UIKit.h>

%hook SpringBoard

-(void)applicationDidFinishLaunching:(id)application {
    %log;
    %orig;
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"applicationDidFinishLaunching"
                                                    message:@"Hello World!"
                                                   delegate:nil
                                          cancelButtonTitle:@"Thanks" 
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
    
    //通过scheme启动另一个app    NSURL *url = [NSURL URLWithString:@"com.zz.tianc:"];    [[UIApplication sharedApplication] openURL:url];
} %end


关于scheme的介绍请参看:http://blog.csdn.net/zzzili/article/details/8449893
代码写完后:Product--->Build For----->Profiling

然后在会生成Package文件夹,里面有deb文件。



这个就是可以开机启动的应用文件。这个程序启动后会通过scheme打开我们想要的app

第二步:实现APP的图标隐藏

实现app的隐藏可以在plist文件里面设置,当然也可以通过代码

//隐藏APP
- (IBAction)TouchHiddenApp:(id)sender {
    NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
    NSFileManager* manager = [NSFileManager defaultManager];
    if (plistPath)
    {
        NSLog(@"%@", plistPath);
        
        NSMutableDictionary* infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
        
        NSArray *array = [NSArray arrayWithObject:@"hidden"];
        //This is the code used to hide the app from the homepage
        [infoDict setObject:array forKey:@"SBAppTags"];
        [infoDict writeToFile:plistPath atomically:YES];
        [manager changeFileAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate] atPath: [[NSBundle mainBundle] bundlePath]];
        
        NSMutableDictionary* infoDictModified = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];
        
        NSLog(@"%@", infoDictModified);
        
        if ([manager isWritableFileAtPath:plistPath])
        {
            NSLog(@"written");
        } else {
            NSLog(@"Something went wrong");
        }
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: