Xcode Copy Files Build Phase - what do the "Destination" options mean?
The app bundle in your example is Viewer
. This is not a file; it's a directory. If you click on it and "Show Package Contents", you'll see the rest of it.
Products Directory is the directory that Viewer
is written to. You cannot write to this directory in iOS.
For iOS, Wrapper is the top level directory within Viewer
.
For iOS, Executable is the same directory as Wrapper.
For iOS, Resources go into either the Wrapper directory, or the localization directories (Base.lproj
, etc) if the resource is localized.
The other directories aren't meaningful for iOS.
Still, you should use the directories logically. Use "Executable" to mean "the directory where my executable lives." Don't assume that the directory tree is laid out a particular way internally.
Regarding you comment that you need to know the path to access the file, you do not need that (and shouldn't try). You should use [NSBundle pathForResource:ofType:]
to find files.
Comments
-
Mr. Boy almost 2 years
The Xcode docs for this don't explain exactly where each of the Destination paths maps to on disc, relative to my application package.
If I use this app as an example, could someone give a canonical answer where each will put files relative to this directory structure?
-
trojanfoe over 10 yearsIs that directory the app bundle (which is what the Copy Files configuration is referring to)?
-
Mr. Boy over 10 yearsSorry, this is the 6.1 subdirectory of the Users/$User/Library/Application Support/iPhoneSimulator directory... so this is what XCode installs for the simulator.
Viewer
is the app bundle itself if I have my terminology correct. -
trojanfoe over 10 yearsI don't believe they are the same thing; Xcode wants to know where within the app bundle you want the file copied and what you show is the app's container folder. I'm not 100% sure however.
-
Mr. Boy over 10 yearsWell, all I'm after is a clear answer where, relative to either View or /891E4861-... each of those destination options will put the files. Are those options literally the names of sub-folders like "Java Resources"? Which is the "Products Directory"? etc
-
trojanfoe over 10 yearsNot sure. Not sure it matters these days as I think everything will go beneath
Resources
anyway. -
Mr. Boy over 10 yearsOf course it matters, I need to know the path to access the files in the app!
-
trojanfoe over 10 yearsNo, I don't think it does matter. Anyway why not try it and see where the file goes into the app bundle?
-
-
Mr. Boy over 10 yearsThis is a C++ application using cross-platform libraries which use regular paths and think in terms of directories and files. I'll add the
C++
tag since I didn't realise this was different in pure iOS dev. -
Rob Napier over 10 yearsYou should still use the bundle to find the path for you. Do not try to construct it based on assumptions about the tree. You can use
NSBundle
in ObjC code and pass the resulting string, or you can useCFBundleCopyResourceURL
in pure C or C++ code. -
Mr. Boy over 10 yearsCross-platform libraries often doesn't give you that luxury (I'm using Ogre3D here), in my case I use iOS APIs to get the absolute path of the bundle and have to do everything relative to that. It works fine (touch wood!), are there official guidelines against this?
-
Rob Napier over 10 yearsIf you're using
[NSBundle resourcePath]
to find your resources, then you are free to read subdirectories off of that. Just don't make assumptions about whereresources
is relative to thebundlePath
. Almost every root path you want is available in viaNSBundle
: developer.apple.com/library/ios/documentation/Cocoa/Reference/…. And you of course can pass these into C++ libraries (I do this all the time). -
Mr. Boy over 10 yearsAh, in this case we may be talking at cross-purposes a bit. Thanks for the help.