[CM] OT Using s7 in an iOS mobile app + SQLite

mike at eggheadgames.com mike at eggheadgames.com
Tue Jan 11 21:19:09 PST 2022

A quick note of thanks to all involved for a *great* piece of software 
in s7 - obviously Bil, but also many others via bug reports, 
documentation or emails in this list.

TLDR: I can report successfully shipping s7 (with SQLite) in an iOS 
mobile app, and plan to do the same with Android before too long.

More details in case you’re interested:

I’ve put my toe in the water and one of my apps currently includes s7 
version 9.18 along with a recent SQLite. Most of the app is still in 
Swift, and it passes an established SQLite connection pointer into a 
tiny s7 / SQlite C wrapper. With this, one of the app’s screens loads 
a few .scm files which run SQL queries and prepare content for a Swift 
view. The Scheme code then supports subsequent user interactions on that 
screen. It’s simple stuff, but it’s cut development time hugely 
compared with Xcode + Swift. So far the app is just as stable as the 
prior Swift-only version. My fears of bizarre memory leaks or 
impenetrable crash logs have not been realised.

The architecture is evolving, but is currently arranged to implement a 
ViewModel and Model in Scheme with the View remaining in Swift + 
Storyboards (so-called MVVM). We tend to develop TDD-style, building 
comprehensive Scheme integration tests that run mostly at the ViewModel 
level (along with existing iOS XCTests). There’s a slim Swift wrapper 
to handle basic type conversion/mapping (int, string, bool, array, set) 
along with procedure calling and an attempt at correctly using 
s7_gc_protect / s7_gc_unprotect_at. We also wired up a simple callback 
mechanism to fire notifications from Scheme that could be observed by 
NSNotification in Swift, though we will likely step back from using it 
extensively for now to keep things simple(r).

Perhaps erroneously, we made yet another (simple!) REPL. This includes 
SQLite and we use it to run our tests, as well as for interactive 
development using various existing Emacs Scheme/Lisp tools.

Using s7 is the latest attempt in my never-ending search for the holy 
grail of cross-platform mobile development :), building on earlier 
efforts which adopted SQLite. It’s also been our first real experience 
with Scheme as a language. It’s been great fun! All the joy and 
convenience of an interactive high level language, but somehow still 
like coding in assembly :)

Next step is try this on Android, where the fun part will be calling C, 
and hence s7, through the JNI layer!

Cheers, Michael

More information about the Cmdist mailing list