Creating a Project
scd project init generates a complete multiplatform project in the current directory. Run it once when starting a new app.
Basic usage
Section titled “Basic usage”mkdir MyApp && cd MyAppscd project initThis uses the directory name as the project name and generates com.myapp.myapp as the package identifier. Pass --package-id to set it explicitly:
scd project init --package-id com.example.myappOptions
Section titled “Options”| Option | Description |
|---|---|
-n, --name | Project name. Defaults to current directory name. |
--package-id | Android package / Apple bundle identifier. Defaults to com.<name>.<name>. |
scd project init --name MyApp --package-id com.example.myappGenerated structure
Section titled “Generated structure”MyApp/ Packages/MyApp/ Package.swift Sources/MyApp/ MyApp.swift
Android/MyApp/ app/ build.gradle.kts src/main/ AndroidManifest.xml java/com/example/myapp/ MainActivity.kt build.gradle.kts settings.gradle.kts gradle/ libs.versions.toml wrapper/
Apple/MyApp/ MyApp.xcodeproj/ project.pbxproj project.xcworkspace/ Sources/ MyAppApp.swift ContentView.swift Assets.xcassets/What each part contains
Section titled “What each part contains”Packages/MyApp/Package.swift
Section titled “Packages/MyApp/Package.swift”A Swift 6 dynamic library targeting macOS 14 and iOS 17, with a dependency on swift4j. The placeholder source file uses @jvm to mark the main class for export to Kotlin/Java:
import Swift4j
@jvmpublic class MyApp { public init() {} public func greeting() -> String { "Hello from Swift!" }}Android/MyApp/app/build.gradle.kts
Section titled “Android/MyApp/app/build.gradle.kts”Applies the SCADE SPM Gradle plugin and points it at the shared Swift package:
plugins { id("com.android.application") id("io.scade.gradle.plugins.android.swiftpm") version "latest.release"}
swiftpm { path = file("../../../Packages/MyApp") product = "MyApp" javaVersion = 8 scdAutoUpdate = true}The Gradle build handles Swift compilation, JNI bridging generation, and APK packaging automatically. See Gradle Plugin for the full configuration reference.
Apple/MyApp/MyApp.xcodeproj
Section titled “Apple/MyApp/MyApp.xcodeproj”An Xcode project with two native targets:
| Target | Platform | Deployment target |
|---|---|---|
MyAppIOS | iPhone + Simulator | iOS 17.0+ |
MyAppMacOS | macOS | macOS 14.0+ |
Both targets reference Packages/MyApp as a local Swift package. ContentView.swift calls MyApp().greeting() from the shared library.
Next steps
Section titled “Next steps”After generating the project: