0

I've been reading (and searching) about xcodebuild for a few days now. I've got a template for an iOS app that swaps out a few user-defined variables like Icons, URLS, and an app name in order to produce a different app.

I'd like to use a PHP script to call the xcodebuildtool to auto-compile these apps and change said variables through the script.

How would I pass these variables to xcodebuild on the command line? Is this even possible?

Jeff
  • 3,829
  • 1
  • 31
  • 49

2 Answers2

0

I'm not sure how to do app name but here's a bash script I use to set the App Icon images from one master image using Apple's built in sips to create the smaller images. Then creating a json file to reference those images. You would use it like this for a standard Xcode created project file structure. ../myScript.sh myImage.png MyProject/MyProject/Images.xcassets/AppIcon.appiconset/

#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "usage source target"
exit
fi
targetdir="${2%/}"
if [ ! -d $targetdir ]
then
echo "target not directory"
exit
fi

echo $targetdir
sizes=(29 40 50 57 58 72 76 80 100 114 120 144 152 180)
for size in ${sizes[@]};
do
echo $size
sips --setProperty format png -Z $size --out "${targetdir}/icon${size}.png" "$1"
done
echo '{
"images" : [
            {
                "size" : "29x29",
                "idiom" : "iphone",
                "filename" : "icon29.png",
                "scale" : "1x"
            },
            {
                "size" : "29x29",
                "idiom" : "iphone",
                "filename" : "icon58.png",
                "scale" : "2x"
            },
            {
                "size" : "40x40",
                "idiom" : "iphone",
                "filename" : "icon80.png",
                "scale" : "2x"
            },
            {
                "size" : "57x57",
                "idiom" : "iphone",
                "filename" : "icon57.png",
                "scale" : "1x"
            },
            {
                "size" : "57x57",
                "idiom" : "iphone",
                "filename" : "icon114.png",
                "scale" : "2x"
            },
            {
                "size" : "60x60",
                "idiom" : "iphone",
                "filename" : "icon120.png",
                "scale" : "2x"
            },
            {
                "size" : "60x60",
                "idiom" : "iphone",
                "filename" : "icon180.png",
                "scale" : "3x"
            },
            {
                "size" : "29x29",
                "idiom" : "ipad",
                "filename" : "icon29.png",
                "scale" : "1x"
            },
            {
                "size" : "29x29",
                "idiom" : "ipad",
                "filename" : "icon58.png",
                "scale" : "2x"
            },
            {
                "size" : "40x40",
                "idiom" : "ipad",
                "filename" : "icon40.png",
                "scale" : "1x"
            },
            {
                "size" : "40x40",
                "idiom" : "ipad",
                "filename" : "icon80.png",
                "scale" : "2x"
            },
            {
                "size" : "50x50",
                "idiom" : "ipad",
                "filename" : "icon50.png",
                "scale" : "1x"
            },
            {
                "size" : "50x50",
                "idiom" : "ipad",
                "filename" : "icon100.png",
                "scale" : "2x"
            },
            {
                "size" : "72x72",
                "idiom" : "ipad",
                "filename" : "icon72.png",
                "scale" : "1x"
            },
            {
                "size" : "72x72",
                "idiom" : "ipad",
                "filename" : "icon144.png",
                "scale" : "2x"
            },
            {
                "size" : "76x76",
                "idiom" : "ipad",
                "filename" : "icon76.png",
                "scale" : "1x"
            },
            {
                "size" : "76x76",
                "idiom" : "ipad",
                "filename" : "icon152.png",
                "scale" : "2x"
            }
            ],
"info" : {
    "version" : 1,
    "author" : "xcode"
}
}' > ${targetdir}/Contents.json
dave234
  • 4,793
  • 1
  • 14
  • 29
0

The xcodebuild man page specifies that you can pass in settings. Run man xcodebuild from Terminal.

I have a project named Tongs. I just built BoBo.app from that project by running this command:

xcodebuild build PRODUCT_NAME=BoBo

Snippet from xcodebuild output:

Create product structure
/bin/mkdir -p /Users/myid/Code/Tongs/build/Release-iphoneos/BoBo.app
Jeff
  • 3,829
  • 1
  • 31
  • 49