I have a very strange problem with the iPad application that I am writing. At startup, I want to copy a folder containing several other folders (empty) from the application set to the Documents directory. The copied folder, called "flds" (all lowercase letters), was added to the Xcode 4 project using "Create Folder Links for Any Added Folders", and I checked that it was actually part of the .app file after compilation. (And that it does not exist already when trying to copy.)
I tried to get into the "flds" folder using one of these calls (they all work):
[[[NSBundle mainBundle] bundleURL] URLByAppendingPathComponent:@"flds"]
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"flds"]
[[NSBundle mainBundle] pathForResource:@"flds" ofType:@""]
Then copy using the NSFileManager method copyItemAtPath:toPath:error:(or equivalent URL when using the URL instead of the path string).
All these strategies work perfectly in the iPad Simulator and on the iPad, except for the following: When I (successfully) create for the Ad Hoc distribution, drag .app and .mobileprovision to iTunes, sync and then launch the application on the device, the system is bigger doesn't think that the "flds" folder exists! I tried to explore it for many hours, with no luck. Again, I’m sure that it works both in the simulator and on a device running with Xcode, but not when syncing via iTunes.
Ideas?
I found that the following call gets the folder path successfully also after syncing the iPad app through iTunes:
[[NSBundle mainBundle] pathForResource:@"flds" ofType:nil inDirectory:nil]
, , "", .txt( , ) , 6-7 . , : , , Xcode ( "flds" "test.txt" ), iTunes ( "flds" 'test.txt' , ). copyItemAtPath:toPath:error:? - iTunes?