// // main.m // changecfile // Created by miaoqushidai on 2023/6/29. // #import <Foundation/Foundation.h> void changeFilePath(NSString* path,NSString* name){ NSString* src = @"/Users/mqsd/Documents/BoomBoy/4HaiwZian/Client/BoomBoyNew/Build/iOS/06291405/App"; NSString *appPath =[[NSBundle mainBundle] bundlePath]; NSString *str=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; str = [str stringByReplacingOccurrencesOfString:src withString:appPath]; NSString *des = [NSString stringWithFormat:@"%@/%@", appPath, @"Libraries/lumps"]; NSString *filePath2 = [NSString stringWithFormat:@"%@/%@", des,name]; NSError* er; BOOL success = [str writeToFile:filePath2 atomically:true encoding:NSUTF8StringEncoding error: &er];//error:nil if(success) { NSLog(@"Writing file is successful!"); } else { NSLog(@"Write file is failed, with error : %@", [er localizedDescription]); } NSLog(@"%@",filePath2); } int main(int argc, const char * argv[]) { @autoreleasepool { NSFileManager *manager = [NSFileManager defaultManager]; NSString *appPath =[[NSBundle mainBundle] bundlePath]; NSString *filePath = [NSString stringWithFormat:@"%@/%@", appPath, @"Libraries/lumps"]; NSArray *allPath =[manager subpathsAtPath:filePath]; for (NSString *subPath in allPath) { NSString* fileName = [NSString stringWithFormat:@"%@/%@",filePath,subPath]; changeFilePath(fileName,subPath); } NSLog(@"%@",appPath); } return 0; }
标签:str,NSLog,stringWithFormat,NSString,appPath,HybirdCLR,版本,error,3.2 From: https://www.cnblogs.com/unity-android-ios/p/17514708.html