Hey guys! I'm walking through the kmmbridge quicks...
# touchlab-tools
e
Hey guys! I'm walking through the kmmbridge quickstart and I've run into a snag with importing the SPM package into Xcode. It fails to download the archive. I'm seeing the releases in Github being built. I don't think I missed a step. Wondering if anyone else has run into this. Happy to share my repo!
I also tried the https://touchlab.github.io/KMMBridge/DEFAULT_GITHUB_FLOW steps on a barebones project, but had the same results 😢
k
Almost always the
~/.netrc
config
How is that being set? What are the permissions on the PAT used there?
Adding Github to Xcode packages isn’t enough, although I’d argue it should be 🙂 . You also need to add your GitHub access to
~/.netrc
Also need to make sure the machine like is:
Copy code
machine <http://maven.pkg.github.com|maven.pkg.github.com>
The earlier version of the artifact manager that used GitHub releases instead of GitHub packages has a different machine:
Copy code
machine <http://api.github.com|api.github.com>
e
Permissions are repo (all) and read:packages
~/.netrc
:
Copy code
machine <http://maven.pkg.github.com|maven.pkg.github.com>
  login ewilliamsfleetio
  password XXXXXXX
Curious, the file Xcode is trying to fetch is
<https://api.github.com/repos/ewilliamsfleetio/richtexteditor/releases/assets/82396203.zip>
k
Then I’m not sure. Outside of auth config I haven’t run into issues. I would check the build log in Xcode and maybe there’s more detail…
No, wait. That’s the release artifact manager, but the packages config. What’s your build gradle kmmbridge config look like?
<https://api.github.com>
is the key there. The Package file is maybe old, or (more likely) our docs aren’t all up to the latest (sorry)
e
No worries! This is already 100% easier than the last time I used KMM (about a year ago!)
Copy code
kmmbridge {
    githubReleaseArtifacts()
    githubReleaseVersions()
    addGithubPackagesRepository() <-- I added this (I think?)
    versionPrefix.set("0.1")
    spm()
}
k
Copy code
kmmbridge {
    mavenPublishArtifacts()
    githubReleaseVersions()
    versionPrefix.set("0.1")
    spm()
}
addGithubPackagesRepository()
e
🫠
k
mavenPublishArtifacts()
is the “new” thing, and the repo needs to go at the root. Also, I just noticed we didn’t add the following…
Copy code
plugins {
  kotlin("multiplatform")
   //etc
    id("co.touchlab.faktory.kmmbridge") version "0.3.1"
    `maven-publish`
}
Basically,
maven-publish
e
oops sorry I sent you the wrong one. This is what I currently have:
Copy code
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("co.touchlab.faktory.kmmbridge")
    `maven-publish`
}

kotlin {
    ios()
    // Note: iosSimulatorArm64 target requires that all dependencies have M1 support
    iosSimulatorArm64()

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(project(":breeds"))
                api(project(":analytics"))
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(libs.bundles.shared.commonTest)
            }
        }
        val iosMain by getting
        val iosTest by getting
        val iosSimulatorArm64Main by getting {
            dependsOn(iosMain)
        }
        val iosSimulatorArm64Test by getting {
            dependsOn(iosTest)
        }
    }

    cocoapods {
        summary = "KMMBridgeKickStart sample"
        homepage = "<https://www.touchlab.co>"
        ios.deploymentTarget = "13.5"
        extraSpecAttributes["libraries"] = "'c++', 'sqlite3'"

        framework {
            export(project(":analytics"))
            isStatic = true
        }
    }
}

addGithubPackagesRepository()

kmmbridge {
    mavenPublishArtifacts()
    githubReleaseVersions()
    spm()
//    cocoapods("git@github.com:touchlab/PodSpecs.git")
}
So I think that's what it should be (unmodified from template)
k
Ah! Well, that should work. Make sure you’re adding a version of the package rather than the main branch.
What does the Package.swift look like? You’ll need to look at the tagged/release version in Github.
e
This for versioning?
k
Hmm. In Github, go to releases, find “0.1.2”, and look at files at that commit version. If you’re using our actions workflow, the commit doesn’t exist in a branch (we delete it), but the commit is still in the repo.
Get that Package.swift
e
Package.swift (in github source)
Copy code
// swift-tools-version:5.3
import PackageDescription

let remoteKotlinUrl = "<https://maven.pkg.github.com/touchlab/KMMBridgeKickStart/co/touchlab/kmmbridgekickstart/allshared-kmmbridge/0.13.0/allshared-kmmbridge-0.13.0.zip>"
let remoteKotlinChecksum = "fe57822fa8ae5806e791558b1a632c3cd3af6f185d8e866ff4e132f40f68a6d4"
let packageName = "allshared"

let package = Package(
    name: packageName,
    platforms: [
        .iOS(.v13)
    ],
    products: [
        .library(
            name: packageName,
            targets: [packageName]
        ),
    ],
    targets: [
        .binaryTarget(
            name: packageName,
            url: remoteKotlinUrl,
            checksum: remoteKotlinChecksum
        )
        ,
    ]
)
Do you want Package.swift from the release zip?
k
“allshared-kmmbridge-0.13.0.zip”. That’s old. Try rerunning the build.
e
So that Package.swift is in the root of my repo? Should I remove that. I thought maybe that should be auto-generated and included in the release ZIP?
maybe that's the issue?
k
Xcode uses Github to organize SPM, so it looks for Package.swfit in the code. The binary is just “somewhere else”, and the Pacakge.swift is not in that zip.
So, anyway, if you look at the the Package.swift file, in the commit for the version 0.1.2, that should tell you where Xcode is trying to go to get the binary. The root Package.swift in the main branch doesn’t matter, but I think if it’s not there Xcode gets upset.
e
I think I may have broke something trying to fix it. I'm going back to the template and trying again on a new repo 🤞
k
Let me know how that goes. There’s a lot of little pieces here, and we’ll need to improve the docs and/or error messages when things fail.
e
And to be clear, I can skip the cocoapod steps if I'm not planning on using that right?
k
Yes, for sure
Cocoapods setup is super painful
e
Yup
I gathered that lol
k
Anyway, if you don’t get this working, and you don’t have strict NDA rules, I can do a screen share a bit later.
e
Great thanks!
k
Thanks for the feedback and navigating our docs 🙂
e
Here's the repo I generated for reference. Letting the build run now: https://github.com/ewilliamsfleetio/kmmbridgekickstart-fleetio
k
Oh, yeah, if it’s visible that’ll be much easier to debug
e
Yeah!
Not like there's anything in it other than your code hahaha
k
Of course, public repos don’t need the
~/.netrc
config, but one thing at a time
e
right right the first try was private
k
Not like there’s anything in it other than your code hahaha
Yes, much easier to debug. I’ve been staring at this for weeks
e
Well I guess starting from scratch is the way to fix things sometimes!
I'll try making it private again later. That was your first guess so maybe something is not quite right on my dev box.
@kpgalligan I was able to get a "real" KMM library published with the KMMBridge and will be demoing this to our dev team today. iOS folks are particularly excited by the easy of just dropping in an SPM package if they aren't going to be actually working on the library 🎉
k
Nice! Let me know how it goes
e
Wanted to followup that we just shipped our first release with KMM libraries this week!
k
Nice!
k
Very glad I found this post. I was stuck on the package not resolving until I realized I was using the version of the
~/.netrc
here: https://touchlab.github.io/KMMBridge/artifacts/GITHUB_RELEASE_ARTIFACTS When I switched to
machine <http://maven.pkg.github.com|maven.pkg.github.com>
it worked like a charm. Thank you for this tool. Its very slick!
174 Views