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

上一章已经提到了通过越狱开发可以获取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文件里面添加以下代码

[cpp]  view plain copy
  1. #import <UIKit/UIKit.h>  
  2.   
  3. %hook SpringBoard  
  4.   
  5. -(void)applicationDidFinishLaunching:(id)application {  
  6.     %log;  
  7.     %orig;  
  8.       
  9.     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"applicationDidFinishLaunching"  
  10.                                                     message:@"Hello World!"  
  11.                                                    delegate:nil  
  12.                                           cancelButtonTitle:@"Thanks"   
  13.                                           otherButtonTitles:nil];  
  14.     [alert show];  
  15.     [alert release];  
  16.       
  17.     //通过scheme启动另一个app<p style="margin-top:0px; margin-bottom:0px; font-size:11px; font-family:Menlo">    NSURL *url = [NSURL URLWithString:<span style="color:#d12f1b">@"com.zz.tianc:"</span>];</p><p style="margin-top:0px; margin-bottom:0px; font-size:11px; font-family:Menlo">    [[UIApplication sharedApplication] openURL:url];</p>  
  18. } %end  

关于scheme的介绍请参看:http://blog.csdn.net/zzzili/article/details/8449893

代码写完后:Product--->Build For----->Profiling

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


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



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

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

[cpp]  view plain copy
  1. //隐藏APP  
  2. - (IBAction)TouchHiddenApp:(id)sender {  
  3.     NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];  
  4.     NSFileManager* manager = [NSFileManager defaultManager];  
  5.     if (plistPath)  
  6.     {  
  7.         NSLog(@"%@", plistPath);  
  8.           
  9.         NSMutableDictionary* infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];  
  10.           
  11.         NSArray *array = [NSArray arrayWithObject:@"hidden"];  
  12.         //This is the code used to hide the app from the homepage  
  13.         [infoDict setObject:array forKey:@"SBAppTags"];  
  14.         [infoDict writeToFile:plistPath atomically:YES];  
  15.         [manager changeFileAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate] atPath: [[NSBundle mainBundle] bundlePath]];  
  16.           
  17.         NSMutableDictionary* infoDictModified = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath];  
  18.           
  19.         NSLog(@"%@", infoDictModified);  
  20.           
  21.         if ([manager isWritableFileAtPath:plistPath])  
  22.         {  
  23.             NSLog(@"written");  
  24.         } else {  
  25.             NSLog(@"Something went wrong");  
  26.         }  
  27.     }  
  28. }  
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值