Skip to content

Commit 2605b5a

Browse files
refactor: remove NSObject inheritance from multiple classes
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 refactor: update Swift version to 5.9 and adjust header file visibility in Podspec refactor: change classes to structs refactor: remove deprecated gesture recognition methods and related properties
1 parent 72bcf30 commit 2605b5a

21 files changed

Lines changed: 48 additions & 267 deletions

File tree

MendixNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ 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"
1817
s.private_header_files = "ios/TurboModules/**/*.h"
18+
s.public_header_files = "ios/TurboModules/MendixNativeHeader.h"
1919

2020
s.dependency "SSZipArchive"
2121
s.dependency "RNCAsyncStorage"

example/ios/MendixNativeExample.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279
PRODUCT_NAME = MendixNativeExample;
280280
SWIFT_OBJC_BRIDGING_HEADER = "MendixNativeExample-Bridging-Header.h";
281281
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
282-
SWIFT_VERSION = 5.0;
282+
SWIFT_VERSION = 5.9;
283283
VERSIONING_SYSTEM = "apple-generic";
284284
};
285285
name = Debug;
@@ -306,7 +306,7 @@
306306
PRODUCT_BUNDLE_IDENTIFIER = mendixnative.example;
307307
PRODUCT_NAME = MendixNativeExample;
308308
SWIFT_OBJC_BRIDGING_HEADER = "MendixNativeExample-Bridging-Header.h";
309-
SWIFT_VERSION = 5.0;
309+
SWIFT_VERSION = 5.9;
310310
VERSIONING_SYSTEM = "apple-generic";
311311
};
312312
name = Release;
@@ -393,6 +393,8 @@
393393
SDKROOT = iphoneos;
394394
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
395395
SWIFT_ENABLE_EXPLICIT_MODULES = NO;
396+
SWIFT_OBJC_INTEROP_MODE = objcxx;
397+
SWIFT_VERSION = 5.9;
396398
USE_HERMES = true;
397399
};
398400
name = Debug;
@@ -470,6 +472,8 @@
470472
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
471473
SDKROOT = iphoneos;
472474
SWIFT_ENABLE_EXPLICIT_MODULES = NO;
475+
SWIFT_OBJC_INTEROP_MODE = objcxx;
476+
SWIFT_VERSION = 5.9;
473477
USE_HERMES = true;
474478
VALIDATE_PRODUCT = YES;
475479
};

example/ios/Podfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,13 @@ target 'MendixNativeExample' do
3737
:mac_catalyst_enabled => false,
3838
# :ccache_enabled => true
3939
)
40+
installer.pods_project.targets.each do |target|
41+
if target.name == 'MendixNative'
42+
target.build_configurations.each do |config|
43+
config.build_settings['SWIFT_VERSION'] = '5.9'
44+
config.build_settings['SWIFT_OBJC_INTEROP_MODE'] = 'objcxx'
45+
end
46+
end
47+
end
4048
end
4149
end

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
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: 4800cb0079f0b97a86fea685d7ff4827fde5bdb7
21302130
op-sqlite: e9ef65bcf95a97863874cee87841425bb71c8396
21312131
OpenSSL-Universal: 9110d21982bb7e8b22a962b6db56a8aa805afde7
21322132
RCTDeprecation: af44b104091a34482596cd9bd7e8d90c4e9b4bd7
@@ -2204,6 +2204,6 @@ SPEC CHECKSUMS:
22042204
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
22052205
Yoga: c0b3f2c7e8d3e327e450223a2414ca3fa296b9a2
22062206

2207-
PODFILE CHECKSUM: 115c3d28fbc33ec0a408f3aba951d5d16e47a401
2207+
PODFILE CHECKSUM: 5f5cb642c9add825a81a839a00d9093747d28ee6
22082208

22092209
COCOAPODS: 1.15.2

ios/Modules/AppPreferences/AppPreferences.swift

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

3-
public class AppPreferences: NSObject {
3+
public struct AppPreferences {
44
@UserDefault(key: "ApplicationUrl", defaultValue: nil)
55
static var _appUrl: String?
66

ios/Modules/AppUrl/AppUrl.swift

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

3-
public class AppUrl: NSObject {
3+
public struct AppUrl {
44

55
// MARK: - Constants
66
public static let defaultPackagerPort = 8083

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.

0 commit comments

Comments
 (0)