typealiased / mockingbird

A Swifty mocking framework for Swift and Objective-C.
https://mockingbirdswift.com
MIT License
656 stars 81 forks source link

CLI upgrading tips #189

Closed okalentiev closed 3 years ago

okalentiev commented 3 years ago

New Issue Checklist

Description

First of all, thank you very much for an amazing mocking framework. It saved so much time for us already 🚀

I'm seeking suggestions on how to upgrade CLI with updates to the Mockingbird dependency. Everything works fine on CI since the CI environment is clean on every build. However, when upgrading lib locally there's a mismatch between CLI and XCode version. I was able to solve it by deleting the existing binary with something like this: rm -rf /usr/local/bin/mockingbird. But I'm wondering if there's a suggested way to do this and maybe a way to automate this.

Currently, we have something like this in our build phase:

which mockingbird 2>&1 >/dev/null
if [ $? -ne 0 ]; then
  DERIVED_DATA=$(dirname $(dirname $BUILD_DIR))
  (cd "${DERIVED_DATA}/SourcePackages/checkouts/mockingbird" && make install-prebuilt)
fi

I'm thinking to add a version check here. However, this is getting too complicated and something tells me that there's a better way 🙂

Environment

andrewchang-bird commented 3 years ago

This is definitely something we want to address very soon. In the meantime, you can pin the binary by changing your script to something like the following (not tested):

DERIVED_DATA=$(dirname $(dirname $BUILD_DIR))
REPO_PATH="${DERIVED_DATA}/SourcePackages/checkouts/mockingbird"
[[ -f "${REPO_PATH}/mockingbird" ]] || (cd "${REPO_PATH}" && make download)

And then change the installed build phase on your test bundle to point to the binary inside the derived data checkout.

okalentiev commented 3 years ago

Thanks for the suggestions!