I am reminded of the 1970s Rocky Horror Picture Show.
In just 7 days I can Make you a ... MAN.
-- Doctor Frank-N-Furter
Well, I love making things and when I saw a toot about Skip the Trans-Compiling Xcode "plug-in" to build and make Android Apps from Swift code... I was hooked. I will try that.
My cohorts for my first iOS App, InspireMe! Cards always wanted a version for their phones running that rip-off OS on that also-ran hardware. But I had made it clear - I was not the developer to create that app. I tried to recruit some beginners who wanted to learn and build - but that path never worked - too much hard work I guess.
Skip's Hello World App running side by side.
Gradle needs a Java SDK
Installing Skip is relatively easy.... getting all the toolchain links working - well that is an exercise in reading logs, finding failures, and downloading more stuff you must implicitly trust. Then configuring the heck out of it.
It will make you reflect on just how valuable that $100 fee for Apple's Developer Ecosystem is worth. Priceless!
This is not a "How To" on installing & configuring Skip...
I once had a job with the university that was largely reverse engineering various Software installation scripts and reworking them to run on our Sun SparkStation AFS system - project Mosaic. The quirk there was that the replication system relied on write-once, read-only installations. Most unix installs at the time enjoyed writing logs to the installation folders. As well as many other poor practices.
I got out of that business many years ago... I hate to have to be the system administrator of my MacBook. By extension, I hate Java installs.
I don't know why after installing and configuring and compiling the Hello World App... when I ran the checkup script... it still had dependencies to download... <frustration> increases++ </frustration>
The customer experience is very important... did you ever read the studies about how to increase patient satisfaction with old-school colonoscopy exams? Weirdly you increase the time...
While Skip has a section on how much effort they have gone to ... to make Skip disappear into the background - I wish they had a section on how to retrofit an existing App into their complex system.
See Developing with Skip.
Start from a copy of their Hello Skipper App. Then copy my existing Apps source code and resources into the existing Hello Skipper App one piece at a time...
At some point that is going to break something... there is little chance that I can drag & drop the files in a proper no dependency skipped way - is there?
I'm in Java land-HELL and can't compile because it cannot find a resource that is the responsibility of yet another 3rd party that this compile is dependent upon. This makes me sick to my senses. It is the reason - I didn't go down the path of porting my App to Android in the first place. Because it is a house of cards that collapses with the slightest breeze.
And in this particular case, I know what the problem is - I just do not know how to fix it. I can get the detail logs - dumped to the screen, then sift through the logs to find the error. And it almost tells me exactly but not quite how to fix it.
After you set the local.properties with ANDROID_HOME. You think it's going to work so you try again. But it does not work... same error. Why did it not work... you cannot tell. Is this a good situation to REBOOT the instance of the WORLD?
We all know - too much Java will make you gittery and maybe even set off ANGER and FRuSTratiON!
I seem to have resolved my Skip compile failures by Removing one to many Java folders on my machine. Seems that the classic "just set JAVA_HOME" was causing it's own set of dependency clashing failure modes. I deleted all - but ONE - the (Apple Silicone M1 - Java 17) Java installs - removed all the ENV VARs that I tried to set. And rebooted the World. Because Env Var are tightly coupled with the start-up of terminals and shells.
Got out of the automobile on the right side - walked around to the left side and got back in. And it worked!
Learning Java and using Java as a solution is like the frogs in the pot of water - sitting on a fire... the pot is going to boil - but the frogs are staying in their safe spot.
Trust me - there are way better environments to program within - way better eco-systems to spend your time/energy maintaining and more fun places to play. JUMP OUT!
Yeah... me too. Maybe I can get back to figuring out how to retrofit my iOS App into the Skip (Java infested waters) and out will pop an Android App...
I will let you know...
Q: How do I get started porting my existing iOS App?
The short answer is that Skip, at this early stage, is best suited to new, greenfield apps. That doesn't mean that you can't bring over your existing SwiftUI and business logic, it just means that you'll need to migrate it yourself.
We'll be writing a blog post and more documentation on this topic soon. In short, we envision the path from an existing iOS app to a dual-platform iOS/Android app using Skip will look something like this:
Create a new Skip project with skip init --appid=… project-name AppName ModuleA ModuleB ModuleC …. See https://skip.tools/docs/gettingstarted/
Take your existing app and move over the code, file by file, into the appropriate ModuleX module (for business logic) or the AppName module (for top-level SwiftUI code). Make sure the project builds and transpiles each time you make a change, either by running an Xcode Build or swift build in the project folder.
If your app has major dependencies on external non-Skipified frameworks, assess how best to replace or re-implement that functionality. Depending on the architecture of your app, this could be either a minor change (e.g., by using one of the standard Skip Frameworks from https://skip.tools/docs/modules/), or a major operation.
Write tests for each module and place them in Tests/ModuleATests/TestModuleA.swift tests. Run them with swift test or skip test to ensure that both the Swift and transpiled Kotlin tests pass. These tests will be exercising your logic in both the Swift and Kotlin (JVM) environments, which are quite different (see https://skip.tools/docs/developing/). Extensive testing is critical to the success of any Skip project.
Once all the modules are building and passing unit tests, move on to the user-interface code and start iterating on your app running it in tandem on the iOS Simulator and Android emulator. These environments are similar but not identical to their testing-environment counterparts (macOS for Swift and Robolectric for Kotlin), so you may need to make adjustments to your business logic.
Many SwiftUI features won't work until they are implemented. Visit https://github.com/skiptools/skip-ui/issues to see a list of open issue and how you can help. Missing SwiftUI features can be worked-around using #if SKIP blocks (see https://skip.tools/docs/platformcustomization/ for details).
Take it slowly and write lots of tests, and you'll be well on your way to to bringing your iOS app to Android and creating a genuinely native dual-platform application.
From: Marc of SkipTools
Q: I see multiple folders that contain SwiftUI files in the Hello-Skip example; where do I place a new Swift View?
You should implement everything app-related in the module(s) under the Sources/AppName/. Source code in the Darwin/Sources/ and Android/app/src/main/ folders are the app's Swift/Kotlin outermost "scaffolding" and are not transpiled by Skip, and will generally contain the nitty-gritty details of the deployment for the app on each platforms.
The Sources/AppName/ folder (and any other local or remote dependent modules you add to your Package.swift project) will be transpiled into Kotlin, and so run on both platforms. That is where you should do your app and model development. You generally only need to touch the platform-specific stuff when you have very platform-bespoke setup to perform, like requesting permissions or setting up the app's style and theme parameters.
Documentation on this topic is still forthcoming. Thanks for helping identify this deficiency, and we hope you continue to try out the Skip tech preview!
From Marc of SkipTools