Pod Install in Xcode Bots Trigger

那年仲夏 提交于 2019-12-21 05:06:59

问题


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.


回答1:


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.




回答2:


#!/bin/sh
cd ProjectDirectory
/usr/local/bin/pod install



回答3:


Set the default path, execute the .bash_profile and then your bot runs just like a normal user

#!/bin/sh
cd $XCS_PRIMARY_REPO_DIR
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands"
. ~/.bash_profile
bundle install
pod install --repo-update

P.s. bundle install installs all gems specified in my Gemfile which looks like this (So you can have different gem requirements per bot):

source 'https://rubygems.org'
gem 'cocoapods', '1.3.1'


来源:https://stackoverflow.com/questions/39521369/pod-install-in-xcode-bots-trigger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!