diff --git a/ios/AlerteSecours.xcodeproj/project.pbxproj b/ios/AlerteSecours.xcodeproj/project.pbxproj index 1533f03..d00877e 100644 --- a/ios/AlerteSecours.xcodeproj/project.pbxproj +++ b/ios/AlerteSecours.xcodeproj/project.pbxproj @@ -196,9 +196,10 @@ BAD00DBFD7D44CD2956A18DF /* Fix Xcode 15 Bug */, 9E6F0A1338934BA5AD468D4B /* Fix Xcode 15 Bug */, 229987488EA44E69AA932D58 /* Fix Xcode 15 Bug */, - 1B0B11FFE0884C2B9A75B09D /* Remove signature files (Xcode workaround) */, A891237ADBD54747890A99FB /* Fix Xcode 15 Bug */, B700EE07E2A24654A0953D3B /* Remove signature files (Xcode workaround) */, + 9E272D599E42446BB8DFD8D0 /* Fix Xcode 15 Bug */, + CBAD4F53ADB04F499371D5DE /* Remove signature files (Xcode workaround) */, ); buildRules = ( ); @@ -1031,6 +1032,40 @@ fi"; shellScript = " echo \"Remove signature files (Xcode workaround)\"; rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\"; + "; + }; + 9E272D599E42446BB8DFD8D0 /* Fix Xcode 15 Bug */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + name = "Fix Xcode 15 Bug"; + inputPaths = ( + ); + outputPaths = ( + ); + shellPath = /bin/sh; + shellScript = "if [ \"$XCODE_VERSION_MAJOR\" = \"1500\" ]; then + echo \"Remove signature files (Xcode 15 workaround)\" + find \"$BUILD_DIR/${CONFIGURATION}-iphoneos\" -name \"*.signature\" -type f | xargs -r rm +fi"; + }; + CBAD4F53ADB04F499371D5DE /* Remove signature files (Xcode workaround) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + name = "Remove signature files (Xcode workaround)"; + inputPaths = ( + ); + outputPaths = ( + ); + shellPath = /bin/sh; + shellScript = " + echo \"Remove signature files (Xcode workaround)\"; + rm -rf \"$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature\"; "; }; /* End PBXShellScriptBuildPhase section */ diff --git a/ios/AlerteSecours/AppDelegate.swift b/ios/AlerteSecours/AppDelegate.swift index c2d7a0d..7bd734b 100644 --- a/ios/AlerteSecours/AppDelegate.swift +++ b/ios/AlerteSecours/AppDelegate.swift @@ -1,29 +1,76 @@ -import ExpoModulesCore +import EXUpdates import FirebaseCore +import React +import TSBackgroundFetch import UIKit @objc(AppDelegate) -class AppDelegate: ExpoAppDelegate { +class AppDelegate: RCTAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil ) -> Bool { - // Log to verify the new ExpoAppDelegate-based path runs on iOS. - NSLog("[AppDelegate] didFinishLaunchingWithOptions (ExpoAppDelegate)") + NSLog("[AppDelegate] didFinishLaunchingWithOptions (RCTAppDelegate)") - // Configure Firebase (react-native-firebase) + // Configure Firebase (react-native-firebase). FirebaseApp.configure() // Transistorsoft background fetch bootstrap. TSBackgroundFetch.sharedInstance().didFinishLaunching() NSLog("[AppDelegate] TSBackgroundFetch didFinishLaunching") + // Initialize expo-updates controller so AppController.sharedInstance can be used safely. + AppController.initializeWithoutStarting() + AppController.sharedInstance.start() + // Configure React Native root module. - moduleName = "main" - initialProps = [:] + self.moduleName = "main" + self.initialProps = [:] let result = super.application(application, didFinishLaunchingWithOptions: launchOptions) NSLog("[AppDelegate] super.application(...) -> %@", result ? "true" : "false") return result } + + // MARK: - RCTBridgeDelegate / JS bundle location + + @objc + override func sourceURL(for bridge: RCTBridge!) -> URL! { + #if DEBUG + let url = RCTBundleURLProvider.sharedSettings().jsBundleURL( + forBundleRoot: ".expo/.virtual-metro-entry", + fallbackExtension: nil + ) + NSLog("[AppDelegate] sourceURL(for:) (DEBUG) -> %@", url?.absoluteString ?? "nil") + return url + #else + let url = self.bundleURL() + NSLog("[AppDelegate] sourceURL(for:) (RELEASE) -> %@", url?.absoluteString ?? "nil") + return url + #endif + } + + @objc + override func bundleURL() -> URL! { + #if DEBUG + let url = RCTBundleURLProvider.sharedSettings().jsBundleURL( + forBundleRoot: ".expo/.virtual-metro-entry", + fallbackExtension: nil + ) + NSLog("[AppDelegate] bundleURL() (DEBUG) -> %@", url?.absoluteString ?? "nil") + return url + #else + if let updatesURL = AppController.sharedInstance.launchAssetUrl() { + NSLog("[AppDelegate] bundleURL() (RELEASE) -> %@", updatesURL.absoluteString) + return updatesURL + } + let url = Bundle.main.url(forResource: "main", withExtension: "jsbundle") + if let url = url { + NSLog("[AppDelegate] bundleURL() (RELEASE fallback) -> %@", url.absoluteString) + } else { + NSLog("[AppDelegate] bundleURL() (RELEASE fallback) -> nil (main.jsbundle not found)") + } + return url + #endif + } }