Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Bots do not update git submodules to specified commit

My Xcode Bot is using an outdated version of my repo's submodules.

It builds old submodule code despite the submodule being updated to a new version in the commit history of the parent app.

  1. Parent repo uses submodule v1.0.
  2. Parent repo updates submodule to v2.0 and commits subproject commit to github.
  3. The "on commit" Xcode Bot is run for the new commit automatically.
  4. Parent app is uploaded to TestFlight.
  5. TestFlight build contains the correct v2.0 submodule commit (the last commit to parent repo).
  6. However the TestFlight build contains the outdated submodule v1.0 code.

I thought I was going crazy when my bugs were reproducible on the TestFlight build despite being "fixed" in the submodule and local builds.

It turns out Xcode Bots do not properly pull the specified submodule commit.

like image 664
pkamb Avatar asked Sep 02 '26 14:09

pkamb


1 Answers

A simpler solution to this problem which doesn't require the server having credecentials for your git remotes - add this as a pre-integration script for your bot:

#!/bin/sh
# Enumerates each submodule to check out the desired commit.
# Needed because Xcode bots for some reason prefers to check out
# the branch head, which may result in the wrong commit.
cd "$XCS_PRIMARY_REPO_DIR"
git submodule foreach --recursive 'git checkout $sha1'

It recursively enumerates your submodules and checks out the commit expected by the parent repo.

like image 120
Accatyyc Avatar answered Sep 05 '26 05:09

Accatyyc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!