I'm trying to add a Run Script Build Phase to a target in a custom Project Template for Xcode 4.
Does anyone have any examples, tutorials, or tips on how to do this?
I'm assuming that this will be done in TemplateInfo.plist - but my searches are comming up fruitless.
To add a new build phase, click the Add button (+) and select an appropriate build phase from the pop-up menu. Xcode disables any menu options that aren't valid. For example, Xcode disables the Compile Sources build phase if your target already contains a build phase of that type.
Build Phase means that part or parts of the Category 1 Property or Phase thereof on which HDV proposes to build, isbuilding or has built the Development (and as may be related to the relevant Demolition Phase).
After quite a lot of trial-and-error I've worked it out. This is the extra key needed in the TemplateInfo.plist. This adds a script that will run after the other default build phases.
<key>Targets</key>
<array>
<dict>
<key>BuildPhases</key>
<array>
<dict>
<key>Class</key>
<string>ShellScript</string>
<key>ShellPath</key>
<string>/bin/sh</string>
<key>ShellScript</key>
<string># Just a comment</string>
</dict>
</array>
</dict>
</array>
To answer to @Paulo Faria question, I found a way to add input and output files to a Run script phase (My template uses R.swift, which requires input and output files):
<key>Targets</key>
<array>
<dict>
<key>BuildPhases</key>
<array>
<dict>
<key>Class</key>
<string>ShellScript</string>
<key>ShellPath</key>
<string>/bin/sh</string>
<key>Name</key>
<string>R.swift</string>
<key>ShellScript</key>
<string>"$PODS_ROOT/R.swift/rswift" generate "$SRCROOT/R.generated.swift"</string>
<key>InputFiles</key>
<array>
<string>$TEMP_DIR/rswift-lastrun</string>
</array>
<key>OutputFiles</key>
<array>
<string>$SRCROOT/R.generated.swift</string>
</array>
</dict>
</array>
</dict>
</array>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With