Jonas
Jonas

Reputation: 474

Xcode IDE not showing download file in directory using Run Script

I'm having trouble with the 'Run Script' in the Xcode IDE. I'm able to download a file from a server using this script below, straight into a directory in Xcode, which can be viewed, by way of right clicking on the folder in the IDE where the download has been sent to, however although it appears here, its not appearing in the 'Copy Bundle Resources' nor in the Xcode resources folder, so when trying to pull this file into the code, I get file doesn't exist.

I'm aware of how to add the file manually(+), however this would be better if it run's automatically in the script.

Can anyone help with this Bash Script below, I've tried to copy (cp) to ${PRODUCTS_DIR} and ${BUILT_PRODUCTS_DIR} but its not copying over for some reason. I'm able to (mv) move the file but still this does appear in the 'Copy Bundle Resources'? Anyone got any clues to this? Thanks in advance.

fileToDownload=$(ssh $Username@server1 ls -t /doc_test_control/the_test_foler/myFile.txt)
echo "File to download: $fileToDownload"


scp $Username@server1:$fileToDownload "${SRCROOT}/Mobile-App-iOS/Test_Foler/"
echo "File downloaded to : ${SRCROOT}/"

mv "${SRCROOT}/Mobile-App-iOS/Test_Foler/""* "${BUILT_PRODUCTS_DIR}"

ls -l "${SRCROOT}/Mobile-App-iOS/Test_Foler/"
echo "DONE"

Upvotes: 0

Views: 463

Answers (1)

Anand
Anand

Reputation: 1946

It looks like you need to copy the downloaded file inside the Bundle using bash commands in the Run Script phase itself. Please use the following script to copy the resource to the bundle.

cp downloadedFile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/

UNLOCALIZED_RESOURCES_FOLDER_PATH is nothing but app path itself. Please see its value in Build logs.

export UNLOCALIZED_RESOURCES_FOLDER_PATH=TestProject.app

I tested this with my local file in Desktop folder and found it to be working.

You cannot use "Copy Bundle Resource" phase to copy the downloaded file at compile time. Because, to use "Copy Bundle Resource", it has to be added to the Target which is not possible when it is downloaded during compile time.

Upvotes: 1

Related Questions