d3p0nit
d3p0nit

Reputation: 442

Xcode Copy Bundle Resources can't find files

Xcode can't find my Storyboards and my Info.plist in my Copy Bundle Resources, So my App doesn't run. I tried to add the Existing files again but they always appear red highlighted. I'm pretty sure it must be a local problem because when i clone the latest update from my repository on my other mac its runs without any problems. I already tried to re-install Xcode, delete files from Xcode/DerivedData and i also deleted the com.apple.Xcode.plist. Anyone any ideas?

Upvotes: 3

Views: 7444

Answers (2)

Wilbo Baggins
Wilbo Baggins

Reputation: 2751

My experience is that the proposed solution works, but cleaning and re-compiling the entire app whenever a resource has changed is very tedious, especially for larger projects.

Therefore I came up with this solution that forces fresh resources in the app on a per-directory basis, without having to clean or recompile:

  1. Add a 'Run Script Build Phase' (Editor > Add Build Phase > Add Run Script Build Phase)
    1. Copy/paste the following script into the build phase (don't forget to set the actual paths on line 1):

dirsToCopy=("path1/directory1","path2/directory2")

for INPATTERN in "${dirsToCopy[@]}"; do
    INDIR=$PROJECT_DIR/$INPATTERN/*
    OUTDIR=$TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH/$INPATTERN
    cp -R $INDIR $OUTDIR
done

For those not used to working with shell scripts:

  • paths on line 1 of the script are relative to the project directory (where the .xcodeproj file resides)

  • you can add more (or less) paths to the array dirsToCopy if you want

  • you can change the pattern of files to copy where variable INDIR is defined

  • you can change how the copying is done (currently, recursive due to -R) by changing the flags to cp in the last line of script within the for block.

Upvotes: 0

Vostro162
Vostro162

Reputation: 124

Try to reset your Simulator and then clean your App Build Folder

Upvotes: 4

Related Questions