Issues with SPM caching

Hello,

Newbie to circleci. App builds successfully, however takes about an hour to build. So trying to cache my SPM frameworks, but seeing this error:

error computing cache key: template: cacheKey:1:13: executing "cacheKey" at <checksum "XXXApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved">: error calling checksum: open /Users/distiller/XXXApp/XXXApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: no such file or directory

I also tried creating a symlink from XXXApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved, dropped the symlink under XXXApp folder - thinking CircleCI is having trouble accessing files inside xcodeproj file - however that didn’t help either. Attaching config.yml

version: 2.1

jobs:
  build:
    working_directory: ~/XXXApp
    macos:
      xcode: "13.1.0"
    environment:
      FL_OUTPUT_DIR: output
      FASTLANE_LANE: dev
    shell: /bin/bash --login -o pipefail
    steps:
      - checkout
      - restore_cache:
          key: spm-cache-{{ checksum "XXXApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}
      - run:
         name: Bundle install
         command: bundle install --gemfile="XXXApp/Gemfile"
      - run:
          name: Fastlane
          command: cd XXXApp; bundle exec fastlane $FASTLANE_LANE
      - save_cache:
          paths:
            - SourcePackages/
          key: spm-cache-{{ checksum "XXXApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}
      - store_artifacts:
          path: output

Found the issue. Hope this is useful to someone.

XXXApp.xcodeproj/project.xcworkspace was part of .gitignore file

So to work that around - I added a Post Build script in XCode that would copy Package.resolved to XXXApp folder. Added XXXApp/Package.resolved to repository.

Also changed path of Package.resolved in config.yml to thus:

version: 2.1

jobs:
  build:
    working_directory: ~/XXXApp
    macos:
      xcode: "13.1.0"
    environment:
      FL_OUTPUT_DIR: output
      FASTLANE_LANE: dev
    shell: /bin/bash --login -o pipefail
    steps:
      - checkout
      - run:
         name: Display contents of current path
         command: ls
      - restore_cache:
          key: spm-cache-{{ checksum "XXXApp/Package.resolved" }}
      - run:
         name: Bundle install
         command: bundle install --gemfile="XXXApp/Gemfile"
      - run:
          name: Fastlane
          command: cd XXXApp; bundle exec fastlane $FASTLANE_LANE
      - save_cache:
          paths:
            - SourcePackages/
          key: spm-cache-{{ checksum "XXXApp/Package.resolved" }}
      - store_artifacts:
          path: output

My fastfile contents look like this:

platform :ios do
  before_all do
    setup_circle_ci
  end
  desc "Dev build for XXX iOS App"
  lane :dev do
    # add actions here: https://docs.fastlane.tools/actions
    build_app(skip_archive: true, skip_codesigning: true, cloned_source_packages_path: "SourcePackages")
  end

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.