ios开发如何批量打包?如何让同一个程序在一个手机上多次安装时不覆盖以前安装的,而是重新生成一个新的

17 篇文章 0 订阅
Bundle identifier如果相同的话,ipa安装解压后会在同一沙盒下,出现你所说的覆盖安装。
首先,你可以在模拟器先运行一遍你的程序,在模拟器的沙盒下找的你的应用,进去找到你不想覆盖的文件及其路径。

搞清楚了以后在你的代码里找到向沙盒拷贝资源的代码,先判断文件是否存在,不存在则拷贝。

为你提供三个方法供你参考,粘贴过来格式乱了,空格你自己处理下吧。
//获取沙盒路径
-(NSString*)GetDocumentPath:(NSString*) _filename
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *pathstr = [paths objectAtIndex:0];
    NSString *ret=[NSStringstringWithFormat:@"%@/%@",pathstr,_filename];
    return ret;
}


//获取资源路径
-(NSString*)GetResPath:(NSString*) _filename Type:(NSString*) _type
{
    NSString *ret = [[NSBundlemainBundle] pathForResource:_filename ofType:_type];
    return ret;
}


//判断沙盒文件是否存在并拷贝
-(bool)FileExitAndCopy:(NSString*) filename FullName:(NSString*)fullfilename Type:(NSString*) _type
{
    if ([[NSFileManagerdefaultManager] fileExistsAtPath:[selfGetDocumentPath:fullfilename]])
    {
        returntrue;
    }else {
        NSError *error;
        NSString * tapppath = [selfGetResPath:filename Type:_type];
        [[NSFileManagerdefaultManager] copyItemAtPath:tapppath toPath:[selfGetDocumentPath:fullfilename] error:&error];
        if ([[NSFileManagerdefaultManager] fileExistsAtPath:[selfGetDocumentPath:fullfilename]])
        {
            returntrue;
        }else {
            returnfalse;
        }
    }
    returnfalse;
}
本文转自http://zhidao.baidu.com/question/502866185.html
不知道有没有用,没试过
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值