XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Package.resolved isn't versioned; How are deterministic Package versions achieved?

Open mayurdhaka-suryasoftware opened this issue 6 years ago • 2 comments

(Xcodegen version 2.10.1)

Hey!

I'm trying to migrate our iOS project that uses Xcodegen, to start using a SwiftPM library we use internally. As part of doing this, I am specifying, in my project.yml, the SwiftPM dependency to use. However, in trying to attempt this, I run into the following problem that is fundamentally at odds with Xcodegen:

  1. From this article I understand that the Package.resolved file--used for making sure all developers are using the same version of packages is stored in the .xcodeproj directory. Here's the relevant quote:

You can find the Package.resolved file inside your .xcodeproj directory at [appName].xcodeproj/project.workspace/xcshareddata/swiftpm/Package.resolved

  1. However, the premise of using Xcodegen is that the repository is able to discard the .xcodeproj folder and related artefacts. So the Package.resolved file can also not be checked in.
  2. How then do developers of a repository get deterministically same versions of their dependencies? I may be missing something here.

Hi @mayurdhaka-suryasoftware. While you don't need to check in the whole xcodeproj, you must check in the Package.resolved file as mentioned here https://github.com/yonaskolb/XcodeGen/blob/master/Docs/Usage.md#swift-package

You can do so with something like the following in your .gitignore:

MyProject.xcodeproj/**
!MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

yonaskolb avatar Jan 04 '20 10:01 yonaskolb

we somehow had to do a staircase of ignored and non ignored:

!/MyProject.xcodeproj/project.xcworkspace
 /MyProject.xcodeproj/project.xcworkspace/*
 !/MyProject.xcodeproj/project.xcworkspace/xcshareddata
 /MyProject.xcodeproj/project.xcworkspace/xcshareddata/*
 !/MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
 /MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/*
 !/MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

paulz avatar Aug 23 '22 17:08 paulz

If you ONLY wish to check in the Package.resolved, we did the same as @paulz with just the one additional line at the beginning:

MyProject.xcodeproj/**
!MyProject.xcodeproj/project.xcworkspace
MyProject.xcodeproj/project.xcworkspace/*
!MyProject.xcodeproj/project.xcworkspace/xcshareddata
MyProject.xcodeproj/project.xcworkspace/xcshareddata/*
!MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/*
!MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

dgilbert-foreflight avatar Sep 22 '22 18:09 dgilbert-foreflight