我已经阅读(和搜索)xcodebuild几天了。我有一个iOS应用程序模板,可以交换一些用户定义的变量,如Icons,URLS和应用程序名称,以生成不同的应用程序。
我想使用PHP脚本调用xcodebuildtool来自动编译这些应用程序并通过脚本更改所述变量。
如何在命令行上将这些变量传递给xcodebuild? 这甚至可能吗?
答案 0 :(得分:0)
我不知道怎么做应用名称,但这里是一个bash脚本,我用它来设置一个主图像中的App Icon图像,使用Apple内置的sips来创建较小的图像。然后创建一个json文件来引用这些图像。您可以像这样使用标准的Xcode创建的项目文件结构。 ../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
答案 1 :(得分:0)
xcodebuild手册页指定您可以传入设置。从终端运行man xcodebuild
。
我有一个名为 Tongs 的项目。我刚刚通过运行此命令从该项目构建了 BoBo.app :
xcodebuild build PRODUCT_NAME=BoBo
xcodebuild输出的片段:
Create product structure
/bin/mkdir -p /Users/myid/Code/Tongs/build/Release-iphoneos/BoBo.app