Is there a way to add Swift Package to app extensions?

[Am sorry if this is out of topic, wanted to check if I was missing something from SPM end]

Overview

  • I have a swift package that I have added to the app target.
  • On the app extension target I have added the same package under Frameworks and Libraries.
  • I am able to manually archive successfully
  • When I start an Xcode Cloud build, I get the following error:
An internal error was detected which caused this stage to error. The error has been logged, and you can re-run this build again.

Resolve package dependencies
Command exited with non-zero exit-code: 74

    fatal: could not read Username for 'http://github.com': terminal prompts disabledan out-of-date resolved file was detected at /Volumes/workspace/repository/<app name>.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved, which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies. Running resolver because the following dependencies were added: '<package name>' (https://github.com/<user name>/<package name>.git)2022-11-11 01:21:37.643 xcodebuild[2273:9107] Writing error result bundle to /var/folders/hf/lmqg8qtx531_sq5gwgt5s3ch0000gn/T/ResultBundle_2022-11-11_01-21-0037.xcresult

Make sure that Package.resolved is up to date on the '<branch name>' branch, and that this branch has been pushed to your remote repository.

Save artifacts
Upload <app name> Build 16 Logs for <app name> archive
An internal error occurred while this artifact was being saved.

Questions:

  1. Is that the right way to add a Swift Package to the app extension?
  2. Am I missing something?

Just answering my own question in case somebody encounters a similar situation.

Note:

  • I was using Xcode Cloud

Background

  1. In an Xcode project you can add a specific swift package only once
  2. So when the dependency is already added to the main target, you need not add the same package again for the extension targets
  3. However you need to add the same package under Frameworks and Libraries.

Problem

In my case the package.resolved existed, however in AppStoreConnect I didn't grant permission to access the Swift Package

Solution

Go to AppStoreConnect > App name > Xcode Cloud, repositories and notice that the swift package didn't have access, so grant it and then it worked