Theos 工程 layout 目录下文件,解包到 iPhone 后,无法修改

需求:

对 layout 文件夹,解包到越狱设备上的文件进行复制,移动,修改。

环境

最新版 theos, iPhone SE 9.3.2, macOS 10.13.1

###关键代码:

复制文件

NSString *path = @"/var/mobile/Media/Test/src/test.txt";
NSString *toPath = @"/var/mobile/Media/Test/des/test.txt";
NSError *error;
[[NSFileManager defaultManager] copyItemAtPath:path toPath:toPath error:&error];

除了无法操作文件外,也无法写文件

NSString *writePath = @"/var/mobile/Media/Test/src/write.txt";
NSError *error;
[[NSFileManager defaultManager] createFileAtPath:writePath contents:nil attributes:nil];
[@"write" writeToFile:writePath atomically:YES encoding:NSUTF8StringEncoding error:&error];

操作步骤:

  1. 使用 theos 的 iphone/application_modern 模板创建工程。
  2. 在工程目录下,创建了 layout 文件夹。
  3. 在 layout 文件夹中,创建了/var/mobile/Media/Test/src/test.txt 以及 /var/mobile/Media/Test/des/
  4. 在 - [RootViewController addButtonTapped:] 中添加了上述代码。
  5. make package install。

结果:

  1. 无法对 /var/mobile/Media/Test/src/test.txt 进行复制,只能读出其中内容。
  2. 也无法在 /var/mobile/Media/Test/src/ 中写入新文件。

错误日志:

复制错误

open on /var/mobile/Media/Test/des/test.txt: Permission denied
// Error
Error Domain=NSCocoaErrorDomain Code=513 "“test.txt” couldn’t be copied because you don’t have permission to access “des”." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Media/Test/src/test.txt, NSUserStringVariant=(
	    Copy
	), NSDestinationFilePath=/var/mobile/Media/Test/des/test.txt, NSFilePath=/var/mobile/Media/Test/src/test.txt, NSUnderlyingError=0x15d502230 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}

写文件错误

Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “write.txt” in the folder “src”." UserInfo={NSFilePath=/var/mobile/Media/Test/src/write.txt, NSUserStringVariant=Folder, NSUnderlyingError=0x12d6bfba0 {Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"}}

关于权限

app 权限:

-rwxr-xr-x 1 root wheel 138880 Dec  4 21:14 ModernApp*

文件夹权限

xx:/var/mobile/Media/Test root# ls -l
total 0
drwxr-xr-x 2 root wheel  68 Nov 14 19:48 des/
drwxr-xr-x 2 root wheel 102 Dec  4 21:14 src/

如上:app 和 文件都是 root wheel,为什么会没有权限,修改 layout 解包后的文件呢?

烦请走过路过的大神们,指点一下迷津。

兄弟 问题解决了吗, 我也遇到这个问题了