使用xcodebuild自动编译iOS

使用xcodebuild自动编译iOS,xcode,xcodebuild,Xcode,Xcodebuild,几天来,我一直在阅读(并搜索)关于xcodebuild的内容。我有一个iOS应用程序的模板,它交换了一些用户定义的变量,如图标、URL和应用程序名称,以便生成不同的应用程序 我想使用PHP脚本调用xcodebuildtool来自动编译这些应用程序,并通过脚本更改所述变量 如何在命令行上将这些变量传递给xcodebuild? 这可能吗?我不知道如何使用app name,但这里有一个bash脚本,我使用苹果内置的sips从一个主图像设置app图标图像,以创建较小的图像。然后创建一个json文件来引用

几天来,我一直在阅读(并搜索)关于xcodebuild的内容。我有一个iOS应用程序的模板,它交换了一些用户定义的变量,如图标、URL和应用程序名称,以便生成不同的应用程序

我想使用PHP脚本调用xcodebuildtool来自动编译这些应用程序,并通过脚本更改所述变量

如何在命令行上将这些变量传递给xcodebuild?
这可能吗?

我不知道如何使用app name,但这里有一个bash脚本,我使用苹果内置的sips从一个主图像设置app图标图像,以创建较小的图像。然后创建一个json文件来引用这些图像。对于标准的Xcode创建的项目文件结构,您可以这样使用它<代码>。/myScript.sh myImage.png MyProject/MyProject/Images.xcsets/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

xcodebuild手册页指定可以传入设置。从终端运行
manxcodebuild

我有一个名为Tongs的项目。我刚刚通过运行以下命令从该项目构建了BoBo.app:

xcodebuild build PRODUCT_NAME=BoBo
xcodebuild输出的代码段:

Create product structure
/bin/mkdir -p /Users/myid/Code/Tongs/build/Release-iphoneos/BoBo.app

您是为临时发行而建吗?我们不是为临时发行而建。