Skip to content

Commit

Permalink
Fix issue where resources were accidentally being deleted from the de…
Browse files Browse the repository at this point in the history
…stination directory
  • Loading branch information
gcasa committed May 11, 2024
1 parent 7e32c54 commit a0a4f94
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions XCode/PBXResourcesBuildPhase.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ - (NSString *) processAssets
NSString *destPath = [resourcesDir stringByAppendingPathComponent: filename];

// Copy the item, remove it first to make sure there is no issue.
[mgr removeItemAtPath: destPath
error: NULL];
//[mgr removeItemAtPath: destPath
// error: NULL];

[mgr copyItemAtPath: imagePath
toPath: destPath
Expand Down Expand Up @@ -264,16 +264,16 @@ - (BOOL) build
withString: @""];

NSDebugLog(@"\t* Copy child %@ -> %@",filePath,destPath);
xcputs([[NSString stringWithFormat: @"\t* Copy child resource %s%@%s --> %s%@%s", CYAN, filePath, RESET, GREEN, destPath, RESET] cString]);
xcputs([[NSString stringWithFormat: @"\t* Copy child resource \"%s%@%s\" --> \"%s%@%s\"", CYAN, filePath, RESET, GREEN, destPath, RESET] cString]);

// Copy the item, remove it first to make sure there is no issue.
[mgr removeItemAtPath: destPath
error: NULL];
//[mgr removeItemAtPath: destPath
// error: NULL];

copyResult = [mgr copyItemAtPath: filePath
toPath: destPath
error: &error];
if (copyResult == NO || error != NULL)
if (error != nil)
{
xcputs([[NSString stringWithFormat: @"\t** Could not copy file %s%s%@%s", BOLD, RED, filePath, RESET] cString]);
NSDebugLog(@"\tERROR: %@, %@ -> %@", error, filePath, destPath);
Expand All @@ -297,19 +297,25 @@ - (BOOL) build
NSError *error = nil;
BOOL copyResult = NO;
NSDebugLog(@"\tXXXX Copy %@ -> %@",filePath,destPath);
xcputs([[NSString stringWithFormat: @"\t* Copy resource %s%@%s --> %s%@%s", CYAN, filePath, RESET, GREEN, destPath, RESET] cString]);
xcputs([[NSString stringWithFormat: @"\t* Copy resource \"%s%@%s\" --> \"%s%@%s\"", CYAN, filePath, RESET, GREEN, destPath, RESET] cString]);

// Copy the item, remove it first to make sure there is no issue.
[mgr removeItemAtPath: destPath
error: NULL];
// [mgr removeItemAtPath: destPath
// error: NULL];

copyResult = [mgr copyItemAtPath: filePath
toPath: destPath
error: &error];
if(!copyResult)
if(error != nil)
{
NSDebugLog(@"\tCopy Error: %@ copying %@ -> %@",[error localizedDescription],
filePath, destPath);
xcputs([[NSString stringWithFormat: @"\t%sCopy Error:%s %@ copying %@ -> %@", RED, RESET, [error localizedDescription],
filePath, destPath] cString]);
}

copyResult = [mgr fileExistsAtPath: destPath];
if (!copyResult)
{
NSLog(@"File not copied: %@ -> %@", filePath, destPath);
}
}

Expand Down

0 comments on commit a0a4f94

Please sign in to comment.