Kotlin Multiplatform, from the compiler up · check

Know The build already?

One question for each of the 4 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 16: The kotlin { } block

You declare only iosArm64() for iOS, then try to run the shared tests in the simulator on your Mac. What happens?

Not quite. A target is one exact kind of binary; the simulator needs its own, iosSimulatorArm64. Learn it in puzzle 16 →

Right. Device and simulator are two different targets.

Not quite. commonTest is compiled per declared target; with no simulator target there's no binary for the simulator at all. Learn it in puzzle 16 →

Puzzle 17: Source sets in between

Your project declares the android, iosArm64 and iosSimulatorArm64 targets. You put a function in appleMain. Which builds compile it?

Right. Code reaches the targets below its source set.

Not quite. Code reaches only the targets below it; Android isn't under appleMain. Learn it in puzzle 17 →

Not quite. appleMain is for every Apple target in the project; here those are the two iOS targets. Learn it in puzzle 17 →

Puzzle 18: Who can see what

Your project has the android, iosArm64 and iosSimulatorArm64 targets. A function in commonMain calls a function you wrote in iosMain. What happens?

Not quite. commonMain is checked against all its targets; it can't compile a call to code Android doesn't have. Learn it in puzzle 18 →

Right. Up, never down.

Not quite. The link goes one way: iosMain sees commonMain, not the reverse. Learn it in puzzle 18 →

Puzzle 19: Dependencies per source set

You add OkHttp, a library built only for the JVM and Android, to commonMain.dependencies. What happens when you build for iOS?

Not quite. A library arrives already built for its platforms; Kotlin/Native can't make an iOS one from it. Learn it in puzzle 19 →

Right. commonMain takes only libraries built for all its targets.

Not quite. commonMain is compiled for every target; nothing is skipped on iOS, it just doesn't compile. Learn it in puzzle 19 →

Back to the overview →