### Start Zipline Development Server Source: https://github.com/cashapp/zipline/blob/trunk/README.md Use Gradle to start a development server that serves the JavaScript code. The --continuous flag ensures the server stays running and recompiles on code changes. ```bash $ ./gradlew -p samples trivia:trivia-js:serveDevelopmentZipline --info --continuous ``` -------------------------------- ### Setup iOS App Dependencies Source: https://github.com/cashapp/zipline/blob/trunk/samples/world-clock/README.md Navigates to the iOS app directory, installs CocoaPods dependencies, and opens the Xcode workspace. The shared Kotlin code is built automatically. ```bash cd samples/world-clock/ios/app pod install open WorldClock.xcworkspace ``` -------------------------------- ### Start CPU Sampling in Kotlin/JS Source: https://github.com/cashapp/zipline/blob/trunk/zipline-profiler/README.md Use this snippet to start CPU sampling for Zipline programs. Ensure the 'fileSystem' object is available and specify the output file name. The profiler is automatically closed when the 'use' block exits. ```kotlin zipline.quickJs.startCpuSampling(fileSystem, "zipline.hprof".toPath()).use { // ...use Zipline... } ``` -------------------------------- ### Install Android Debug App Source: https://github.com/cashapp/zipline/blob/trunk/samples/world-clock/README.md Installs the Android application in debug mode. Assumes an emulator is running and fetches code from the devserver on the host machine. ```bash ./gradlew -p samples world-clock:android:installDebug ``` -------------------------------- ### Build JNI Libraries Locally with Zig Source: https://github.com/cashapp/zipline/blob/trunk/TROUBLESHOOTING.md Cross-compile Zipline's JVM native libraries using Zig. This process is tested on macOS and may work on Linux. Ensure Zig 0.14.0 is installed. ```bash $ cd zipline $ zig build -p src/jvmMain/resources/jni/ ``` -------------------------------- ### Run Gradle Tasks in Sample Project Source: https://github.com/cashapp/zipline/blob/trunk/zipline-gradle-plugin/README.md Navigate to a sample project directory and run Gradle tasks. This is typically done after configuring the Zipline version. ```bash $ cd zipline-gradle-plugin/src/test/projects/basic $ ../../../../../gradlew tasks ``` -------------------------------- ### Build and Run JVM Host Application Source: https://github.com/cashapp/zipline/blob/trunk/README.md Build the fat JAR for the JVM host application and run it to connect to the Zipline service. This should be done in a separate terminal from the development server. ```bash $ ./gradlew -p samples trivia:trivia-host:shadowJar java -jar samples/trivia/trivia-host/build/libs/trivia-host-all.jar ``` -------------------------------- ### Serve Development Zipline Presenters Source: https://github.com/cashapp/zipline/blob/trunk/samples/world-clock/README.md Compiles Kotlin/JS presenters and serves them for development. The server runs until interrupted. ```bash ./gradlew -p samples world-clock:presenters:serveDevelopmentZipline --info --continuous ``` -------------------------------- ### Zipline Native Library Build Configuration Source: https://github.com/cashapp/zipline/blob/trunk/zipline/src/androidMain/CMakeLists.txt Configures the minimum CMake version, C and C++ standards, finds all C/C++ source files, defines a shared library named 'quickjs', and sets linker options for page size. ```cmake cmake_minimum_required(VERSION 3.4.1) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 11) file(GLOB_RECURSE sources "../../native/*.c" "../../native/*.cpp") add_library(quickjs SHARED ${sources}) target_link_libraries(quickjs) target_link_options(quickjs PRIVATE "-Wl,-z,max-page-size=16384") ``` -------------------------------- ### Zipline CLI Help (Local Development) Source: https://github.com/cashapp/zipline/blob/trunk/zipline-cli/README.md Displays the help message for the zipline-cli tool after building it locally using Gradle. This version includes additional commands like 'generate-key-pair'. ```bash $ ./gradlew :zipline-cli:installDist $ zipline-cli/build/install/zipline-cli/bin/zipline-cli -h Usage: zipline-cli [-hV] COMMAND Use Zipline without Gradle. -h, --help Show this help message and exit. -V, --version Print version information and exit. Commands: download Recursively download Zipline code to a directory from a URL generate-key-pair Generate an Ed25519 key pair for ManifestSigner and ManifestVerifier help Displays help information about the specified command ``` -------------------------------- ### Zipline CLI Help (Downloaded) Source: https://github.com/cashapp/zipline/blob/trunk/zipline-cli/README.md Displays the help message for the zipline-cli tool when downloaded from a release. Use this to understand available commands and options. ```bash $ bin/zipline-cli -h Usage: zipline-cli [-hV] COMMAND Use Zipline without Gradle. -h, --help Show this help message and exit. -V, --version Print version information and exit. Commands: download Recursively download Zipline code to a directory from a URL. help Displays help information about the specified command ``` -------------------------------- ### Troubleshoot Missing JNI Libraries Source: https://github.com/cashapp/zipline/blob/trunk/TROUBLESHOOTING.md A stack trace indicating `Unable to read /jni/aarch64/libquickjs.dylib from JAR` suggests missing prebuilt C libraries. Download the `jni-binaries` artifact and extract it to the `zipline/src/jvmMain/resources/jni/` directory. ```java java.lang.ExceptionInInitializerError at app.cash.zipline.Zipline$Companion.create(Zipline.kt:175) at app.cash.zipline.Zipline$Companion.create$default(Zipline.kt:170) at app.cash.zipline.ConsoleTest.(ConsoleTest.kt:36) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ... Caused by: java.lang.IllegalStateException: Unable to read /jni/aarch64/libquickjs.dylib from JAR at app.cash.zipline.QuickJsNativeLoaderKt.loadNativeLibrary(QuickJsNativeLoader.kt:36) at app.cash.zipline.QuickJs.(QuickJs.kt:35) ... 46 more ``` -------------------------------- ### Set Release and Next Versions Source: https://github.com/cashapp/zipline/blob/trunk/RELEASING.md Export environment variables for the release version and the next development version. ```bash export RELEASE_VERSION=X.Y.Z export NEXT_VERSION=X.Y.Z-SNAPSHOT ``` -------------------------------- ### Run Zipline Gradle Plugin Tests Source: https://github.com/cashapp/zipline/blob/trunk/zipline-gradle-plugin/README.md Execute the Zipline Gradle plugin tests using the Gradle wrapper. This command builds the plugin and libraries required for testing. ```bash ./gradlew zipline-gradle-plugin:test ``` -------------------------------- ### Configure Zipline Compilation Settings Source: https://github.com/cashapp/zipline/blob/trunk/zipline-gradle-plugin/README.md Set the main entry point for your Zipline application. This is the JS module containing your application's entrypoint function. ```kotlin zipline { mainFunction.set("my.application.package.path.prepareFunction") } ``` -------------------------------- ### Configure Zipline Signing Keys in Gradle Source: https://github.com/cashapp/zipline/blob/trunk/README.md Configure the Zipline Gradle plugin to use a private key for signing builds. This is done in the `zipline` block of your `build.gradle.kts` file. ```kotlin zipline { signingKeys { create("key1") { privateKeyHex.set(...) algorithmId.set(app.cash.zipline.loader.SignatureAlgorithmId.Ed25519) } } } ``` -------------------------------- ### Configure Zipline Manifest Verifier in Host Application Source: https://github.com/cashapp/zipline/blob/trunk/README.md Configure the Zipline manifest verifier in the host application to verify signatures of downloaded libraries. This involves adding public keys and building a `ManifestVerifier` instance. ```kotlin val manifestVerifier = ManifestVerifier.Builder() .addEd25519("key1", ...) .build() val loader = ZiplineLoader( manifestVerifier = manifestVerifier, ... ) ``` -------------------------------- ### Configure Android SDK Location for Gradle/IntelliJ Source: https://github.com/cashapp/zipline/blob/trunk/TROUBLESHOOTING.md Add this to a `local.properties` file at the root of the Zipline repo to resolve Android SDK files. Adjust the path for your operating system. ```properties sdk.dir=/Users/{your username}/Library/Android/sdk ``` -------------------------------- ### Update Versions, Tag, and Commit Source: https://github.com/cashapp/zipline/blob/trunk/RELEASING.md Update gradle.properties with the release version, commit, tag the release, and then update for the next development version. ```bash sed -i "" "s/VERSION_NAME=.*/VERSION_NAME=$RELEASE_VERSION/g" \ gradle.properties git commit -am "Prepare version $RELEASE_VERSION" git tag -am "Version $RELEASE_VERSION" $RELEASE_VERSION sed -i "" "s/VERSION_NAME=.*/VERSION_NAME=$NEXT_VERSION/g" \ gradle.properties git commit -am "Prepare next development version" git push && git push --tags ``` -------------------------------- ### Launch Zipline and Bind Service in Kotlin/JS Source: https://github.com/cashapp/zipline/blob/trunk/README.md Export a function to launch Zipline and bind the implemented TriviaService. This function is called from the host application to make the service available. ```kotlin @JsExport fun launchZipline() { val zipline = Zipline.get() zipline.bind("triviaService", RealTriviaService()) } ``` -------------------------------- ### Configure Zipline Version in Gradle Properties Source: https://github.com/cashapp/zipline/blob/trunk/zipline-gradle-plugin/README.md Set the Zipline plugin version in the `gradle.properties` file for sample projects. Substitute the actual version from your `build.gradle.kts`. ```properties ziplineVersion=1.0.0-SNAPSHOT ``` -------------------------------- ### Load Zipline Service in Kotlin/JVM Source: https://github.com/cashapp/zipline/blob/trunk/README.md Load the Kotlin/JS code and service from a manifest URL using ZiplineLoader. A single-threaded dispatcher is required for Zipline instances. ```kotlin suspend fun launchZipline(dispatcher: CoroutineDispatcher): Zipline { val manifestUrl = "http://localhost:8080/manifest.zipline.json" val loader = ZiplineLoader( dispatcher, ManifestVerifier.NO_SIGNATURE_CHECKS, OkHttpClient(), ) return loader.loadOnce("trivia", manifestUrl) } ``` -------------------------------- ### Configure Zipline Download Task Source: https://github.com/cashapp/zipline/blob/trunk/zipline-gradle-plugin/README.md Set up a Gradle task to download the latest Zipline compiled code from a network URL. This task is useful for packaging Zipline code into your application. ```kotlin plugins { id("app.cash.zipline") } kotlin { js { browser() binaries.library() } } val downloadZipline by tasks.creating(ZiplineDownloadTask::class) { applicationName = "my-application" manifestUrl = "https://your-cdn.com/zipline/alpha-app/latest/manifest.zipline.json" downloadDir = file("$buildDir/resources/zipline/alpha-app/latest") } ``` -------------------------------- ### Generate Zipline Manifest Key Pair (Ed25519) Source: https://github.com/cashapp/zipline/blob/trunk/README.md This command generates an EdDSA key pair for signing Zipline manifests. The private key should be kept secure on the build server. ```bash $ ./gradlew :generateZiplineManifestKeyPairEd25519 ... ---------------- ---------------------------------------------------------------- ALGORITHM: Ed25519 PUBLIC KEY: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX PRIVATE KEY: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ---------------- ---------------------------------------------------------------- ... ``` -------------------------------- ### Embedded Module Structure Source: https://github.com/cashapp/zipline/blob/trunk/zipline-loader/README.md Illustrates the expected directory structure for embedded Zipline modules, including manifest files and pre-compiled JavaScript bytecode. ```plaintext /embedded /zipline /searchapp.manifest.zipline.json /stockapp.manifest.zipline.json /123sdf234sdf234 /234sd23dsf234sd /34897kj98987oik /890wer234sdsdfl ``` -------------------------------- ### Implement Trivia Service in Kotlin/JS Source: https://github.com/cashapp/zipline/blob/trunk/README.md Implement the shared TriviaService interface in the Kotlin/JS module. This class will be bound and exposed to the host platform. ```kotlin class RealTriviaService : TriviaService { // ... } ``` -------------------------------- ### Define Trivia Service Interface in Kotlin Source: https://github.com/cashapp/zipline/blob/trunk/README.md Define a service interface that extends ZiplineService. This interface will be shared between Kotlin/JVM and Kotlin/JS. ```kotlin interface TriviaService : ZiplineService { fun games(): List fun answer(questionId: String, answer: String): AnswerResult } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.