Skip to content

dboris/camlkit-starter-storyboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is a storyboard-based starter template for an iOS application built with Camlkit in OCaml. The template features a minimal Xcode project useful for testing the application on an iOS simulator, installing it on a device, debugging, etc.

The bulk of the application is built in OCaml and packaged as an xcframework, which gets linked with the Xcode project. The application follows the Main program in C pattern, and the main function is very minimal:

int main(int argc, char * argv[]) {
    caml_startup(argv);
    return UIApplicationMain(argc, argv, nil, @"AppDelegate");
}

The call to caml_startup initializes the OCaml runtime and causes the evaluation of the OCaml code. As a result of this evaluation, three Objective-C classes are defined and registered with the Objective-C runtime: GreetingsTVC, SceneDelegate, and AppDelegate.

The next call is to UIApplicationMain, which doesn't exit for the duration of running the application. UIApplicationMain instantiates UIApplication and AppDelegate, and when appropriate calls back the delegate's application:didFinishLaunchingWithOptions: method. This is the entry point in the OCaml part of the application, suitable for performing global initialization tasks.

UIApplicationMain creates a UISceneSession, a UIWindowScene, and an instance that will serve as the window scene’s delegate. The class of the window scene’s delegate is specified in Info.plist, under the key UISceneDelegateClassName.

UIApplicationMain looks to see whether the initial scene uses a storyboard. Info.plist specifies the name of its storyboard under the key path: UIApplicationSceneManifest -> UISceneConfigurations -> UISceneStoryboardFile

UIApplicationMain instantiates that storyboard’s initial view controller, a UIWindow, and assigns the initial view controller instance to the window’s rootViewController property. UIApplicationMain causes the app’s interface to appear by calling the UIWindow instance method makeKeyAndVisible.

Setup

opam repository add ios https://github.com/ocaml-cross/opam-cross-ios.git

opam switch create 4.14.2-device 4.14.2 --repos=default,ios
eval $(opam env)
ARCH=arm64 SUBARCH=arm64 PLATFORM=iPhoneOS SDK=$(xcrun --sdk iphoneos --show-sdk-version) VER=13.0 opam install conf-ios
opam install camlkit-ios

opam switch create 4.14.2-simulator 4.14.2 --repos=default,ios
eval $(opam env)
opam install conf-simulator-ios
ARCH=amd64 SUBARCH=x86_64 PLATFORM=iPhoneSimulator SDK=$(xcrun --sdk iphonesimulator --show-sdk-version) VER=13.0 opam install conf-ios
opam install camlkit-ios

opam switch create 4.14.2-simulator-arm 4.14.2 --repos=default,ios
eval $(opam env)
opam install conf-simulator-ios
ARCH=arm64 SUBARCH=arm64 PLATFORM=iPhoneSimulator SDK=$(xcrun --sdk iphonesimulator --show-sdk-version) VER=13.0 opam install conf-ios
opam install camlkit-ios

Building

Use make to build the xcframework and make open to open the project in Xcode.

About

Camlkit starter template using a storyboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published