XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Xcode removing Package.resolved

Open AhmedMohamedAllam opened this issue 11 months ago • 8 comments

Environment

  • xcodegen version: 2.39.1
  • Xcode version: 15.3

Description

I've encountered an issue where xcodegen fails to retain the CleverTapGeofence Swift Package Manager (SPM) dependency in the Package.resolved file of the generated Xcode project. The dependency is correctly specified in the .yml configuration file, and when dependencies are resolved directly through Xcode, the CleverTapGeofence package is successfully added. However, upon generating the project with xcodegen, this particular package is missing from Package.resolved.

Steps to Reproduce

  1. Specify CleverTapGeofence package in the .yml configuration file for xcodegen.
  2. Generate the Xcode project using xcodegen.
  3. Observe that the CleverTapGeofence package is missing from Package.resolved in the generated project.

Expected Behavior

The CleverTapGeofence package, as specified in the .yml file, should be retained in the Package.resolved file of the generated project, similar to how it is retained when adding the package directly through Xcode's SPM integration.

Actual Behavior

The CleverTapGeofence package is missing from the Package.resolved file in the generated Xcode project, despite being specified in the .yml configuration file for xcodegen.

Additional Information

  • .yml Configuration Snippet for CleverTapGeofence:
    packages:
       CleverTapGeofence:
          url: https://github.com/CleverTap/clevertap-geofence-ios.git
          from: 1.0.4
    

AhmedMohamedAllam avatar Mar 14 '24 13:03 AhmedMohamedAllam

This issue only happens with Xcode 15.3, after revert back to 15.2 it works as expected.

AhmedMohamedAllam avatar Mar 14 '24 22:03 AhmedMohamedAllam

I have the same issue :) always have to resolve packages manually with 15.3

dungi avatar Mar 20 '24 09:03 dungi

Also have this issue on xcode 15.3 (thx aapl)

As temporary solution you can add next lines to top of project.yml

options:
  postGenCommand: xcodebuild -resolvePackageDependencies -project MyApp.xcodeproj -scheme MyApp

and replace "MyApp" to yours project name

(@wojciech-kulik FYI)

Woit avatar Mar 24 '24 14:03 Woit

@Woit thanks for the workaround!

I've already reported this issue to Apple: FB13684602

It happens even if you just reset xcodeproj in your external git client :). So it's not connected with XcodeGen. In general, any modification of the project outside of Xcode will cause that.

wojciech-kulik avatar Mar 24 '24 19:03 wojciech-kulik

Is the issue still present in Xcode 15.4?

Mathbl avatar May 14 '24 14:05 Mathbl

Sadly this still seems to be present in Xcode 15.4 😞 How this issue still hasn't been fixed baffles me

yonaskolb avatar May 15 '24 06:05 yonaskolb

Is the issue still present in Xcode 15.4?

Unfortunately Apple not fix this bug yet.

mobile-sergey avatar May 24 '24 13:05 mobile-sergey

Unfortunately triggering resolve packages in a postgen command didn't fix the issue for me.

What helps a bit is setting defaults write com.apple.dt.Xcode IDEPackageOnlyUseVersionsFromResolvedFile 1. It will prevent Xcode from deleting the Packages.resolved file. Even though the project still won't build until packages are resolved, at least there's no longer a need to restore the package lock.

achernenko-schibsted avatar Jul 10 '24 13:07 achernenko-schibsted