开发者

Where to start for writing a shell script for copying elements into main app xcode4

开发者 https://www.devze.com 2023-03-24 16:38 出处:网络
I am looking for some documentation or tutorial for copying files from a given directory into the app created by xcode at build time, before it is run.

I am looking for some documentation or tutorial for copying files from a given directory into the app created by xcode at build time, before it is run. At first I have tried to copy files into the derived directory, hoping that everything resides in there would be automatically added to the app, but I was wrong.

So I am looking for a script because the original dir may change its name, second the script could be customized by another xcode 4 user with its src dir path etc. The things is I don't know how to start, which language etc. I am quite confident with shell script, but maybe there's a better option开发者_如何学C. Second, I am trying to figure out which command could add a file in the already built app.

thanks


That answer didn't really help - the BUILT_PRODUCT_DIR isn't where most stuff goes.

Ultimately, I found you just need to do:

  1. Add the following to the very end of your script (or get your script to write directly to the output location):

    cp ${DERIVED_FILE_DIR}/[YOUR OUTPUT FILES] ${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}

...but there's a lot of other things I tried. More thoughts and ideas here: http://red-glasses.com/index.php/tutorials/xcode4-a-script-that-creates-adds-files-to-your-project/


You want a Run Script or Copy Files build phase. Select your main project in the navigator, then select the app's target. Click the Build Phases tab. Click the Add Build Phase button at the bottom of the window and choose the appropriate phase.

By "appropriate" I mean if you really want to run a script, you'll use a Run Script build phase and use Xcode-provided environment variables like $BUILT_PRODUCT_DIR (see the documentation or hit build and examine the full output of an empty script in the build log) to figure out your target folder. If all you want to do is copy files (no real processing), the Copy Files build phase already knows how to locate the app bundle's proper folders depending on what you're copying (Resources, Frameworks, etc.).

0

精彩评论

暂无评论...
验证码 换一张
取 消