Skip to content

Commit 97550d2

Browse files
refactor: set Swift version and configure Objective-C++ interoperability in Podfile
refactor: remove deprecated Swift version and Objective-C++ interoperability configuration refactor: remove deprecated pod_target_xcconfig for Swift interoperability refactor: update deprecated APIs and improve Swift interoperability
1 parent 72bcf30 commit 97550d2

10 files changed

Lines changed: 20 additions & 209 deletions

File tree

MendixNative.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Pod::Spec.new do |s|
1414
s.source = { :git => "https://github.com/mendix/mendix-native.git", :tag => "#{s.version}" }
1515

1616
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
17-
s.public_header_files = "ios/Modules/Helper/ReactHostHelper.h"
18-
s.private_header_files = "ios/TurboModules/**/*.h"
17+
s.public_header_files = "ios/TurboModules/**/*.h"
1918

2019
s.dependency "SSZipArchive"
2120
s.dependency "RNCAsyncStorage"

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ EXTERNAL SOURCES:
21262126
SPEC CHECKSUMS:
21272127
FBLazyVector: e97c19a5a442429d1988f182a1940fb08df514da
21282128
hermes-engine: a7179a4cd45fa3f8143712e52bd3c2d20b5274a0
2129-
MendixNative: b0ea153b893ce40b90016f397e9a5acfe4444c33
2129+
MendixNative: d837df97dfd0018ca8106d4bc59242121961d9b7
21302130
op-sqlite: e9ef65bcf95a97863874cee87841425bb71c8396
21312131
OpenSSL-Universal: 9110d21982bb7e8b22a962b6db56a8aa805afde7
21322132
RCTDeprecation: af44b104091a34482596cd9bd7e8d90c4e9b4bd7

ios/Modules/Helper/DevHelper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public class DevHelper {
1010
getModule(type: RCTDevSettings.self)?.isShakeToShowDevMenuEnabled = enabled
1111

1212
// This event can be triggered to facilitate communication with the DevSettings JS module. Please refer to dev-settings.ts for further details.
13-
// ReactHostHelper().emitEvent("mendixSetShakeToShowDevMenu", payload: enabled)
13+
// getModule(type: RCTEventEmitter.self)?.sendEvent(withName: "mendixSetShakeToShowDevMenu", body: enabled)
1414
}
1515

1616
public static func hideDevLoadingView() {
1717
getModule(type: RCTDevLoadingView.self)?.hide()
1818
}
1919

2020
public static func getModule<T: NSObject>(type: T.Type) -> T? {
21-
return ReactHostHelper().module(for: T.self) as? T
21+
return ReactAppProvider.shared()?.reactHost()?.moduleRegistry.module(for: type.self) as? T
2222
}
2323
}

ios/Modules/Helper/ReactAppProvider.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ open class ReactAppProvider: UIResponder, UIApplicationDelegate {
5555
}
5656

5757
public static func shared() -> ReactAppProvider? {
58-
return UIApplication.shared.delegate as? ReactAppProvider
58+
if Thread.isMainThread {
59+
return UIApplication.shared.delegate as? ReactAppProvider
60+
} else {
61+
return DispatchQueue.main.sync {
62+
return UIApplication.shared.delegate as? ReactAppProvider
63+
}
64+
}
5965
}
6066

6167
public func changeRoot(to controller: UIViewController) {
@@ -68,7 +74,11 @@ open class ReactAppProvider: UIResponder, UIApplicationDelegate {
6874
}
6975

7076
public static func isReactAppActive() -> Bool {
71-
return ReactHostHelper().isReactAppActive()
77+
return shared()?.reactHost() != nil
78+
}
79+
80+
public func reactHost() -> RCTHost? {
81+
return reactNativeFactory?.rootViewFactory.reactHost
7282
}
7383
}
7484

ios/Modules/Helper/ReactHostHelper.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

ios/Modules/Helper/ReactHostHelper.mm

Lines changed: 0 additions & 78 deletions
This file was deleted.

