Xcode: add files to project in a build phase - xcode

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?

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.

Related

premake5: add files to "Copy Bundle Resources" build phase

I have some image files I need to add to an Xcode project. I need the files to be included in the Copy Bundle Resources build phase. I also need Type to be set to Data to avoid any compression or processing by Xcode.
Is this possible with premake5?
You can use a filter to select the files and then do an embed action
filter "files:%{prj.name}/Res/**"
buildaction "Embed"
This example adds all of the files in the Res folder to the Copy Bundle Resources. Although XCode won't show them in the Copy Bundle Resources list they should still show up in the target directory after you build and run the project.
https://github.com/premake/premake-core/wiki/buildaction

how to deploy a custom sub-directory within the project with capistrano?

I couldn't find a way to do this yet with capistrano, but lets say I have a project like
project
project/src
project/Capfile
project/config/deploy.rb
project/config/deploy/production.rb
project/build
project/build/main.js
project/build/other_src.js
so the intention is to deploy only what I have within the /build sub directory within the project.
I realize I can just move the capistrano files to the build directory, but the directory is build and dropped every time I compile the project, so I need to kept the capistrano files within the root dir of the project.
Any advice on how to do it in Capistrano?
I've always deployed the entire project and then pointed my webserver at the relevant subfolder. Alternately, you can write a custom task to rework the data in the release path.

Minify JSON (or XML) in XCode build phase

I'm building an iOS app that frequently loads JSON configuration files at runtime.
However, the files are very generous with comments and indenting.
How can I tell XCode to copy minified versions of the files to the bundle during build?
You just need to add a build phase to your target. Here is an example, my build script that converts a multimarkdown file to an HTML file.
# Create the HTML file from the Markdown File
/usr/local/bin/multimarkdown --process-html --output="${SCRIPT_OUTPUT_FILE_0}" --to=html "${SCRIPT_INPUT_FILE_0}"
# Publish the Help Text and Image to Dropbox
if [ -d ~/Dropbox/Public/DCWS-Help-Text ]; then
rsync -t "${SRCROOT}/DC Wire Sizer/en.lproj/"* ~/Dropbox/Public/DCWS-Help-Text/
fi
I create the file in the source directory but added it to my git ignore file. It is a build product and not in source control, but you need to make sure it is in your project and part of the target, so it gets copied into the bundle. Also make sure your build script runs before your copy bundle phase.

What is the difference between Copy Bundle Resources and Copy Files for Xcode build phases?

Could someone explain the difference between the Copy Bundle Resources phase of Xcode and a Copy Files phase? When would I use "Copy Files"?
Copy Bundle Resources phase copies files that you want to be available in your bundle (.app). On the other hand Copy Files phase copies files to other (standard) locations accessible from your application (for example to /Library/Fonts) giving you also the option to copy them only when installing. You can also see relevant documentation here
Xcode Copy Files vs Copy Bundle Resources
Copy Files - Copies files from a project to an external specified location.
It is useful, for example, when you are creating an Objective-C Static Library where you should expose .modulemap[About] or/and umbrella.h[About] files
Copy Bundle Resources - Copies files that support your source code into internal structure. If you want to make sure the files you added will get copied to the application bundle
It is useful, when you are creating an app where you can add images and other resources
Vocablurary

How to Specify Active Folder for ExternalBuildToolExecution on Xcode 4?

When using a make for an external build system on Xcode 4x, how to specify the active folder?
The active folder appears on the first line cd/
ExternalBuildToolExecution Action
cd /Users/myName/Documents/Xcode/myProject
setenv ACTION
By default, it is the folder of the project, i.e. /Users/myName/Documents/Xcode/myProject.
However, when the project is created by a template, the Xcode project adds a layer:
/Users/myName/Documents/Xcode/myProjec contains myProject.xcodeproject and another folder named
/Users/myName/Documents/Xcode/myProject/myProject with all the source code inside.
So I need to specify /Users/myName/Documents/Xcode/myProject/myProject
An alternative solution would consist on defining the Directory in a Target, but the question What is the key in Xcode template to define Directory in a Target? remains unanswered.

Resources