经过一些谷歌搜索和“应用内购买内容”项目的一些测试后,我认为您需要使用的是productbuild
命令行工具。由于我自己只是 iOS 开发人员,因此我没有创建安装程序的经验,但我非常确定应用程序内内容的“pkg”文件是使用此命令行工具创建的。
要找到正确的参数,您可以参考https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/OSXWorkflowGuide/DistributingApplications/DistributingApplications.html#//apple_ref/doc/uid/TP40011201-CH5-SW1 https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/OSXWorkflowGuide/DistributingApplications/DistributingApplications.html#//apple_ref/doc/uid/TP40011201-CH5-SW1
or man
.
Edit:
To test what XCode does, I have created a simple project
And I archived it:
然后我创建了一个简单的程序,我们称之为ArgumentLogger
,代码是
int main(int argc, const char* argv[]) {
//Open a file for logging
FILE* file = fopen("/Users/Sulthan/Desktop/log.txt","a+");
for (int i = 0; i < argc; i++) {
//log all parameters
fprintf(file, "%s\n", argv[i]);
}
//end
fclose(file);
return 0;
}
让我们举一个 bash 命令的例子:
ArgumentLoggger --arg test1 test2 test3
log.txt
将包含
ArgumentLogger
--arg
test1
test2
test3
现在,我们来替换/usr/bin/productbuild
有了这个程序
sudo mv /usr/bin/productbuild /usr/bin/productbuild_old
sudo mv ArgumentLogger /usr/bin/productbuild
and then hit "Distribute" in XCode.
and export the package.
log.txt
现在包含
/usr/bin/productbuild
--content
/var/folders/v5/wwrmfpqx2mx1q5sf67_6vgg00000gn/T/FDCEA38E-1EF6-490B-8C30-8B0675C56CC8-47322-00014822C462D3CD/TestContent
/var/folders/v5/wwrmfpqx2mx1q5sf67_6vgg00000gn/T/FDCEA38E-1EF6-490B-8C30-8B0675C56CC8-47322-00014822C462D3CD/TestContent.pkg
现在我们确切地看到 XCode 做了什么。
第二个文件是生成的文件,我不确定该文件是否还有更多处理,但在使用pkgutil
,内容好像和里面的一样pkg
从 XCode 创建。
The first file is a directory which seems to be taken directly from the xcarchive
file.
Let's see its contents
Edit 2:
综上所述,bash
脚本应该是这样的:
CONTENTS_DIR = $( find "$nameOfProject.xcarchive" -name "InAppPurchaseContent" -type d )
PKG_FILE = "$nameOfProject.pkg"
productbuild --content "$CONTENTS_DIR" "$PKG_FILE"