Question

I am now working on a simple project in Xcode. This project requires me to read a config file (which would be modified in future) in app's package during runtime.

The config file is manually written in the project, and should copy into target app's package. How can I achieve that? This may consists of two sub-questions as below:

1) How should I creat the config file in the project? By "New"? Or other Xcode commands or options?

2) How to make Xcode automatically copy the config file during building the app?

Thank you very much!!

Was it helpful?

Solution

1) Yes, you can use XCode's New command to create a new file. Specifically, New > New File... and you'll probably want to choose the Other > Empty template. This will create the file and also add it to your project.

2) Creating a file that is not a source file will probably automatically add it to the target's Copy Bundle Resources build phase. To verify:

  • Select the project in the project navigator
  • Select your target
  • Select the Build Phases tab
  • Expand the Copy Bundle Resources phase

If the new file isn't listed there, you can drag it over from the project navigator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top