Yokan / rebuild
Course 1 8624561

getting-started.html

docs/getting-started.html

documentation / design asset173 lines
1<!doctype html>2<html lang="en">3<head>4  <meta charset="utf-8">5  <meta name="viewport" content="width=device-width, initial-scale=1">6  <meta name="description" content="Set up Yokan and learn how its Kotlin Multiplatform build and source sets fit together.">7  <meta name="theme-color" content="#172033">8  <title>Get started · Yokan KMP Field Guide</title>9  <link rel="icon" href="./assets/mark.svg" type="image/svg+xml">10  <link rel="stylesheet" href="./assets/styles.css">11  <script>try{const t=localStorage.getItem('yokan-docs-theme');document.documentElement.dataset.theme=t||(matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light')}catch{}</script>12  <script defer src="./assets/app.js"></script>13</head>14<body data-page="start">15  <a class="skip-link" href="#main-content">Skip to content</a>16  <header data-site-header></header>1718  <div class="page-shell">19    <aside class="side-nav" aria-label="Guide chapters">20      <span class="nav-label">Field guide</span>21      <ul>22        <li><a href="./getting-started.html" aria-current="page">01 · Get started</a></li>23        <li><a href="./architecture.html">02 · Architecture</a></li>24        <li><a href="./patterns.html">03 · Patterns</a></li>25      </ul>26    </aside>2728    <main id="main-content" class="page-main">29      <header class="chapter-header">30        <nav class="breadcrumbs" aria-label="Breadcrumb"><a href="./index.html">Field guide</a><span>/</span><span>Get started</span></nav>31        <h1>Build a target. Map the project.</h1>32        <p>Start with the desktop app for the shortest feedback loop, then connect the Gradle model to the folders you will read throughout this guide.</p>33        <div class="chapter-meta"><span class="pill">15–25 minutes</span><span class="pill">JDK 21</span><span class="pill">No KMP experience required</span></div>34      </header>3536      <section class="doc-section" aria-labelledby="before-you-start">37        <h2 id="before-you-start">Before you start</h2>38        <p>Yokan is a Compose Multiplatform application targeting Android, desktop JVM, and iOS. You only need one runnable target to follow the guide.</p>39        <table class="comparison">40          <thead><tr><th>Tool</th><th>Required for</th><th>Why</th></tr></thead>41          <tbody>42            <tr><td>JDK 21</td><td>All Gradle work</td><td>Runs Gradle and the desktop target. Android bytecode is configured for JVM 17 separately.</td></tr>43            <tr><td>Android SDK</td><td>Android</td><td>Build tools, platform APIs, emulator, and APK packaging.</td></tr>44            <tr><td>Xcode</td><td>iOS on macOS</td><td>Compiles the SwiftUI host and links the Kotlin/Native framework.</td></tr>45          </tbody>46        </table>47        <div class="callout warning">48          <strong>Composite build prerequisite</strong>49          <p><code>settings.gradle.kts</code> includes <code>../yokan-ext</code>. Keep the extension project beside this checkout, or replace that composite-build substitution with a resolvable published dependency before syncing Gradle.</p>50        </div>51      </section>5253      <section class="doc-section" aria-labelledby="run-first-target">54        <h2 id="run-first-target">Run your first target</h2>55        <p>Desktop has no emulator or Xcode handoff, so it is the best first proof that your JDK, Gradle, source sets, generated resources, and shared UI are wired correctly.</p>56        <div class="code-block">57          <div class="code-label"><span>terminal · project root</span></div>58          <pre><code>export JAVA_HOME=$(/usr/libexec/java_home -v 21)   # macOS59./gradlew :composeApp:run</code></pre>60        </div>61        <p>Once the desktop window opens, the same shared <code>YokanApp()</code> composition can be built for the other targets:</p>62        <div class="code-block">63          <div class="code-label"><span>terminal · target checks</span></div>64          <pre><code># Android debug APK65./gradlew :androidApp:assembleDebug6667# Shared tests on the desktop JVM68./gradlew :composeApp:desktopTest6970# iOS simulator framework71./gradlew :composeApp:linkDebugFrameworkIosSimulatorArm647273# Then run the native iOS host74open iosApp/iosApp.xcodeproj</code></pre>75        </div>76        <div class="callout">77          <strong>Why desktop tests?</strong>78          <p><code>commonTest</code> is compiled into platform test executables. The desktop JVM target is fast and can execute most shared domain, service, and state tests without a simulator.</p>79        </div>80      </section>8182      <section class="doc-section" aria-labelledby="read-gradle-model">83        <h2 id="read-gradle-model">Read the Gradle model</h2>84        <p>Open <a href="https://codeberg.org/FriedCutlet/yokan/src/branch/main/composeApp/build.gradle.kts"><code>composeApp/build.gradle.kts</code></a> and find <code>kotlin { sourceSets { ... } }</code>. The block defines a dependency graph, not independent folders.</p>85        <div class="file-tree" role="img" aria-label="Source set dependency tree"><b>commonMain</b>  ← portable product code86├── <em>platformWebViewMain</em>  ← shared WebView capability87│   ├── androidMain88│   └── iosMain89├── <em>jvmCommonMain</em>       ← Rhino + LuaJ shared by JVM targets90│   ├── androidMain91│   └── desktopMain92├── androidMain93├── desktopMain94└── iosMain95    ├── iosArm64Main96    └── iosSimulatorArm64Main</div>97        <h3 id="source-set-rules">Three source-set rules</h3>98        <ol>99          <li>A child source set can use declarations and dependencies from every source set it <code>dependsOn</code>.</li>100          <li><code>commonMain</code> cannot import Android, JVM, or Apple APIs. Its declarations must compile for every target.</li>101          <li>Intermediate source sets share capability between a subset of targets. Yokan uses this to avoid duplicating JVM engines and Android/iOS WebView code.</li>102        </ol>103      </section>104105      <section class="doc-section" aria-labelledby="tour-folders">106        <h2 id="tour-folders">Tour the folders</h2>107        <p>Do not begin by reading every screen. First learn which layer owns each kind of decision.</p>108        <div class="file-tree"><b>composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan</b>109├── <em>domain/</em>       portable product models and recognition rules110├── <em>database/</em>     database contracts, entities, Room declarations111├── <em>data/</em>         repository boundary and domain/database mapping112├── <em>services/</em>     HTTP, extensions, sync, playback, platform contracts113└── <em>ui/</em>           shared Compose app, state, screens, MVI, theme114115<b>composeApp/src/{androidMain,desktopMain,iosMain}</b>116├── database/     target-specific Room builders117├── services/     actual implementations and OS integrations118└── ui/           small target rendering helpers119120<b>iosApp/</b>              native SwiftUI host for YokanShared.framework</div>121        <p>The iOS host is intentionally small. Android and desktop also have thin entry points; the product is assembled in shared Kotlin.</p>122      </section>123124      <section class="doc-section" aria-labelledby="first-inspection">125        <h2 id="first-inspection">Your first inspection</h2>126        <p>Trace the HTTP client factory. The shared service contract declares one capability; each target selects an engine:</p>127        <div class="code-block">128          <div class="code-label"><span>commonMain/services/PlatformServices.kt</span></div>129          <pre><code>expect fun createPlatformHttpService(): HttpService</code></pre>130        </div>131        <div class="code-block">132          <div class="code-label"><span>platform actuals</span></div>133          <pre><code>// androidMain + desktopMain134actual fun createPlatformHttpService(): HttpService =135    KtorHttpService(OkHttp.create())136137// iosMain138actual fun createPlatformHttpService(): HttpService =139    KtorHttpService(Darwin.create())</code></pre>140        </div>141        <ul class="checklist">142          <li>Find the common <code>expect</code> declaration.</li>143          <li>Open the Android, desktop, and iOS <code>actual</code> files.</li>144          <li>Find the engine dependencies in their corresponding source sets.</li>145          <li>Notice that callers depend on <code>HttpService</code>, not on OkHttp or Darwin.</li>146        </ul>147      </section>148149      <section class="doc-section" aria-labelledby="common-setup-problems">150        <h2 id="common-setup-problems">Common setup problems</h2>151        <table class="comparison">152          <thead><tr><th>Symptom</th><th>Check</th></tr></thead>153          <tbody>154            <tr><td>Unsupported Java version</td><td>Confirm <code>java -version</code> and <code>JAVA_HOME</code> both point to JDK 21.</td></tr>155            <tr><td>Included build missing</td><td>Place <code>yokan-ext</code> beside this repository so <code>../yokan-ext</code> resolves.</td></tr>156            <tr><td>iOS framework not found</td><td>Build the simulator framework, then let Xcode run <code>BuildSharedFramework.sh</code> from the host project.</td></tr>157            <tr><td>Room generated code missing</td><td>Use the Gradle tasks rather than compiling files directly; KSP runs once per configured target.</td></tr>158          </tbody>159        </table>160      </section>161162      <nav class="next-page" aria-label="Chapter navigation">163        <a href="./index.html"><small>Previous</small><strong>Field guide overview</strong></a>164        <a href="./architecture.html"><small>Next</small><strong>Trace the architecture</strong></a>165      </nav>166    </main>167168    <aside class="on-this-page" data-toc aria-label="On this page"></aside>169  </div>170171  <footer data-site-footer></footer>172</body>173</html>174

Search chapters, reference and source filenames.