diff --git a/.github/scripts/verifyPodfile.sh b/.github/scripts/verifyPodfile.sh index 3a57a736cd70..82906f2564b4 100755 --- a/.github/scripts/verifyPodfile.sh +++ b/.github/scripts/verifyPodfile.sh @@ -13,10 +13,10 @@ declare EXIT_CODE=0 # Check Provisioning Style. If automatic signing is enabled, iOS builds will fail, so ensure we always have the proper profile specified info "Verifying that automatic signing is not enabled" if grep -q 'PROVISIONING_PROFILE_SPECIFIER = chat_expensify_appstore' ios/NewExpensify.xcodeproj/project.pbxproj; then - success "Automatic signing not enabled" + success "Automatic signing not enabled" else - error "Error: Automatic provisioning style is not allowed!" - EXIT_CODE=1 + error "Error: Automatic provisioning style is not allowed!" + EXIT_CODE=1 fi PODFILE_SHA=$(openssl sha1 ios/Podfile | awk '{print $2}') @@ -26,10 +26,26 @@ echo "Podfile: $PODFILE_SHA" echo "Podfile.lock: $PODFILE_LOCK_SHA" if [[ "$PODFILE_SHA" == "$PODFILE_LOCK_SHA" ]]; then - success "Podfile checksum verified!" + success "Podfile checksum verified!" else - error "Podfile.lock checksum mismatch. Did you forget to run \`npx pod-install\`?" - EXIT_CODE=1 + error "Podfile.lock checksum mismatch. Did you forget to run \`npx pod-install\`?" + EXIT_CODE=1 +fi + +info "Ensuring correct version of cocoapods is used..." + +POD_VERSION_REGEX='([[:digit:]]+\.[[:digit:]]+)(\.[[:digit:]]+)?'; +POD_VERSION_FROM_GEMFILE="$(sed -nr "s/gem \"cocoapods\", \"~> $POD_VERSION_REGEX\"/\1/p" Gemfile)" +info "Pod version from Gemfile: $POD_VERSION_FROM_GEMFILE" + +POD_VERSION_FROM_PODFILE_LOCK="$(sed -nr "s/COCOAPODS: $POD_VERSION_REGEX/\1/p" ios/Podfile.lock)" +info "Pod version from Podfile.lock: $POD_VERSION_FROM_PODFILE_LOCK" + +if [[ "$POD_VERSION_FROM_GEMFILE" == "$POD_VERSION_FROM_PODFILE_LOCK" ]]; then + success "Cocoapods version from Podfile.lock matches cocoapods version from Gemfile" +else + error "Cocoapods version from Podfile.lock does not match cocoapods version from Gemfile. Please use \`npm pod-install\` or \`bundle exec pod install\` instead of \`pod install\` to install pods." + EXIT_CODE=1 fi info "Comparing Podfile.lock with node packages..." diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 84f8373ff247..06521d401eb4 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -157,8 +157,21 @@ jobs: ruby-version: '2.7' bundler-cache: true + - name: Cache Pod dependencies + uses: actions/cache@v3 + id: pods-cache + with: + path: ios/Pods + key: ${{ runner.os }}-pods-cache-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: ${{ runner.os }}-pods-cache- + + - name: Compare Podfile.lock and Manifest.lock + id: compare-podfile-and-manifest + run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('ios/Podfile.lock') == hashFiles('ios/Pods/Manifest.lock') }}" >> "$GITHUB_OUTPUT" + - name: Install cocoapods uses: nick-invision/retry@0711ba3d7808574133d713a0d92d2941be03a350 + if: steps.pods-cache.outputs.cache-hit != 'true' || steps.compare-podfile-and-manifest.outputs.IS_PODFILE_SAME_AS_MANIFEST != 'true' with: timeout_minutes: 10 max_attempts: 5 diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 16fffcc2c65e..fd8118895679 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -154,8 +154,21 @@ jobs: ruby-version: '2.7' bundler-cache: true + - name: Cache Pod dependencies + uses: actions/cache@v3 + id: pods-cache + with: + path: ios/Pods + key: ${{ runner.os }}-pods-cache-${{ hashFiles('ios/Podfile.lock') }} + restore-keys: ${{ runner.os }}-pods-cache- + + - name: Compare Podfile.lock and Manifest.lock + id: compare-podfile-and-manifest + run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('ios/Podfile.lock') == hashFiles('ios/Pods/Manifest.lock') }}" >> "$GITHUB_OUTPUT" + - name: Install cocoapods uses: nick-invision/retry@0711ba3d7808574133d713a0d92d2941be03a350 + if: steps.pods-cache.outputs.cache-hit != 'true' || steps.compare-podfile-and-manifest.outputs.IS_PODFILE_SAME_AS_MANIFEST != 'true' with: timeout_minutes: 10 max_attempts: 5 diff --git a/.github/workflows/verifyPodfile.yml b/.github/workflows/verifyPodfile.yml index 64188769f0bd..2cb3efbc7bc3 100644 --- a/.github/workflows/verifyPodfile.yml +++ b/.github/workflows/verifyPodfile.yml @@ -1,13 +1,14 @@ name: Verify Podfile on: + workflow_dispatch: pull_request: types: [opened, synchronize] branches-ignore: [staging, production] paths: - ios/** - "package.json" - - "package-lock.json" + - "package-lock.json" jobs: verify: diff --git a/README.md b/README.md index fce7cee8dcdd..293d752626fd 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ In order to have more consistent builds, we use a strict `node` and `npm` versio * Changes applied to Javascript will be applied automatically via WebPack as configured in `webpack.dev.js` ## Running the iOS app 📱 -For an M1 Mac, read this [SO](https://stackoverflow.com/questions/64901180/how-to-run-cocoapods-on-apple-silicon-m1) for installing cocoapods. +For an M1 Mac, read this [SO](https://stackoverflow.com/questions/64901180/how-to-run-cocoapods-on-apple-silicon-m1) for installing cocoapods. * Install project gems, including cocoapods, using bundler to ensure everyone uses the same versions. In the project root, run: `bundle install` * If you get the error `Could not find 'bundler'`, install the bundler gem first: `gem install bundler` and try again. diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 2bea672171fe..bf6d20954fb8 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1311,4 +1311,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 845537d35601574adcd0794e17003ba7dbccdbfd -COCOAPODS: 1.12.1 +COCOAPODS: 1.11.1