Build phase, which creates Plist and copies it in the resource bundle

I created a ruby ​​script that generate Plist from data in a different format (this script is inside the xcode project folder).

I created a script build phase that calls my script:

echo "Running xls Plister" cd ${PROJECT_DIR}/plistr ruby plistr.rb scriptExitStatus=$? echo "DONE with script: (exitStatus=${scriptExitStatus})" exit "${scriptExitStatus}" 

This script displays plist in the following folder ${PROJECT_DIR}/plistr/output/data.plist

I cannot figure out how to copy this to the Bundle resource, so I can access it something like this:

 [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"]; 

EDIT: my actual workaround is to run the script as the first build phase and add a link to the generated plist in "Copy Bundle Resources"

+2
source share
1 answer

You can copy the file to the package as follows:

 cp /tmp/foo.txt ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app 

Please note that copying info.plist to a package is not recommended; it will also issue a warning if it is copied with the build phase of the Bundle copy resources.

See this official expression .

+10
source

Source: https://habr.com/ru/post/1402812/


All Articles