如何从 Xcode Bot 将自动构建部署到 TestFlight?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19555107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:10:37  来源:igfitidea点击:

How do I deploy automated builds to TestFlight from an Xcode Bot?

iosxcodecontinuous-integrationbuild-automationtestflight

提问by mattv123

I spent a good amount of time formatting the mentioned blog with code, screenshots, and etc. that is too much effort to duplicate here on Stack Overflow. That said I figured the community would want some help in this arena (I struggled for a long time figuring it all out), so I posted this question and respective answer. If you still think that the intent of this post is nefarious, please comment as such and I'll delete it!

我花了很多时间用代码、屏幕截图等格式化提到的博客。也就是说,我认为社区会在这个领域需要一些帮助(我努力解决了很长时间),所以我发布了这个问题和相应的答案。如果你仍然认为这篇文章的意图是邪恶的,请发表评论,我会删除它!

The question is: how do I configure my fancy new Xcode server with Bots to continuously integrate and send completed builds to my testers via test flight? To me, this seems like the holy grail of CI in the iOS world, so I spent a lot of time to figure it out.

问题是:如何使用 Bots 配置我喜欢的新 Xcode 服务器,以通过试飞持续集成并发送已完成的构建给我的测试人员?对我来说,这似乎是 iOS 世界中 CI 的圣杯,所以我花了很多时间来弄明白。

The process involves some manual work that just doesn't seem to get done properly by the XCode server software in Mavericks, at least in the initial release. It took me a lot of time and even some scripting to figure it all out and make it work, and I'm happy to share the results.

该过程涉及一些手动工作,至少在初始版本中,Mavericks 中的 XCode 服务器软件似乎无法正确完成这些工作。我花了很多时间,甚至编写了一些脚本来弄清楚并使其工作,我很高兴分享结果。

For the sake of adding value to this question, I've posted the post-op script that you should run during the Archive process below. The link to my blog below provides step by step details should you need more information.

为了给这个问题增加价值,我已经发布了您应该在下面的存档过程中运行的术后脚本。如果您需要更多信息,下面指向我的博客的链接提供了分步详细信息。

#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Valid and working as of 10/29/2013
# Xcode 5.0.1, XCode Server 
#
API_TOKEN="<Your TesFlight API Token>"
TEAM_TOKEN="<Your TestFlight Team Token>"
DISTRIBUTION_LISTS="<Comma separated TestFlight Distribution List Names for auto deploy>"
PROVISIONING_PROFILE="/Library/Server/Xcode/Data/ProvisioningProfiles/<your file name here>.mobileprovision"
#EXAMPLE:"/Library/Server/Xcode/Data/ProvisioningProfiles/DocLink_InHouse_2013.mobileprovision"

SIGNING_IDENTITY="<your provisioning profile name here>"
#EXAMPLE:"iPhone Distribution: Unwired Revolution, LLC."

# DO NOT EDIT BELOW HERE!
########################################
DSYM="/tmp/Archive.xcarchive/dSYMs/${PRODUCT_NAME}.app.dSYM"

IPA="/tmp/${PRODUCT_NAME}.ipa"

APP="/tmp/Archive.xcarchive/Products/Applications/${PRODUCT_NAME}.app"

# Clear out any old copies of the Archive
echo "Removing old Archive files from /tmp...";
/bin/rm -rf /tmp/Archive.xcarchive*

#Copy over the latest build the bot just created
echo "Copying latest Archive to /tmp/...";
LATESTBUILD=$(ls -1rt /Library/Server/Xcode/Data/BotRuns | tail -1)
/bin/cp -Rp "/Library/Server/Xcode/Data/BotRuns/${LATESTBUILD}/output/Archive.xcarchive" "/tmp/"

echo "Creating .ipa for ${PRODUCT_NAME}"
/bin/rm "${IPA}"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "${IPA}" --sign "${SIGNING_IDENTITY}" --embed "${PROVISIONING_PROFILE}"

echo "Done with IPA creation."

echo "Zipping .dSYM for ${PRODUCT_NAME}"
/bin/rm "${DSYM}.zip"
/usr/bin/zip -r "${DSYM}.zip" "${DSYM}"

echo "Created .dSYM for ${PRODUCT_NAME}"

echo "*** Uploading ${PRODUCT_NAME} to TestFlight ***"
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"${IPA}" \
-F dsym=@"${DSYM}.zip" \
-F api_token="${API_TOKEN}" \
-F team_token="${TEAM_TOKEN}" \
-F distribution_lists="${DISTRIBUTION_LISTS}" \
-F notes="Build uploaded automatically from Xcode Server Bot."

echo "TestFlight upload finished!"

I hope all the time I spent on it will save the community collectively a lot more of theirs!

我希望我花在它上面的所有时间都能为社区集体拯救更多的人!

Here is the link: http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/

这是链接:http: //matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/

采纳答案by mattv123

Here is a link to a post that outlines how to create an Xcode bot, connected to a 3rd party git repository, with automated deployment of builds to TestFlight:

这是一篇文章的链接,该文章概述了如何创建一个 Xcode bot,连接到 3rd 方 git 存储库,并自动将构建部署到 TestFlight:

http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/

http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/

Hope it helps! Please sound off with your comments or feedback.

希望能帮助到你!请提出您的意见或反馈。