2

I have a project with a bunch of .png files that I want to convert to PVRTC compressed textures. Right now, I'm using a custom XCode run script phase that looks like this:

TEXTURE_TOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool

$TEXTURE_TOOL -e PVRTC --bits-per-pixel-2 -o "$SRCROOT/images/select_menu_bgs1.pvr" -f PVR "$SRCROOT/images/select_menu_bgs1.png"
$TEXTURE_TOOL -e PVRTC --bits-per-pixel-2 -o "$SRCROOT/images/select_menu_bgs2.pvr" -f PVR "$SRCROOT/images/select_menu_bgs2.png"

but it's annoying to have to make it explicitly include the exact list of files I need converted. (they also need to be added to the input & output properties of the build step, which is the even more annoying part.)

what I would like to do is something easy with "make": have a rule that says "if there's a .pvr in the project, it's built from the corresponding .png using this command line."

Is anything like this possible in XCode?

1 Answer 1

6

Double-click a Target.

Choose the Rules pane, simplify it with the popup Rules Specific to target

Click the Plus button at the bottom of the window.

For the Process: popup, choose the last entry - Source files with names matching, which allows you to enter a file glob pattern.

For Using, choose Custom Script and enter your script below.

Use "${INPUT_FILE_BASE}" eg:

$TEXTURE_TOOL -e PVRTC --bits-per-pixel-2 -o "${INPUT_FILE_BASE}.pvr" -f PVR "${INPUT_FILE_BASE}.png"
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, didn't see that before! I'm not quite sure if I can make it do what I want, since I want to select the rule based on the target filetype, not the source filetype (because not all PNGs want to get compressed this way) but I appreciate the pointer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.