ios/Modules/MendixBackwardsCompatUtility/MendixBackwardsCompatUtility.swift

Lines changed: 0 additions & 67 deletions
This file was deleted.

ios/Modules/MendixBackwardsCompatUtility/UnsupportedFeatures.swift

Lines changed: 0 additions & 12 deletions
This file was deleted.

ios/Modules/ReactNative.swift

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ public protocol ReactNativeDelegateInternal: AnyObject {
55
func onAppClosed()
66
}
77

8-
@objcMembers
98
open class ReactNative: NSObject, RCTReloadListener {
109
// MARK: - Properties
1110
private var mendixApp: MendixApp?
1211
private var bundleUrl: URL?
13-
private var mendixOTAEnabled: Bool = false
1412
private var tapGestureHelper: TapGestureRecognizerHelper?
1513

1614
public weak var delegate: ReactNativeDelegateInternal?
@@ -23,10 +21,9 @@ open class ReactNative: NSObject, RCTReloadListener {
2321
}
2422

2523
// MARK: - Setup Methods
26-
public func setup(_ mendixApp: MendixApp, launchOptions: [AnyHashable: Any]? = nil, mendixOTAEnabled: Bool = false) {
24+
public func setup(_ mendixApp: MendixApp, launchOptions: [AnyHashable: Any]? = nil) {
2725
self.mendixApp = mendixApp
2826
self.bundleUrl = mendixApp.bundleUrl
29-
self.mendixOTAEnabled = mendixOTAEnabled
3027

3128
if let host = bundleUrl?.host, let port = bundleUrl?.port {
3229
let jsLocation = "\(host):\(port)"
@@ -68,9 +65,7 @@ open class ReactNative: NSObject, RCTReloadListener {
6865

6966
// MARK: - Splash Screen Methods
7067
public func showSplashScreen() {
71-
if MendixBackwardsCompatUtility.isHideSplashScreenInClientSupported() {
72-
mendixApp?.splashScreenPresenter?.show(ReactAppProvider.shared()?.rootView)
73-
}
68+
mendixApp?.splashScreenPresenter?.show(ReactAppProvider.shared()?.rootView)
7469
}
7570

7671
public func hideSplashScreen() {
@@ -86,25 +81,11 @@ open class ReactNative: NSObject, RCTReloadListener {
8681
// which RCTHost re-invokes on reload. RCTReloadCommandSetBundleURL is a legacy-bridge
8782
// mechanism that the bridgeless host ignores, so it is intentionally not used here.
8883

89-
if mendixApp.isDeveloperApp {
90-
let runtimeInfoUrl = AppUrl.forRuntimeInfo(mendixApp.runtimeUrl.absoluteString)
91-
RuntimeInfoProvider.getRuntimeInfo(runtimeInfoUrl) { [weak self] response in
92-
if response.status == "SUCCESS", let version = response.runtimeInfo?.version {
93-
MendixBackwardsCompatUtility.update(version)
94-
}
95-
self?.reloadWithBridge()
96-
}
97-
} else {
98-
reloadWithBridge()
99-
}
100-
}
101-
102-
private func reloadWithBridge() {
10384
RCTTriggerReloadCommandListeners("Reload command from app")
10485
}
10586

10687
public func reloadWithState() {
107-
ReactHostHelper().reloadClientWithState()
88+
DevHelper.getModule(type: MxReload.self)?.emitOnReloadWithState()
10889
}
10990

11091
// MARK: - RCTReloadListener

ios/Modules/RuntimeInfoProvider/RuntimeInfo.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public class RuntimeInfo: NSObject {
3+
public class RuntimeInfo {
44

55
// MARK: - Properties
66
public let cacheburst: String
@@ -14,7 +14,6 @@ public class RuntimeInfo: NSObject {
1414
self.cacheburst = cacheburst
1515
self.nativeBinaryVersion = nativeBinaryVersion
1616
self.packagerPort = packagerPort
17-
super.init()
1817
}
1918

2019
convenience init(_ dictionary: [String: Any]) {

0 commit comments

Comments
 (0)