Skip to content

Commit 06b82a0

Browse files
committed
refactor: migrate AppDelegate to Swift and remove Objective-C files
1 parent 7c7cbff commit 06b82a0

File tree

6 files changed

+111
-159
lines changed

6 files changed

+111
-159
lines changed

example/ios/AppDelegate.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// AppDelegate.swift
3+
// ReactNativeSdkExample
4+
//
5+
// Created by Loren Posen on 6/11/25.
6+
//
7+
8+
import UIKit
9+
import React
10+
import React_RCTAppDelegate
11+
import ReactAppDependencyProvider
12+
13+
@main
14+
class AppDelegate: UIResponder, UIApplicationDelegate {
15+
var window: UIWindow?
16+
17+
var reactNativeDelegate: ReactNativeDelegate?
18+
var reactNativeFactory: RCTReactNativeFactory?
19+
20+
func application(
21+
_ application: UIApplication,
22+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
23+
) -> Bool {
24+
let delegate = ReactNativeDelegate()
25+
let factory = RCTReactNativeFactory(delegate: delegate)
26+
delegate.dependencyProvider = RCTAppDependencyProvider()
27+
28+
reactNativeDelegate = delegate
29+
reactNativeFactory = factory
30+
31+
window = UIWindow(frame: UIScreen.main.bounds)
32+
33+
factory.startReactNative(
34+
withModuleName: "ReactNativeSdkExample",
35+
in: window,
36+
launchOptions: launchOptions
37+
)
38+
39+
return true
40+
}
41+
}
42+
43+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
44+
override func sourceURL(for bridge: RCTBridge) -> URL? {
45+
self.bundleURL()
46+
}
47+
48+
override func bundleURL() -> URL? {
49+
#if DEBUG
50+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
51+
#else
52+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
53+
#endif
54+
}
55+
}
56+

0 commit comments

Comments
 (0)