Reputation: 14834
I found this piece of code from anther post here. It worked as intended with iPad simulator mode but not when I switched to the actual iPad device mode. Instead, it came up with a "no such files exist" error message. Before executing this codes, I did create a the Populator folder by right-click on the xxxxxx.app and chose "show package contents" and put some files into the Populator folder. Does Xcode copy the whole app package over the iPad device? Any suggestions?
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Populator"];
NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"Files"];
NSLog(@"Source Path: %@\n Documents Path: %@ \n Folder Path: %@", sourcePath, documentsDirectory, folderPath);
NSLog(@"docdire: %@", documentsDirectory);
NSLog(@"loadImage button clicked");
label.text = [@"sourcePath: " stringByAppendingString:sourcePath];
textField.text = [@"clicked: " stringByAppendingString:documentsDirectory];;
NSError *error;
if([[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:folderPath error:&error]){
NSLog(@"File successfully copied");
label.text = @"copy succeeded";
} else {
NSLog(@"Error description-%@ \n", [error localizedDescription]);
NSLog(@"Error reason-%@", [error localizedFailureReason]);
label.text = [@"Error description: " stringByAppendingString:[error localizedDescription]];
label2.text = [@"Error reason: " stringByAppendingString:[error localizedFailureReason]];
}
Upvotes: 0
Views: 1443
Reputation: 14834
As in my comment in the original question:
I found out that there are 2 places that has the xxxxx.app package. One is for the simulator and the other one is for the build distribution.
Upvotes: 0
Reputation: 11703
You cannot add files or folder to the NSBundle after it has been built. For the device, Xcode is going to sign the NSBundle. Whatever files and folders you want in the NSBundle on the device will have to be added to your Xcode project.
The other way to add files/folders to your NSBundle is during the build phase before the bundle is signed.
Upvotes: 3
Reputation: 11502
Without access to the actual file list, you might want to check the case of the file names. The iPhone simulator is not case-sensitive, while the iPad filesystem is Case-Sensitive. This has tripped up many developers in the past.
Upvotes: 0