Xcode 5 bots and Testflight automated builds
Asked Answered
D

2

11

First I have a Mac Mini running Server on Mavericks and have Xcode 5 installed. On the server I have my iOS projects set up with Bots to run automated builds of my Github repo on each commit to master. What I want to find out is if anyone already has configure this kind of setup to work with automated builds being sent to TestFlight.

The script that worked previously with a Jenkins build process is pasted below, but throws an error and doesn't upload when the bot completes it's build. I have this script run on the "post-action" of the archive process of my app.

Server log error:

Print: Entry, "CFBundleVersion", Does Not Exist

error: Specified application doesn't exist or isn't a bundle directory : '/Library/Server/Xcode/Data/BotRuns/Cache/s892fj1n2-f4bb-2514-522v-2a23d0f0c725/DerivedData/Build/Products/Debug-iphoneos/myApp.ipa'

Script:

 PLIST_FILE=$(echo -n "${SRCROOT}/${INFOPLIST_FILE}")
 BUILD_TYPE=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PLIST_FILE}")
 API_TOKEN="<API_TOKEN>"
 TEAM_TOKEN="<SECRET>"

 APP="${BUILD_ROOT}/Debug-iphoneos/${FULL_PRODUCT_NAME}"

/bin/rm "/bots/${PRODUCT_NAME}.ipa"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "/bots/${PRODUCT_NAME}.ipa"

/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"/bots/${PRODUCT_NAME}.ipa" \
-F a      pi_token="${API_TOKEN}" \
-F team_token="${TEAM_TOKEN}" \
-F notes="Build uploaded automatically from server." \
-F distribution_lists="internal"

UPDATE 11/20:

A good resource to try: TestFlight Bots

I didn't get it to work a couple weeks ago but the post has been updated since I last tried.

Dives answered 24/10, 2013 at 7:32 Comment(2)
There is way too much discussion about TestFlight on this thread. The problem has nothing to do with TestFlight and everything to do with the error the xcrun process created: Specified application doesn't exist or isn't a bundle directoryResupine
Unfortunately this doesn't work for Xcode 6Boiling
B
0

This looks like a permissions issue. Are you able to access \Library\XCode\Data folder? I was able to run your script (other than upload to testflight). I had to give read access to \Data and write access to destination folder and I see the ipa created.

Beaune answered 29/10, 2013 at 18:3 Comment(2)
I haven't had the chance to test this yet, I'll let you know if that was the problem. Thanks!Dives
And almost a month later... That didn't completely fix it, but it did help. I still can't get the TestFlight build to upload but I did find another good resource (added link to my original post).Dives
K
0

I am researching ways to switch my team from our Jenkins farm for iOS builds to the new Xcode bots server. I have a very similar problem to solve regarding continuous deployment upon a successful CI build/test.

I don't have an answer (yet), but, wanted to share some things I found that may help you.

Two threads may help give clues to why your TestFlight upload is failing on the bots server.

According to Kra Larivain with this post regarding the CocoaPods CLI and Xcode bots:

  • "the build runs on the bot as an unprivileged user with no shell (_teamsserver with /usr/bin/false as a shell)"

  • "add _teamsserver to the password-less sudoers (%_teamsserver ALL=(ALL) NOPASSWD: ALL in your sudoers file). You probably want to be a little bit more clever and only grant it sudo privilege" for the commands actually needed

  • /Library/Server/Xcode/Data is set to be rw by the _teamsserver user only

  • "add to your pre action the following script, where BUILD_USER is your, well, build user. Make sure you Provide build settings from the main target, SRCROOT won’t be set otherwise (the default is None)." This example is for CocoaPods, but, could be adapted to your use

if [ `whoami` = '_teamsserver' ]; then
echo "running pod install as part of CI build"
chmod 777 /Library/Server/Xcode/Data
cd ${SRCROOT}
rm ./Podfile.lock
rm -rf ./Pods
sudo chown -R BUILD_USER .
sudo -H -u BUILD_USER pod install
sudo chown -R _teamsserver .
fi

You likely seen this already, but, it's worth mentioning for others. Check Justin Miller's post on Xcode and testflight post-archive actions for comparison with your script.

Good luck! Steve

Khania answered 15/11, 2013 at 19:25 Comment(4)
I did see this post before, I'm going to try to get this started again. I added a link to the original post that may help as well. I'll post back with what works for me. Thanks!Dives
@Mark, any progress? I'm new to CI and have been running into the same issues with projects with Cocoapods.Douai
@Douai I worked on it for some time and eventually went back to using Jenkins for the time being, I just couldn't get the TestFlight builds to upload. The best thing (I think) that I tried was this link. On a side note, Apple did recently acquire Burstly (the company that owns TestFlight) source, so maybe we will see some integration with Xcode Server in the near future.Dives
"add to your pre action the following script, where BUILD_USER is your, well, build user" Do you need to set up this somewhere?Codify

© 2022 - 2024 — McMap. All rights reserved.