将xcodeproj应用内购买转换为终端(Bash)的pkg文件或如何将xcarchive文件转换为pkg文件? [英] Converting a xcodeproj in-app purchase to a pkg file from terminal (Bash) or how to convert a xcarchive file to a pkg file?

查看:149
本文介绍了将xcodeproj应用内购买转换为终端(Bash)的pkg文件或如何将xcarchive文件转换为pkg文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个bash脚本来自动创建应用内购买pkg文件。

I am trying to create a bash script to automate the creation of in-app purchase pkg files.

我正处于脚本成功创建的全部位置-app购买xcodeproj项目然后使用此命令归档它们

I am at a point that the script creates successfully all in-app purchase xcodeproj projects and then archive them using this command

xcodebuild -scheme $nameOfProject archive

$ nameOfProject 是一个变量,它在循环内保存与in对应的xcodeproj文件的名称-app purchase。

$nameOfProject is a variable that holds, inside a loop, the name of the xcodeproj file correspondent to the in-app purchase.

执行此操作后,我必须打开Xcode的存档部分并手动导出所有存档以创建我需要上传到的pkg文件iTC。

After doing this, I have to open the archive part of Xcode and manually export all archives to create the pkg files that I need to have to upload to iTC.

我可以使用任何命令从终端自动执行此操作吗?

Is there any command that I can use to do this automatically from terminal?

另一件事将提供相同的解决方案:如何将xcarchive文件转换为pkg文件?

Another thing that would provide the same solution would be: how to convert a xcarchive file into a pkg file?

推荐答案

经过一些谷歌搜索和一些测试与应用内购买c ontentProject,我认为您需要使用的是 productbuild 命令行工具。由于我自己只是iOS开发人员,我没有创建安装程序的经验,但我很确定使用此命令行工具创建应用程序内容的pkg文件。

After some googling and some testing with the "In-app purchase content" Project, I think that what you need to use is the productbuild command line tool. Since I am only iOS developer myself, I have no experience with creating installers but I am pretty sure the "pkg" file for the in-app content is created using this command line tools.

要查找正确的参数,您可以参考
https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/OSXWorkflowGuide/DistributingApplications/DistributingApplications.html #// apple_ref / doc / uid / TP40011201-CH5-SW1

To find the correct parameters you can refer to https://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/OSXWorkflowGuide/DistributingApplications/DistributingApplications.html#//apple_ref/doc/uid/TP40011201-CH5-SW1

man

编辑:


要测试XCode的作用,我创建了一个简单的项目

< img src =https://i.stack.imgur.com/ZIjSN.pngalt =Project>


To test what XCode does, I have created a simple project

我存档了它:

And I archived it:

然后我创建了一个简单的程序,我们称之为 ArgumentLogger ,代码是

Then I created a simple program, let's call it ArgumentLogger, the code is

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命令:

Let's have an example - for bash command:

ArgumentLoggger --arg test1 test2 test3

log.txt 将包含

ArgumentLogger
--arg
test1
test2
test3

现在,让我们替换 / usr / bin / productbuild 使用此程序

Now, let's replace /usr/bin/productbuild with this program

sudo mv /usr/bin/productbuild /usr/bin/productbuild_old
sudo mv ArgumentLogger /usr/bin/productbuild

然后在XCode中点击Distribute。

并导出包裹。

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到底发生了什么。

Now we see exactly what XCode did.

第二个文件是生成的文件,我不确定该文件是否还有更多功能,但是在用扩展它之后pkgutil ,内容似乎与从XCode创建的 pkg 中的内容相同。

The second file is the resulting file, I am not sure whether there is something more done with the file or not, but after expanding it with pkgutil, the contents seem to be the same as the ones in the pkg created from XCode.

第一个文件是一个似乎直接从 xcarchive 文件中获取的目录。
让我们看看它的内容

The first file is a directory which seems to be taken directly from the xcarchive file. Let's see its contents

编辑2:

总之, bash 脚本应该是以下行:

Edit 2:
In summary, the bash script should be something along the lines of:

CONTENTS_DIR = $( find "$nameOfProject.xcarchive" -name "InAppPurchaseContent" -type d )
PKG_FILE = "$nameOfProject.pkg"

productbuild --content "$CONTENTS_DIR" "$PKG_FILE"

这篇关于将xcodeproj应用内购买转换为终端(Bash)的pkg文件或如何将xcarchive文件转换为pkg文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