diff --git a/app/App-Bridging-Header.h b/app/App-Bridging-Header.h new file mode 100644 index 0000000..9d09bb7 --- /dev/null +++ b/app/App-Bridging-Header.h @@ -0,0 +1 @@ +#import diff --git a/app/AppDelegate.h b/app/AppDelegate.h deleted file mode 100644 index 25a0c52..0000000 --- a/app/AppDelegate.h +++ /dev/null @@ -1,5 +0,0 @@ -#import - -@interface AppDelegate : UIResponder - -@end diff --git a/app/AppDelegate.m b/app/AppDelegate.m deleted file mode 100644 index 1dead42..0000000 --- a/app/AppDelegate.m +++ /dev/null @@ -1,31 +0,0 @@ -#import - -#import "AppDelegate.h" - -@implementation AppDelegate { - BareWorklet *worklet; -} - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - NSURL *url = [[NSBundle mainBundle] URLForResource:@"app" withExtension:@"bundle"]; - - worklet = [[BareWorklet alloc] initWithConfiguration:nil]; - - [worklet start:[url path] source:nil arguments:nil]; - - return YES; -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - [worklet suspend]; -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - [worklet resume]; -} - -- (void)applicationWillTerminate:(UIApplication *)application { - [worklet terminate]; -} - -@end diff --git a/app/AppDelegate.swift b/app/AppDelegate.swift new file mode 100644 index 0000000..3b7286f --- /dev/null +++ b/app/AppDelegate.swift @@ -0,0 +1,31 @@ +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + var window: UIWindow? + var worklet: BareWorklet? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + guard let url = Bundle.main.url(forResource: "app", withExtension: "bundle") else { + return false + } + + worklet = BareWorklet(configuration: nil) + + worklet?.start(url.path, source: nil, arguments: nil) + + return true + } + + func applicationDidEnterBackground(_ application: UIApplication) { + worklet?.suspend() + } + + func applicationWillEnterForeground(_ application: UIApplication) { + worklet?.resume() + } + + func applicationWillTerminate(_ application: UIApplication) { + worklet?.terminate() + } +} diff --git a/app/main.m b/app/main.m deleted file mode 100644 index 325b44c..0000000 --- a/app/main.m +++ /dev/null @@ -1,10 +0,0 @@ -#import - -#import "AppDelegate.h" - -int -main (int argc, char *argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/project.yml b/project.yml index 443927b..e87c3e3 100644 --- a/project.yml +++ b/project.yml @@ -9,17 +9,18 @@ targets: settings: base: PRODUCT_BUNDLE_IDENTIFIER: to.holepunch.bare.ios + SWIFT_VERSION: 6.0 + SWIFT_OBJC_BRIDGING_HEADER: app/App-Bridging-Header.h info: path: app/Info.plist dependencies: - framework: app/frameworks/BareKit.xcframework sources: - - path: app/AppDelegate.h - - path: app/AppDelegate.m + - path: app/AppDelegate.swift + - path: app/App-Bridging-Header.h + - path: app/app.js - path: app/app.bundle optional: true - - path: app/app.js - - path: app/main.m scheme: preActions: - name: Link