Hey Thomas. Sorry for late reply, but I was OOO for a while. I have good news. I made it work and I am very satisfied with the result. I will make a blog post with all the details, but in short:
1. Since SPM are preconfigured and outside of project configuration, we need to build the framework locally. I am using specific gradle task with specific platform, so it do not generate all the targets, but just emulator. For example:
./gradlew spmDevBuild -PspmBuildTargets=ios_simulator_arm64
2. I have both shared and iOS projects in the same root:
- MyProjects
-- iosProject
--- Packages/Core
-- shared-kmp
3. In the
Package.swift
you have the dependencies array, something like:
var coreDependencies: [Package.Dependency] = [
.package(url: "<https://github.com/Alamofire/Alamofire>", exact: "5.8.1"),
.package(url: "<https://github.com/kasketis/netfox>", exact: "1.21.0"),
.package(url: "<https://github.com/evgenyneu/keychain-swift>", exact: "20.0.0"),
.package(url: "<https://github.com/marmelroy/PhoneNumberKit>", exact: "3.7.6")
]
and you can add new item to that array using append:
if remoteBuild {
coreDependencies.append(.package(url: "<https://github.com/myapp/shared-kmp>", exact: "0.1.4"))
} else {
// put shared-kmp repo in the same root as your iOS project
coreDependencies.append(.package(name: "MyShared", path: "../../../shared-kmp"))
}
4. so, at the end I am changing just one boolean
remoteBuild
to work with remote build or local. The variable is default to TRUE, so I have no issues when running CI machine.
Hope it makes sense 🙂