简体   繁体   English

新创建的存档的 xcodebuild 存档路径

[英]xcodebuild archive path of newly created archive

When I archive from the command line using xcodebuild archive , how can I get the path to the newly created archive?当我使用xcodebuild archive从命令行xcodebuild archive ,如何获取新创建的存档的路径? I'd like to follow on with an -exportArchive command to create an adhoc distribution.我想继续使用-exportArchive命令来创建临时分发。

I know that I can define an -archivePath , however if I do that then Organizer doesnt know where about this archive, so that's no good.我知道我可以定义一个-archivePath ,但是如果我这样做,那么组织者不知道这个档案在哪里,所以这是不好的。

Thoughts?想法?

you can simply create a variable holding the path of the archive you want to generate.您可以简单地创建一个变量来保存要生成的存档的路径。 Then use the same path when you want to export然后要导出时使用相同的路径

$ARCHIVE_PATH="<path_of_your_archive>" # can be something like "build/app_name.xcarchive"

# ARCHIVING

xcodebuild archive \
    -workspace "${APP_NAME}.xcworkspace" \
    -configuration $CONFIGUATION \
    -scheme $SCHEME \
    -archivePath $ARCHIVE_PATH

# EXPORTING

xcodebuild -exportArchive \
     -archivePath $ARCHIVE_PATH \
     -exportPath $OUTPUT_DIRECTORY \
     -exportOptionsPlist exportPlist.plist

Hope this helps you in any way!希望这可以以任何方式帮助您!

There's $ARCHIVE_PATH variable that's only available in archive post-actions scripts$ARCHIVE_PATH变量仅在存档后操作脚本中可用在此处输入图片说明

Edit: $ARCHIVE_PATH returns a kind of generic path that doesn't account for the date, time, or duplicate suffixes.编辑: $ARCHIVE_PATH返回一种不考虑日期、时间或重复后缀的通用路径。

Use $ARCHIVE_PRODUCTS_PATH instead.请改用$ARCHIVE_PRODUCTS_PATH Or actually REAL_ARCHIVE_PATH=$(dirname ${ARCHIVE_PRODUCTS_PATH}) .或者实际上REAL_ARCHIVE_PATH=$(dirname ${ARCHIVE_PRODUCTS_PATH})

Assuming that you have a standard archives path on your machine, I use this python code to get me the current archive path for builds.假设你的机器上有一个标准的档案路径,我使用这个 python 代码来获取构建的当前档案路径。

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import datetime

class Xcodebuild:

    @staticmethod
    def current_archive_path():
        # The default archives path is as follows
        #
        #    /Users/<USER>/Library/Developer/Xcode/Archives/<YYYY>-<MM>-<DD>
        #
        home = os.path.expanduser("~")
        archives_path = os.path.join(home, "Library/Developer/Xcode/Archives")

        if not os.path.isdir(archives_path):
            exit("error: Xcode archives directory not found at {}".format(archives_path))

        dirname = str(datetime.date.today())
        archive_path = os.path.join(archives_path, dirname)

        if not os.path.exists(archive_path):
            os.makedirs(archive_path)

        return archive_path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM