Skip to content

Add watchOS and tvOS targets - #159

Open
AJ Alt (ajalt) wants to merge 1 commit into
JetBrains:masterfrom
ajalt:watchos-targets
Open

AJ Alt (ajalt) wants to merge 1 commit into
JetBrains:masterfrom
ajalt:watchos-targets

Conversation

@ajalt

Copy link
Copy Markdown
Contributor

This library currently only publishes for the simulators for watchOS and tvOS. This PR adds the remaining targets for those platforms.

@goncalossilva

Copy link
Copy Markdown

Can we consider this? We're also stuck on this.

@donnerpeter

Copy link
Copy Markdown
Member

Why do you need these targets? Can it be enough to build the source code against them locally?

@jaimeazevedo

Copy link
Copy Markdown

Hey Peter, thanks for the quick reply 🙂

We're working on a Markdown foundation for our iOS and watchOS apps, and I think using this library in a shared KMP module would be the best option for us. The problem is that without the device targets (watchosArm64 / watchosDeviceArm64) we can't ship to a real Apple Watch, because the simulator ones only get us through development.

Building from source would work, but it means keeping a fork and publishing it ourselves, which I'd rather avoid. Right now this is what makes us choose between this library and writing our own native parser.

@donnerpeter

Copy link
Copy Markdown
Member

Here's an AI analysis. To be able to run CI, this should probably be rebased onto master. And please address the publication and CHANGELOG issues.


This PR shouldn't be merged as it stands. The target declarations are fine, but the new targets are missing from the publishing setup. A release from this branch would probably fail Maven Central validation, and that would block the whole release.

What the PR does

  • In build.gradle.kts, it replaces the deprecated ios() shortcut with explicit iosX64() and iosArm64() declarations.
  • It adds watchosArm32, watchosArm64, watchosDeviceArm64, watchosX64, tvosX64 and tvosArm64, and hooks them into nativeMain.
  • It adds macOS-arm64, iOS-sim-arm64, tvOS and watchOS test tasks to the macos-tests CI job.

Blocking issue

The new targets aren't added to publicationsToArtifacts (build.gradle.kts). Only names on that list go through registerPublicationFromKotlinPlugin (which attaches javadocJar and the POM details: license, developers, scm) and signPublicationsIfNecessary; see publication.kt. The Kotlin plugin will still create publications for the six new targets, such as markdown-watchosarm64. But they'll go into the artifacts bundle with no signature, no javadoc jar and a bare POM. Central Portal rejects a bundle like that, so publishMavenToCentralPortal would fail for the whole release, not just for these targets.

The fix is to add these six entries to the list:

"watchosArm32" to "markdown-watchosarm32",
"watchosArm64" to "markdown-watchosarm64",
"watchosDeviceArm64" to "markdown-watchosdevicearm64",
"watchosX64" to "markdown-watchosx64",
"tvosX64" to "markdown-tvosx64",
"tvosArm64" to "markdown-tvosarm64",

Ideally, build both target lists (declarations, nativeSourceSets) and the publication map from one shared list, so the three can't drift apart again. This bug happened exactly because they did.

Unverified CI risks

  • CI has never run on this PR (gh pr checks reports nothing), and it was opened in May 2024. It merges cleanly, but the workflow change was written against an old test.yml: the PR's context line still says "Bundle the build report", while master says "Upload the build report". It should be rebased and run green before merging.
  • The watchOS and tvOS simulator tests need the default simulator devices that Kotlin Gradle Plugin 2.0.0 expects to exist on the current macos-latest image. With newer Xcode versions, the default watch device is often missing and the test task fails. If that happens, set testRuns["test"].deviceId explicitly or leave those tests out.
  • watchosX64Test and tvosX64Test run x86_64 simulators under Rosetta on arm64 runners. This should work, since iosX64Test already does it, but it adds CI time.
  • I couldn't compile the new targets here, because this host is Linux and Apple targets need macOS. Of the new ones, watchosArm32 is the only 32-bit target in the build and watchosDeviceArm64 is Kotlin tier 3. Neither should matter for this pure-common code, but a macOS build should confirm it.

Fine as is

  • Dropping ios() only removes the empty iosMain intermediate source set; there's no src/iosMain. iosX64Main and iosArm64Main now depend on nativeMain directly, so consumers see no change.
  • The new Apple test tasks still only run commonTest, not fileBasedTest, the same as iosX64Test today. That's acceptable.

Nits

  • The trailing comma after "tvosSimulatorArm64", is the only one in that list.
  • There's no CHANGELOG entry for the new artifacts.

@ajalt

Copy link
Copy Markdown
Contributor Author

I pushed a new commit that addresses all the review comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants