KMMBridgeiOS Dev Setup

iOS Dev Setup

To consume a published Kotlin XCFramework build, Xcode needs some configuration. This part is often confusing, particularly for SPM, because Xcode uses separate authentication methods to access git repos and binary downloads. Further, as most examples are using GitHub, there is the added complication that GitHub requires user authentication for binary downloads, even in public repos.

The binary download authentication issue is such a common source of confusion that we mention it in multiple places throughout the KMMBridge docs. If you authenticate to GitHub through Xcode, you still need to configure ~/.netrc and supply your authentication info there as well in order to actually download the binary files. Even if you’re using a public GitHub repo and hosting your binaries in either GitHub Packages or GitHub Releases, you still need to provide the ~/.netrc auth to actually access those files. It’s a GitHub thing. You need to authenticate to download binaries.

Using SPM

SPM config is found in the Package.swift file. This file must be in the root of a git repo, and Xcode must be able to access that repo. Also, again, the authentication for your git repo and the authentication for downloading binary files is different.

We have an updated GitHub Actions workflow and quick-start project, specifically designed for SPM publishing. This is the best place to look to see how everything works together.

Using CocoaPods

CocoaPods also relies on git repos for config, but CocoaPods requires a separate repo solely to index it’s dependencies. You can have multiple CocoaPods projects publishing their config to one repo. Indeed, the main CocoaPods spec index is one big GitHub repo with over 800k commits.

In theory it might be possible to use your code repo to host your CocoaPods config. However, after some attempts at making this work, we would highly suggest not attempting it.

To see examples of SPM and CoccoPods config, please see KMMBridge Quick Start Updates. It will walk through configuring publication and Xcode access for the sample project. Note these examples focus on the 0.5.x versions of KMMBridge, but should still be relevant for our latest versions.

Private Artifacts

If you are hosting artifacts somewhere that requires authentication, you’ll need to add auth info for that to work. See Xcode and Binary File Authentication for more info.

You must do this before attempting to integrate dependency managers!!!

You can publish artifacts from public repos to GitHub Packages, but GitHub still requires a valid GitHub user to access those artifacts. If you are intending to publish a public library and do not want to force your users to configure GitHub auth, you’ll need to host your library’s binaries somewhere else.

Local Kotlin Editing

For developers editing Kotlin, you will want to test locally-built Kotlin code directly in your Xcode project from time to time. How that works differs depending on which dependency manager you use. For CocoaPods see IOS_LOCAL_DEV_COCOAPODS. For SPM see IOS_LOCAL_DEV_SPM.