I've got an Xcode project with a build phase that copies some files around. Say I want to copy all rtf files from [project directory]/foo/bar to [project directory]/bar/foo. I would use a command like this:
cp -v foo/bar/*.rtf bar/foo/
Executing this in Terminal does exactly what I expect: all rtf files in foo/bar are copied to bar/foo. But when building, I get a build error from cp:
Cp: foo/bar/*.rtf: No such file or directory
cp can't seem to find the files. It's as if bash isn't expanding the wildcard. I know I'm in the right directory when the script runs, because I've run pwd before cp and it gives what I expect. And I've set the Shell of the script phase to /bin/bash. What am I doing wrong? Can I not use globs in Run Script build phases? If so, why?
Update: I found out that you can turn off globbing in bash like this:
set -o noglob
And turn it back on like this:
set +o noglob
And see all bash options and their status like this:
set -o
I tried using the latter in my Run Script phase and it shows that noglob is disabled. So noglob is not the issue here.
foo/bar/*.rtfisn't matching anything, so it is passed as a literal string tocp. This is either because the current working directory is not[project directory], or because there are no RTF files infoo/bar. - chepner