在寫作Xcode時,有時需要及時地產生一些輸入檔,而這些輸入檔卻希望使用一些外部程式來產生,因此xcode提供一個執行外部程式的一個run script的方法。這方便一些需要預先處理的輸入。
1. 在一個Project中,增加一個run script的phase
2. 可以為這個run scipt取一個代號
3. 如果只是要用到shell的指令,shell部分只需使用/bin/sh,如果要使用其他的程式如Ruby則需要另外設定如/usr/bin/ruby之類。另外Input File及Output File可不設定,直接使用程式輸出即可。
另外可以使用xcrun這個指令來執行SDK中的一些工具,例如使用iphoneos這個SDK中的texturetool
xcrun -sdk iphoneos texturetool -m -e PVRTC --bits-per-pixel-4 -o "$SRCROOT/Images/Brick_mipmap_4.pvr" -f PVR "$SRCROOT/Images/Brick.png"
其中texturetool的目錄在
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
參考說明
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcrun.1.html
shell的官方參考網頁
https://developer.apple.com/library/mac/#documentation/OpenSource/Conceptual/ShellScripting/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004268-TP40003516



沒有留言:
張貼留言