当前位置: 代码迷 >> Iphone >> 大姐,要在越狱的iphone 上做一个类似Cydia或同步推的东西
  详细解决方案

大姐,要在越狱的iphone 上做一个类似Cydia或同步推的东西

热度:25   发布时间:2016-04-25 06:41:31.0
各位大哥大姐,求助,要在越狱的iphone 上做一个类似Cydia或同步推的东西。
现在主要思路是:
实现程序A :安装到/Applications目录下,获得root权限。
A:完成的功能是:
1.下载ipa程序包。
2.检查程序是否安装,找到安装目录(已经安装)或生成新的安装目录。
3.把ipa解压,把iTurnArtwork 及.app 复制到/var/mobile/Applications/安装目录/ 下。
4.修改复制东东的权限。

问题:
1.安装后要过好久桌面才会出现程序图标。(怎么程序刷新桌面或配置什么东东会让图标马上显示出来?)
2.安装后桌面的图标为白图标。(icon无效了,怎么程序处理?)
3.现在很多程序都安装在/Applications,这个是如何实现 的

------解决方案--------------------
我也正在做这个东西。你拷过去试下。
- (BOOL)InstallIPA:(NSString *)strpath
{
//create zip
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSError *error;

ZipArchive *zip = [[ZipArchive alloc] init];
NSString *strzippath = [strpath stringByAppendingString:@".zip"];

if([fileMgr fileExistsAtPath:strpath])
{
if([fileMgr copyItemAtPath:strpath toPath:strzippath error:&error]!=YES)
{
NSLog(@"Unable to move file: %@", [error localizedDescription]);
// return FALSE;
}
//[zip CreateZipFile2:strzippath];
//[zip addFileToZip:strpath newname:strname];
//[zip CloseZipFile2];
}
else {
return FALSE;
}


//unzip
NSString *topath = [strpath stringByDeletingPathExtension];
if([fileMgr fileExistsAtPath:strzippath])
{
if([zip UnzipOpenFile:strzippath])
{
if([zip UnzipFileTo:topath overWrite:YES])
{
NSLog(@"error:");
}
}
[zip UnzipCloseFile];
}
else {
return FALSE;
}


//rename Payload and move
NSString *strname=[topath lastPathComponent];
NSString *strPayload = [topath stringByAppendingString:@"/Payload"];
NSString *syspath = [[NSString alloc] initWithString:@"/private/var/mobile/Applications/"]; 
NSString *filename =[syspath stringByAppendingString:strname];
if([fileMgr fileExistsAtPath:strPayload])
{
if([fileMgr moveItemAtPath:strPayload toPath:filename error:&error]!=YES)
{
NSLog(@"Unable to move file: %@", [error localizedDescription]);
}
NSString *strDocuments= [filename stringByAppendingString:@"/Documents"];
[fileMgr createDirectoryAtPath:strDocuments attributes:nil];
}
else 
{
return FALSE;
}

//set right
NSDictionary *theAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:0755],NSFilePosixPermissions,nil];
 
[fileMgr setAttributes:theAttributes ofItemAtPath:filename error:&error];
return TRUE;
}
------解决方案--------------------
如果图标很久出来,那么你得强制respring了或者重启机器了,这没办法的。
------解决方案--------------------
关键是这个程序没有权限是创建目录什么的。例如:/private/var/mobile/Applications/ 创建沙河目录,老是失败,操作不允许,权限怎么解决?
  相关解决方案