From f8acc1ce48f25811629f24a8e73e15f01a6f497a Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Tue, 21 Jan 2025 13:56:40 +0100 Subject: [PATCH] chore: Switch to Swift-based `AppDelegate` --- example/ios/AppDelegate.swift | 36 +++++++++++++++++++ example/ios/DummyFile.swift | 8 ----- example/ios/NitroExample-Bridging-Header.h | 3 -- .../NitroExample.xcodeproj/project.pbxproj | 32 ++++------------- example/ios/NitroExample/AppDelegate.h | 6 ---- example/ios/NitroExample/AppDelegate.mm | 31 ---------------- example/ios/NitroExample/main.m | 10 ------ example/ios/Podfile.lock | 2 +- 8 files changed, 43 insertions(+), 85 deletions(-) create mode 100644 example/ios/AppDelegate.swift delete mode 100644 example/ios/DummyFile.swift delete mode 100644 example/ios/NitroExample-Bridging-Header.h delete mode 100644 example/ios/NitroExample/AppDelegate.h delete mode 100644 example/ios/NitroExample/AppDelegate.mm delete mode 100644 example/ios/NitroExample/main.m diff --git a/example/ios/AppDelegate.swift b/example/ios/AppDelegate.swift new file mode 100644 index 000000000..e1d57153b --- /dev/null +++ b/example/ios/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// NitroExample +// +// Created by Marc Rousavy on 21.01.25. +// + +import UIKit +import React +import React_RCTAppDelegate + +@main +class AppDelegate: RCTAppDelegate { + override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + self.moduleName = "NitroExample" + //self.dependencyProvider = RCTAppDependencyProvider() + + // You can add your custom initial props in the dictionary below. + // They will be passed down to the ViewController used by React Native. + self.initialProps = [:] + + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } + + override func sourceURL(for bridge: RCTBridge) -> URL? { + self.bundleURL() + } + + override func bundleURL() -> URL? { +#if DEBUG + RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") +#else + Bundle.main.url(forResource: "main", withExtension: "jsbundle") +#endif + } +} diff --git a/example/ios/DummyFile.swift b/example/ios/DummyFile.swift deleted file mode 100644 index fa2c53227..000000000 --- a/example/ios/DummyFile.swift +++ /dev/null @@ -1,8 +0,0 @@ -// -// DummyFile.swift -// NitroExample -// -// Created by Marc Rousavy on 19.06.24. -// - -import Foundation diff --git a/example/ios/NitroExample-Bridging-Header.h b/example/ios/NitroExample-Bridging-Header.h deleted file mode 100644 index e11d920b1..000000000 --- a/example/ios/NitroExample-Bridging-Header.h +++ /dev/null @@ -1,3 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// diff --git a/example/ios/NitroExample.xcodeproj/project.pbxproj b/example/ios/NitroExample.xcodeproj/project.pbxproj index 4b1de6578..b5352701d 100644 --- a/example/ios/NitroExample.xcodeproj/project.pbxproj +++ b/example/ios/NitroExample.xcodeproj/project.pbxproj @@ -9,14 +9,12 @@ /* Begin PBXBuildFile section */ 00E356F31AD99517003FC87E /* NitroExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* NitroExampleTests.m */; }; 0C80B921A6F3F58F76C31292 /* libPods-NitroExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-NitroExample.a */; }; - 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; - 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 7699B88040F8A987B510C191 /* libPods-NitroExample-NitroExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-NitroExample-NitroExampleTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; B5425A16F500085048F53261 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = A98DCE138B16911E2CF8DB85 /* PrivacyInfo.xcprivacy */; }; + B88C9DC22D3FCE4D00133987 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B88C9DC12D3FCE4B00133987 /* AppDelegate.swift */; }; B88F64252CE4CF530079E862 /* MGLExampleTurboModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = B88F64242CE4CF4F0079E862 /* MGLExampleTurboModule.mm */; }; - B8D0C54B2C2357CE0037DD32 /* DummyFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8D0C54A2C2357CE0037DD32 /* DummyFile.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -34,11 +32,8 @@ 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 00E356F21AD99517003FC87E /* NitroExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NitroExampleTests.m; sourceTree = ""; }; 13B07F961A680F5B00A75B9A /* NitroExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NitroExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = NitroExample/AppDelegate.h; sourceTree = ""; }; - 13B07FB01A68108700A75B9A /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = NitroExample/AppDelegate.mm; sourceTree = ""; }; 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = NitroExample/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = NitroExample/Info.plist; sourceTree = ""; }; - 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = NitroExample/main.m; sourceTree = ""; }; 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = NitroExample/PrivacyInfo.xcprivacy; sourceTree = ""; }; 19F6CBCC0A4E27FBF8BF4A61 /* libPods-NitroExample-NitroExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NitroExample-NitroExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B4392A12AC88292D35C810B /* Pods-NitroExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NitroExample.debug.xcconfig"; path = "Target Support Files/Pods-NitroExample/Pods-NitroExample.debug.xcconfig"; sourceTree = ""; }; @@ -48,10 +43,9 @@ 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = NitroExample/LaunchScreen.storyboard; sourceTree = ""; }; 89C6BE57DB24E9ADA2F236DE /* Pods-NitroExample-NitroExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NitroExample-NitroExampleTests.release.xcconfig"; path = "Target Support Files/Pods-NitroExample-NitroExampleTests/Pods-NitroExample-NitroExampleTests.release.xcconfig"; sourceTree = ""; }; A98DCE138B16911E2CF8DB85 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = NitroExample/PrivacyInfo.xcprivacy; sourceTree = ""; }; + B88C9DC12D3FCE4B00133987 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; B88F64232CE4CF480079E862 /* MGLExampleTurboModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLExampleTurboModule.h; sourceTree = ""; }; B88F64242CE4CF4F0079E862 /* MGLExampleTurboModule.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLExampleTurboModule.mm; sourceTree = ""; }; - B8D0C5492C2357CE0037DD32 /* NitroExample-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NitroExample-Bridging-Header.h"; sourceTree = ""; }; - B8D0C54A2C2357CE0037DD32 /* DummyFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DummyFile.swift; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -95,17 +89,13 @@ 13B07FAE1A68108700A75B9A /* NitroExample */ = { isa = PBXGroup; children = ( + B88C9DC12D3FCE4B00133987 /* AppDelegate.swift */, B88F64222CE4CF3F0079E862 /* Example Turbo Module */, - 13B07FAF1A68108700A75B9A /* AppDelegate.h */, - 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 13B07FB51A68108700A75B9A /* Images.xcassets */, 13B07FB61A68108700A75B9A /* Info.plist */, 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, - 13B07FB71A68108700A75B9A /* main.m */, 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */, A98DCE138B16911E2CF8DB85 /* PrivacyInfo.xcprivacy */, - B8D0C54A2C2357CE0037DD32 /* DummyFile.swift */, - B8D0C5492C2357CE0037DD32 /* NitroExample-Bridging-Header.h */, ); name = NitroExample; sourceTree = ""; @@ -416,9 +406,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */, - B8D0C54B2C2357CE0037DD32 /* DummyFile.swift in Sources */, - 13B07FC11A68108700A75B9A /* main.m in Sources */, + B88C9DC22D3FCE4D00133987 /* AppDelegate.swift in Sources */, B88F64252CE4CF530079E862 /* MGLExampleTurboModule.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -512,7 +500,6 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.mrousavy.nitro.example; PRODUCT_NAME = NitroExample; - SWIFT_OBJC_BRIDGING_HEADER = "NitroExample-Bridging-Header.h"; SWIFT_OBJC_INTEROP_MODE = objc; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -544,7 +531,6 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.mrousavy.nitro.example; PRODUCT_NAME = NitroExample; - SWIFT_OBJC_BRIDGING_HEADER = "NitroExample-Bridging-Header.h"; SWIFT_OBJC_INTEROP_MODE = objc; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -624,10 +610,7 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = ( - "$(inherited)", - " ", - ); + OTHER_LDFLAGS = "$(inherited) "; REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native"; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; @@ -701,10 +684,7 @@ "-DFOLLY_CFG_NO_COROUTINES=1", "-DFOLLY_HAVE_CLOCK_GETTIME=1", ); - OTHER_LDFLAGS = ( - "$(inherited)", - " ", - ); + OTHER_LDFLAGS = "$(inherited) "; REACT_NATIVE_PATH = "${PODS_ROOT}/../../../node_modules/react-native"; SDKROOT = iphoneos; SWIFT_OBJC_INTEROP_MODE = objcxx; diff --git a/example/ios/NitroExample/AppDelegate.h b/example/ios/NitroExample/AppDelegate.h deleted file mode 100644 index 5d2808256..000000000 --- a/example/ios/NitroExample/AppDelegate.h +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import - -@interface AppDelegate : RCTAppDelegate - -@end diff --git a/example/ios/NitroExample/AppDelegate.mm b/example/ios/NitroExample/AppDelegate.mm deleted file mode 100644 index 0a566e951..000000000 --- a/example/ios/NitroExample/AppDelegate.mm +++ /dev/null @@ -1,31 +0,0 @@ -#import "AppDelegate.h" - -#import - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - self.moduleName = @"NitroExample"; - // You can add your custom initial props in the dictionary below. - // They will be passed down to the ViewController used by React Native. - self.initialProps = @{}; - - return [super application:application didFinishLaunchingWithOptions:launchOptions]; -} - -- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge -{ - return [self bundleURL]; -} - -- (NSURL *)bundleURL -{ -#if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; -#else - return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; -#endif -} - -@end diff --git a/example/ios/NitroExample/main.m b/example/ios/NitroExample/main.m deleted file mode 100644 index d645c7246..000000000 --- a/example/ios/NitroExample/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/example/ios/Podfile.lock b/example/ios/Podfile.lock index 338929c1f..a9cc2cc09 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1895,7 +1895,7 @@ SPEC CHECKSUMS: glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 1949ca944b195a8bde7cbf6316b9068e19cf53c6 NitroImage: ccc116b3881f723f1d3f77743acf8028681160f1 - NitroModules: 9d5bc0172f6d9b098eb29e8cd9891e16881cd4b6 + NitroModules: 8448d25a61e25ef84aa056568d3036fd0c202e03 RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: 063fc281b30b7dc944c98fe53a7e266dab1a8706 RCTRequired: 8eda2a5a745f6081157a4f34baac40b65fe02b31