IOS 编译后代码修改mainBundle的文件的可行性

来源:互联网 发布:怎么样做淘宝生意 编辑:程序博客网 时间:2024/06/18 05:48

因为需求问题,今天测试了一下运行后,代码改变mainBundle里边文件的操作,发现一下情况


  • 将两张不同名字的图片拖入工程(testImage和testImage2),核心代码如下:
-(void)replaceImage{    NSString *testImagePath = [[NSBundle mainBundle] pathForResource:@"testImage" ofType:@"png"];    NSString *testImage2Path = [[NSBundle mainBundle] pathForResource:@"testImage2" ofType:@"png"];    NSLog(@"%@",testImage2Path);    BOOL success = [FILE_MANAGER replaceItemAtURL:[NSURL fileURLWithPath:testImagePath] withItemAtURL:[NSURL fileURLWithPath:testImage2Path] backupItemName:@"testImage.png" options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:nil error:nil];    if (success) {        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"tips" message:@"替换成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];        [alert show];    }}
  • 结果发现,在模拟机下是能替换的,但是,在真机下是不行的。然后拿了一些调试证书打出来的ipa包解压修改里边的文件,发现也是做了校验的:
    安装图片

所以不用打编译后的mainBundle的文件的注意了,毕竟安全很重要

阅读全文
0 0
原创粉丝点击