DataDog / dd-sdk-ios

Datadog SDK for iOS - Swift and Objective-C.
Apache License 2.0
219 stars 127 forks source link

Xcode Cloud - a resolved file is required (dependencies were added: 'framer'). #1984

Closed iosdec closed 2 months ago

iosdec commented 3 months ago

Describe the bug

When building with Xcode Cloud, there's an error that occurs when using Carthage:

carthage update --use-xcframeworks --platform iOS --no-use-binaries

Cartfile contents (using previous version, because latest has issue for me with DatadogPrivate being missing):

github "DataDog/dd-sdk-ios" "2.10.0"

All works perfectly locally, but with Xcode Cloud I receive the following errors:

A shell task (/usr/bin/xcrun xcodebuild -project /Volumes/workspace/repository/Carthage/Checkouts/dd-sdk-ios/DatadogSessionReplay/SRSnapshotTests/SRSnapshotTests.xcodeproj CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list) failed with exit code 74:

2024-08-01 01:44:15.903 xcodebuild[6725:26775] Writing error result bundle to /var/folders/cy/nwzds5px5v13hvt6ndwvg1d80000gn/T/ResultBundle_2024-01-08_01-44-0015.xcresult

xcodebuild: error: Could not resolve package dependencies:

a resolved file is required when automatic dependency resolution is disabled and should be placed at /Volumes/workspace/repository/Carthage/Checkouts/dd-sdk-ios/DatadogSessionReplay/SRSnapshotTests/SRSnapshotTests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved. Running resolver because the following dependencies were added: 'framer' (https://github.com/ncreated/Framer)

Reproduction steps

Update Cartfile with:

github "DataDog/dd-sdk-ios" "2.10.0"

Run Xcode Cloud with ci_post_clone.sh script:

#!/bin/sh

echo "Attempting to install carthage..."

brew install carthage

echo "Attempting carthage update command..."

cd ../

carthage update --use-xcframeworks --platform iOS --no-use-binaries

SDK logs

A shell task (/usr/bin/xcrun xcodebuild -project /Volumes/workspace/repository/Carthage/Checkouts/dd-sdk-ios/DatadogSessionReplay/SRSnapshotTests/SRSnapshotTests.xcodeproj CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list) failed with exit code 74:

2024-08-01 01:44:15.903 xcodebuild[6725:26775] Writing error result bundle to /var/folders/cy/nwzds5px5v13hvt6ndwvg1d80000gn/T/ResultBundle_2024-01-08_01-44-0015.xcresult

xcodebuild: error: Could not resolve package dependencies:

a resolved file is required when automatic dependency resolution is disabled and should be placed at /Volumes/workspace/repository/Carthage/Checkouts/dd-sdk-ios/DatadogSessionReplay/SRSnapshotTests/SRSnapshotTests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved. Running resolver because the following dependencies were added: 'framer' (https://github.com/ncreated/Framer)

Expected behavior

That the carthage update command runs successfully.

Affected SDK versions

2.10.0 +

Latest working SDK version

n/a

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

Carthage

Xcode Version

15.4

Swift Version

5.0

MacOS Version

Latest

Deployment Target

16.0

Device Information

No response

Other relevant information

No response

maxep commented 3 months ago

Hey @iosdec 👋

Thank you for the detailed report 👍

That's interesting:

xcodebuild: error: Could not resolve package dependencies:

a resolved file is required when automatic dependency resolution is disabled and should be placed at /**/*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved.

And Xcode Cloud documentation state the following:

Following the best practice for using Swift package dependencies in a CI/CD environment, Xcode Cloud doesn’t use automatic package resolution and instead relies on the Package.resolved file to resolve your dependencies. If you use Swift package dependencies in your project, make sure to include the Package.resolved file in your Git repository and commit any changes to it. Don’t include the file in your .gitignore file. Additionally, make sure the Package.resolved file resides at $filename.xcodeproj/project.workspace/xcshareddata/swiftpm/Package.resolved.

So we should commit the Package.resolved in our testing Xcode projects.

That being said, I would also recommend using our pre-built binaries by removing the --no-use-binaries argument when invoking carthage. It will workaround this issue and speed up your build.

iosdec commented 3 months ago

Hey @iosdec 👋

Thank you for the detailed report 👍

That's interesting:

xcodebuild: error: Could not resolve package dependencies:

a resolved file is required when automatic dependency resolution is disabled and should be placed at /**/*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved.

And Xcode Cloud documentation state the following:

Following the best practice for using Swift package dependencies in a CI/CD environment, Xcode Cloud doesn’t use automatic package resolution and instead relies on the Package.resolved file to resolve your dependencies. If you use Swift package dependencies in your project, make sure to include the Package.resolved file in your Git repository and commit any changes to it. Don’t include the file in your .gitignore file. Additionally, make sure the Package.resolved file resides at $filename.xcodeproj/project.workspace/xcshareddata/swiftpm/Package.resolved.

So we should commit the Package.resolved in our testing Xcode projects.

That being said, I would also recommend using our pre-built binaries by removing the --no-use-binaries argument when invoking carthage. It will workaround this issue and speed up your build.

I can confirm after updating my ci script to remove --no-use-binaries, the carthage update command was successful, and I have a build uploaded with Xcode Cloud! Also saves much more time using prebuilt binaries.

Thank you very much!