This sample app is available at https://github.com/skiptools/skipapp-hiya.git, which can be checked out and run once Skip is installed.
HiyaSkip
This is a Skip dual-platform app project that demonstrates the integration between a native Swift model layer compiled for Android connected to a transpiled SwiftUI user interface. For more information on using natively-compiled Swift on Android, see the native swift documentation.
This is the exact project with will be output when running the command:
skip init --appid=hiya.skip skipapp-hiya HiyaSkip HiyaSkipModel HiyaSkipLogic
The package will contain three modules:
- A top-level
HiyaSkip
target that uses SwiftUI that will be transpiled to Jetpack Compose on Android to make up the user interface portion of the app - A
HiyaSkipModel
model layer that will be compiled natively for both Android and iOS. It contains an@Observable ViewModel
that will be used directly on iOS, and on Android will be bridged to the transpiled user-interface layer using SkipFuse and SkipBridge. - A pure swift cross-platform
HiyaSkipLogic
module that does not use any bridging, and is depended on byHiyaSkipModel
The project structure looks like:
skipapp-hiya/
βββ Android
βΒ Β βββ app
βΒ Β βΒ Β βββ build.gradle.kts
βΒ Β βΒ Β βββ proguard-rules.pro
βΒ Β βΒ Β βββ src
βΒ Β βΒ Β βββ main
βΒ Β βΒ Β βββ AndroidManifest.xml
βΒ Β βΒ Β βββ kotlin
βΒ Β βΒ Β βββ hiya
βΒ Β βΒ Β βββ skip
βΒ Β βΒ Β βββ Main.kt
βΒ Β βββ gradle.properties
βΒ Β βββ settings.gradle.kts
βββ Darwin
βΒ Β βββ Assets.xcassets
βΒ Β βΒ Β βββ AccentColor.colorset
βΒ Β βΒ Β βΒ Β βββ Contents.json
βΒ Β βΒ Β βββ Contents.json
βΒ Β βββ Entitlements.plist
βΒ Β βββ HiyaSkip.xcconfig
βΒ Β βββ HiyaSkip.xcodeproj
βΒ Β βΒ Β βββ project.pbxproj
βΒ Β βββ Info.plist
βΒ Β βββ Sources
βΒ Β βββ HiyaSkipAppMain.swift
βββ Package.swift
βββ README.md
βββ Skip.env
βββ Sources
βΒ Β βββ HiyaSkip
βΒ Β βΒ Β βββ ContentView.swift
βΒ Β βΒ Β βββ HiyaSkipApp.swift
βΒ Β βΒ Β βββ Resources
βΒ Β βΒ Β βΒ Β βββ Localizable.xcstrings
βΒ Β βΒ Β βΒ Β βββ Module.xcassets
βΒ Β βΒ Β βΒ Β βββ Contents.json
βΒ Β βΒ Β βββ Skip
βΒ Β βΒ Β βββ skip.yml
βΒ Β βββ HiyaSkipLogic
βΒ Β βΒ Β βββ HiyaSkipLogic.swift
βΒ Β βββ HiyaSkipModel
βΒ Β βββ Resources
βΒ Β βΒ Β βββ Localizable.xcstrings
βΒ Β βββ Skip
βΒ Β βΒ Β βββ skip.yml
βΒ Β βββ ViewModel.swift
βββ Tests
βββ HiyaSkipModelTests
βΒ Β βββ HiyaSkipModelTests.swift
βΒ Β βββ Resources
βΒ Β βΒ Β βββ TestData.json
βΒ Β βββ Skip
βΒ Β βΒ Β βββ skip.yml
βΒ Β βββ XCSkipTests.swift
βββ HiyaSkipTests
βββ HiyaSkipTests.swift
βββ Resources
βΒ Β βββ TestData.json
βββ Skip
βΒ Β βββ skip.yml
βββ XCSkipTests.swift
Building
This project is both a stand-alone Swift Package Manager module, as well as an Xcode project that builds and transpiles the project into a Kotlin Gradle project for Android using the Skip plugin.
Building the module requires that Skip be installed using
Homebrew with brew install skiptools/skip/skip
.
This will also install the necessary transpiler prerequisites: Kotlin, Gradle, and the Android build tools.
Installation prerequisites can be confirmed by running skip checkup
.
Testing
The module can be tested using the standard swift test
command
or by running the test target for the macOS destination in Xcode,
which will run the Swift tests as well as the transpiled
Kotlin JUnit tests in the Robolectric Android simulation environment.
Parity testing can be performed with skip test
,
which will output a table of the test results for both platforms.
Running
Xcode and Android Studio must be downloaded and installed in order to run the app in the iOS simulator / Android emulator. An Android emulator must already be running, which can be launched from Android Studioβs Device Manager.
To run both the Swift and Kotlin apps simultaneously, launch the HiyaSkipApp target from Xcode. A build phases runs the βLaunch Android APKβ script that will deploy the transpiled app a running Android emulator or connected device. Logging output for the iOS app can be viewed in the Xcode console, and in Android Studioβs logcat tab for the transpiled Kotlin app.