xcodebuildswift-package-manager

Prevent `xcodebuild clean` from updating SPM dependencies


I am using Fastlane to build an iOS application that uses Swift Package Manager integrated into Xcode. Some of my dependencies are in private Git repositories that require authentication.

I have a simple lane for cleaning all build artifacts like this:

desc "Clean"
lane :clean do
  clean_build_artifacts
  clear_derived_data
  xcclean
end

The problem I have is that I want to be able to run this lane without being prompted for Git credentials. The xcclean action calls the xcodebuild clean command which tries to resolve all packages (and therefore prompts for credentials).

The xcodebuild command for actually doing a build doesn't resolve packages (you need to call xcodebuild -resolvePackageDependencies for that) but the clean command doesn't seem to have any argument that can be used to turn off automatic dependency resolution.

Is there a way to stop xcodebuild clean from trying to resolve dependencies? Alternatively, is there some other equivalent command I can use instead of xcclean?


Solution

  • I still have not found any way to do this with Apple's tools.

    However, I have switched all of my iOS projects to use Tuist. Tuist performs dependency resolution as a separate step, so Xcode itself sees only the pre-resolved dependencies and does not try to connect to the server.