flowkey / UIKit-cross-platform

Cross-platform Swift implementation of UIKit, mostly for Android
MIT License
597 stars 40 forks source link

Restructure to use UIApplication #243

Closed ephemer closed 6 years ago

ephemer commented 6 years ago

Fixes #230

Type of change: Correctness and deployment fix

Motivation

Until now we had been doing some custom weirdness to render the initial views, either manually adding views to SDL.rootView or SDL.window (neither of which exists any longer) at some undefined point in time.

The current PR makes it a lot easier to make a cross-platform app, because we can use a common entry point that has more clearly-defined behaviour.

Android

import JNI
import UIKit

@_silgen_name("JNI_OnLoad")
public func JNI_OnLoad(jvm: UnsafeMutablePointer<JavaVM>, reserved: UnsafeMutableRawPointer) -> JavaInt {
    UIKitAndroid.UIApplicationDelegateClass = AppDelegate.self
    return JNI_VERSION_1_6
}

iOS / Mac (main.swift)

import UIKit

UIApplicationMain(0, nil, nil, NSStringFromClass(AppDelegate.self))