1

In my Xcode project I have a custom build phase which runs a script and downloads some images for use by the app. What I want to do is to automatically add those image to the project during the build. Right now, I have to build once (which downloads the files), and then manually add those files to the project. It works as long as the file names don't change. Instead, I'd like to add all the files in a specific directory to the project.

I've tried setting the Output Files value, as suggested here, like this:

$(PROJECT_DIR)/$(PROJECT_NAME)/External Assets/*

but it doesn't work. Any idea if this can be done?

Community
  • 1
  • 1
TotoroTotoro
  • 17,524
  • 4
  • 45
  • 76
  • Do you want to add the files to the project or to the app? – Aaron Golden Jan 08 '14 at 00:16
  • I want to add them to the project. – TotoroTotoro Jan 08 '14 at 00:20
  • I don't think this can be done, but I also can't really image a case where you would need it. What are you trying to archive and why can't you download the file inside the app? – Sitses Jan 08 '14 at 02:11
  • I want to use these images as the launch icon and the splash screen, as a minimum. I think for all other purposes I can load them into a bundle, like @Chris Lundie has suggested in his answer. – TotoroTotoro Jan 08 '14 at 05:50

1 Answers1

0

Create a directory with the .bundle extension. Add this bundle to your app's resources. When the project builds, it will automatically copy every file in the bundle, even if they are changed or added after you first add the bundle to the project.

Chris Lundie
  • 6,023
  • 2
  • 27
  • 28
  • Thanks. I'll try that tomorrow, and let you know how it goes. I understand, this will give me access to the images through `[UIImage imageNamed:]`, right? – TotoroTotoro Jan 08 '14 at 05:51
  • That may still work OK if you prefix the image name with the bundle name, separated with a slash. – Chris Lundie Jan 08 '14 at 14:54