Xcode Copy Bundle Resources can't find files

故事扮演 提交于 2019-12-20 02:26:12

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/16010452/xcode-copy-bundle-resources-cant-find-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!