1

Problem

I've attempted to add pre-action shell scripts that would switch on/off certain definitions in my .pch file depending on what I was building for.

However, when running a build, nothing happens. I'm not a fluent shell scripter, so the solution may be my incorrect syntax, but Xcode won't tell me anything.

Details

Here's some code:

prefix=${PROJECT_DIR}/${GCC_PREFIX_HEADER}

sed -i 's/source/working/' $prefix
sed -i 's/\/\/#define\ HOCKEYAPP_BUILD/#define\ HOCKEYAPP_BUILD' $prefix
sed -i 's/\/\/#define\ FLURRY_ENABLED/#define\ FLURRY_ENABLED' $prefix
sed -i 's/\/\/#define\ PRODUCTION_BUILD/#define\ PRODUCTION_BUILD' $prefix

I added the first line to test if it would even remove a basic word I know is in the .pch file. It didn't. This leads me to believe that my path is invalid.

I've tried several different variations of the .pch file's path and have failed with all of them, though they all could have been wrong.

Thank you for your help

Rob Caraway
  • 3,856
  • 3
  • 30
  • 37
  • Why don't you use e.g. ```#ifdef DEBUG ...``` in the .pch file? – SAE Mar 09 '13 at 18:12
  • See: "Adding script files to an Xcode archive", http://stackoverflow.com/questions/7188704/adding-script-files-to-an-xcode-archive/, esp. the reference to how to use pre-action scripts. –  Mar 09 '13 at 18:29
  • SAE: Sometimes I need to have these turned on during Debugging and sometimes not. – Rob Caraway Mar 09 '13 at 18:33
  • Use plenty of echoes to get details on your scripting progress. – Till Mar 09 '13 at 21:36

1 Answers1

1

Your sed lines seem not to be correct. Try:

prefix=${PROJECT_DIR}/${GCC_PREFIX_HEADER}

sed -i -e 's/source/working/' $prefix
sed -i -e 's/\/\/#define\ HOCKEYAPP_BUILD/#define\ HOCKEYAPP_BUILD/' $prefix
sed -i -e 's/\/\/#define\ FLURRY_ENABLED/#define\ FLURRY_ENABLED/' $prefix
sed -i -e 's/\/\/#define\ PRODUCTION_BUILD/#define\ PRODUCTION_BUILD/' $prefix
Matthias
  • 8,018
  • 2
  • 27
  • 53
  • 1
    The `-e` marks the following argument as the actual code to execute. It is not needed by any `sed`, but you are on the safe side using it. More important is the closing slash at the end of the substitution term: without that slash, the term is incorrect. – Matthias Mar 13 '13 at 20:13