Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pod Install in Xcode Bots Trigger

I started the pre integration trigger with the following

cd "${XCS_PRIMARY_REPO_DIR}"
pwd
pod install --verbose

And it gave me

pod: command not found

Simple right? Can't find the pod binary so, I'll just point it over to the path. Easy.

cd "${XCS_PRIMARY_REPO_DIR}"
pwd
/usr/local/bin/pod install --verbose

Which gives me the following

env: ruby_executable_hooks: No such file or directory

This makes me think ruby isn't set up right to run for the triggers. Now understand a simple "pod install" in the terminal of the build server fixes all this and runs fine and dandy. The project definitely builds properly on the build server.

So since I think the environment is messed up, I'll try to run it from the wrapper directory, that should set up good and nice. That's what it's made for right? This worked historically whenever I needed ruby to run in a run script phase of the build. So here we go on the trigger.

~/.rvm/wrappers/ruby-2.2.3@global/pod install

I test this one in the terminal of the build server and it's cool with it, so I put it into the trigger and I get this

/Users/XcodeServer/.rvm/wrappers/ruby-2.2.3@global/pod: line 7: exec: pod: not found

:/ Alright I crack up the pod source and see what it says on line 7

exec pod "$@"

I'm not a ruby person but it didn't mean anything to me. Oh yeah and I tried downloading cocoapods directly into usr/local/bin, rather than letting it install into some other directory, by first uninstalling all cocoapods and then by doing the following

sudo gem install -n /usr/local/bin cocoapods --pre

I put --pre because I needed 1.1.0.rc.2 to fix a bug with building swift 3. Any who, it all doesn't work. It seems like everyone else can simply put

cd /path/to/proj/
pod install

into their Xcode bot triggers and have them work.

like image 416
Biclops Avatar asked Sep 15 '16 22:09

Biclops


People also ask

How does POD install work?

This is to be used the first time you want to retrieve the pods for the project, but also every time you edit your Podfile to add, update or remove a pod. Every time the pod install command is run — and downloads and install new pods — it writes the version it has installed, for each pods, in the Podfile.

What is create bot in Xcode?

Bots are processes that Xcode Server runs to perform integrations on the current version of a project in a source code repository. An integration is a single run of a bot. Integrations consist of building, analyzing, testing, and archiving the apps (or other software products) defined in your Xcode projects.


2 Answers

I had the trigger run a script on the build server that did the pod install.

So make a shell script on your build server that has the following:

#make sure the encoding is correct
export LANG=en_US.UTF-8

# fix the path so Ruby can find it's binaries
export PATH=/usr/local/bin:$PATH
echo "PATH: $PATH"

# update or install depending on what we got
if [ -d ${PODS_DIR} ]; then 
    # pods directory exist
    echo "=================="
    echo "   Delete Pods"
    echo "=================="

    # delete cocoapods files if they exist
    rm -rf "${PODS_DIR}"
    eval rm "${BS_SRCROOT}/Podfile.lock"
    eval rm -rf "${BS_SRCROOT}/${BS_EXECUTABLE_NAME}.workspace"
    echo "Deleted Pods directory ${PODS_DIR}"
    echo "Deleted ${BS_EXECUTABLE_NAME}.workspace"
    echo "Deleted Podfile.lock"
else 
    # no need to delete pod files
    echo "Pods NOT detected at ${PODS_DIR}"
fi

echo "=================="
echo "   Install Pods"
echo "=================="

# make sure we are where we need to be
eval cd "${BS_SRCROOT}"
pwd
~/.rvm/wrappers/ruby-2.2.3@global/pod install

Remember to use the 'sh' suffix when naming the script. And then in your bot trigger run the script like this

sh ~/Path/to/Scripts/podUpdateHack.sh

Kind of silly but it works, ¯\_(ツ)_/¯ Oh yeah all those dumb evals are there because the BS_SRCROOT is an environment variable on XCode bots, which references the environment variable $XCS_PRIMARY_REPO_DIR. You can just replace it with $XCS_PRIMARY_REPO_DIR and remove the eval. I don't remember who defines PODS_DIR that might be from the workspace and BS_EXECUTABLE_NAME is a redefinition of the executable name from the project since it doesn't exist at this point in time.

Hope that helps homie.

like image 192
Biclops Avatar answered Sep 30 '22 17:09

Biclops


#!/bin/sh
cd ProjectDirectory
/usr/local/bin/pod install
like image 38
Kirit Vaghela Avatar answered Sep 30 '22 17:09

Kirit Vaghela