Reputation: 61
I have a SwiftPM issue which is driving me nuts.
Let’s say I have swift package project (no Xcode project involved). And let’s call it SDK from here. The SDK is laying in its own git repository.
So I want to build a Showcase App for that SDK by adding the SDK as a dependency, managing swift packages via Xcode not via a Package.swift
file. The showcase is deployed to our QA team and they should be able to always test the latest development version of the SDK with that showcase.
So naturally I would configure the package dependency in Xcode by defining the branch develop.
So now, when I change something inside the SDK, push it onto the develop
branch, and want to have that change available inside the showcase, I simply need to right click on the package inside the showcase and click Update Package
and this works great.
Here comes the catch: This approach does not work on our Jenkins CI. I don’t know what I’m doing wrong here, but the xcodebuild
command line tool won’t notice something changed on the develop
branch of the SDK and would checkout the older revision.
What I tried so far:
Package.resolved
from git index and added it to .gitignore
so after the git clone/checkout there should be no Package.resolved
file~/Library/Cache/org.swift.swiftpm
and ~/Library/org.swift.swiftpm
prior to the buildFastlane
and so I am also explicitly setting the cloned source packages path to something inside my workspace to make sure the cloned sources are deleted on workspace clean-up via cloned_source_packages_path: "SourcePackages"
The generated xcodebuild
command by Fastlane looks like this: $ xcodebuild -resolvePackageDependencies -scheme ScannerShowcase -project ScannerShowcase.xcodeproj -configuration Release -clonedSourcePackagesDirPath SourcePackage
The Fastlane gym summary looks like this:
I'd expect that if I delete all that cached packages and not having any Package.resolved
file present xcodebuild
would resolve the swift package to the latest revision available. Instead it seems there still is something cached somewhere and xcodebuild
is using that cache.
Nothing worked so far. Does anybody have experienced this same issue and is able to provide any suggestions and/or help?
Upvotes: 0
Views: 1002
Reputation: 61
As it turns out there seems to be now way to achieve the same results with xcodebuild
command line tool as with Xcode's Update Package
or Update to Latest Versions
.
The command line tools rely on data stored inside derived data while updating packages. Thanks to Gregory Higley's answer here I was able to solve the issue by deleting the derived data for that specific build job by
Showcase.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
out of git index,Package.resolved
to .gitignore
to keep it that way,Jenkins
file:stage('Clean up') {
steps {
script { env.DERIVED_DATA_PATH=sh(returnStdout: true, script: "xcodebuild -showBuildSettings | grep -m 1 BUILD_DIR | grep -oE \"/.*\" | sed 's|/Build/Products||'") }
echo "Derived data path is: ${env.DERIVED_DATA_PATH}"
// The above will return a folder with a name like /Users/you/Library/Developer/Xcode/DerivedData/MyProject-ehdkocavaenextdcrsaszjdmyssx
sh script: "rm -rf ${env.DERIVED_DATA_PATH}", label: "Removing derived project data ..."
}
}
Any other step I mentioned when asking the question wasn't necessary to achieve my goal:
~/Library/Cache/org.swift.swiftpm
nor ~/Library/org.swift.swiftpm
cloned_source_packages_path: "SourcePackages"
Again big shout out to Gregory Higley for their approach.
Upvotes: 0