wudebin 2 maanden geleden
bovenliggende
commit
51758dad69

+ 5 - 0
Strides-SPAPP/android/app/src/main/java/com/strides/chargeco/MainActivity.kt

@@ -15,6 +15,11 @@ class MainActivity : ReactActivity() {
    */
   override fun getMainComponentName(): String = "Strides"
 
+  override fun onCreate(savedInstanceState: Bundle?) {
+    // 关键点:传入 null 而不是 savedInstanceState
+    super.onCreate(null)
+  }
+
   /**
    * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
    * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]

+ 4 - 0
Strides-SPAPP/ios/BridgingHeader.h

@@ -0,0 +1,4 @@
+#import <React/RCTBundleURLProvider.h>
+#import <React/RCTBridgeDelegate.h>
+#import <RNCPushNotificationIOS/RNCPushNotificationIOS.h>
+#import <FirebaseMessaging/FirebaseMessaging.h>

+ 42 - 115
Strides-SPAPP/ios/Podfile

@@ -1,10 +1,5 @@
+require_relative '../node_modules/react-native/scripts/react_native_pods.rb'
 # Resolve react_native_pods.rb with node to allow for hoisting
-require Pod::Executable.execute_command('node', ['-p',
-  'require.resolve(
-    "react-native/scripts/react_native_pods.rb",
-    {paths: [process.argv[1]]},
-  )', __dir__]).strip
-require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
 def node_require(script)
   # Resolve script with node to allow for hoisting
   require Pod::Executable.execute_command('node', ['-p',
@@ -13,10 +8,11 @@ def node_require(script)
       {paths: [process.argv[1]]},
   )", __dir__]).strip
 end
-node_require('react-native/scripts/react_native_pods.rb')
+
+#node_require('react-native/scripts/react_native_pods.rb')
 node_require('react-native-permissions/scripts/setup.rb')
 
-platform :ios, '13.0'
+platform :ios, '15.1'
 prepare_react_native_project!
 
 # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
@@ -29,7 +25,7 @@ prepare_react_native_project!
 #     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
 # ```
 #flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
-flipper_config = FlipperConfiguration.disabled;
+#flipper_config = FlipperConfiguration.disabled;
 
 linkage = ENV['USE_FRAMEWORKS']
 if linkage != nil
@@ -62,13 +58,17 @@ setup_permissions([
 target 'Strides' do
   config = use_native_modules!
 
-  # Flags change depending on the env values.
-  flags = get_default_flags()
+  use_react_native!(
+    :path => config[:reactNativePath],
+    :fabric_enabled => true,
+    # An absolute path to your application root.
+    :app_path => "#{Pod::Config.instance.installation_root}/.."
+  )
 
   # 谷歌地图服务
-  pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
+  # pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
   rn_maps_path = '../node_modules/react-native-maps'
-  pod 'react-native-google-maps', :path => rn_maps_path
+  pod 'react-native-maps/Google', :path => rn_maps_path
   # pod 'GoogleMaps', '3.5.0'
   # pod 'Google-Maps-iOS-Utils', '2.1.0'
 
@@ -77,118 +77,45 @@ target 'Strides' do
   pod 'FirebaseCore'
   pod 'FirebaseAnalytics'
   pod 'FirebaseMessaging'
+  pod 'FirebaseCrashlytics'
+  pod 'GoogleDataTransport', :modular_headers => true
+  pod 'nanopb', :modular_headers => true
   # pod 'FirebaseFirestore'
   pod 'GoogleUtilities', :modular_headers => true
 
-  use_react_native!(
-    :path => config[:reactNativePath],
-    # Hermes is now enabled by default. Disable by setting this flag to false.
-    :hermes_enabled => flags[:hermes_enabled],
-    :fabric_enabled => flags[:fabric_enabled],
-    # Enables Flipper.
-    #
-    # Note that if you have use_frameworks! enabled, Flipper will not work and
-    # you should disable the next line.
-    :flipper_configuration => flipper_config,
-    # An absolute path to your application root.
-    :app_path => "#{Pod::Config.instance.installation_root}/.."
-  )
-
-  target 'StridesTests' do
-    inherit! :complete
-    # Pods for testing
-  end
-
-  # Enables Flipper.
-  #
-  # Note that if you have use_frameworks! enabled, Flipper will not work and
-  # you should disable the next line.
-  # use_flipper!()
-  # use_flipper!({'Flipper' => '0.182.0', 'Flipper-Folly' => '2.6.10', 'Flipper-RSocket' => '1.3.1'})
-
-  #post_install do |installer|
-  #  react_native_post_install(installer)
-  #end
-
-  #--------------------修复iOS 16.4新建RN0.64无法运行--------------------------
-  # post_install do |installer|
-  #  react_native_post_install(installer)
-  #  fix_library_search_paths(installer)
-  #  installer.pods_project.build_configurations.each do |config|
-  #    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
+  # target 'StridesTests' do
+  #   inherit! :complete
+  #   # Pods for testing
   # end
-  #end
 
   post_install do |installer|
-    react_native_post_install(
-      installer,
-      config[:reactNativePath],
-      :mac_catalyst_enabled => false
-    )
-    fix_library_search_paths(installer)
-    installer.pods_project.build_configurations.each do |config|
-      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
-      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
-    end
     installer.pods_project.targets.each do |target|
-      target.build_configurations.each do |config|
-        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
-        #config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "16.4"
+      if target.name == 'fmt'
+        target.build_configurations.each do |config|
+          # 1. 强制禁用 consteval,回退到运行时检查或旧版编译器行为
+          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
+          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'FMT_USE_CONSTEVAL=0'
+        end
       end
     end
-    __apply_Xcode_12_5_M1_post_install_workaround(installer)
-    # 修复iOS 18编译问题
-    bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
-    def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
-      framework_path = File.join(Dir.pwd, framework_relative_path)
-      command = "#{bitcode_strip_path} #{framework_path} -r -o #{framework_path}"
-      puts "Stripping bitcode: #{command}"
-      system(command)
-    end
-    framework_paths = [
-      #"Pods/LogRocket/LogRocket.xcframework/ios-arm64/LogRocket.framework/LogRocket",
-      "Pods/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework/hermes",
-      "Pods/hermes-engine/destroot/Library/Frameworks/macosx/hermes.framework/Versions/Current/hermes",
-      "Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64/hermes.framework/hermes",
-      "Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64_x86_64-maccatalyst/hermes.framework/hermes"
-    ]
-    framework_paths.each do |framework_relative_path|
-      strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
-    end
-  end
-end
-
-def fix_library_search_paths(installer)
-  def fix_config(config)
-    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
-    if lib_search_paths
-      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
-        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
-        # since the libraries there are only built for x86_64 and i386.
-        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
-        lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
-        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
-          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
-          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
-        end
+    # 2. 针对源码文件进行物理补丁(确保万无一失)
+    fmt_base = File.join(installer.sandbox.root, 'fmt', 'include', 'fmt', 'base.h')
+    if File.exist?(fmt_base)
+      content = File.read(fmt_base)
+      unless content.include?('// Xcode 26 workaround')
+        puts "Patching fmt/base.h for Xcode 26.4 compatibility..."
+        # 将检测到的 consteval 支持强制设为 0
+        patched = content.gsub('#  define FMT_USE_CONSTEVAL 1', "#  define FMT_USE_CONSTEVAL 0 // Xcode 26 workaround")
+        File.chmod(0644, fmt_base)
+        File.write(fmt_base, patched)
       end
     end
+    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
+    react_native_post_install(
+      installer,
+      config[:reactNativePath],
+      :mac_catalyst_enabled => false,
+      # :ccache_enabled => true
+    )
   end
 end
-
-# projects = installer.aggregate_targets
-#   .map{ |t| t.user_project }
-#   .uniq{ |p| p.path }
-#   .push(installer.pods_project)
-
-#   projects.each do |project|
-#     project.build_configurations.each do |config|
-#       fix_config(config)
-#     end
-#     project.native_targets.each do |target|
-#       target.build_configurations.each do |config|
-#         fix_config(config)
-#       end
-#     end
-#     project.save()
-#   end

File diff suppressed because it is too large
+ 1334 - 658
Strides-SPAPP/ios/Strides.xcodeproj/project.pbxproj


+ 0 - 7
Strides-SPAPP/ios/Strides.xcodeproj/project.xcworkspace/contents.xcworkspacedata

@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Workspace
-   version = "1.0">
-   <FileRef
-      location = "self:">
-   </FileRef>
-</Workspace>

+ 0 - 8
Strides-SPAPP/ios/Strides.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IDEDidComputeMac32BitWarning</key>
-	<true/>
-</dict>
-</plist>

+ 95 - 1
Strides-SPAPP/ios/Strides/AppDelegate.swift

@@ -3,8 +3,13 @@ import React
 import React_RCTAppDelegate
 import ReactAppDependencyProvider
 
+import UserNotifications
+import FirebaseCore
+
+import GoogleMaps
+
 @main
-class AppDelegate: UIResponder, UIApplicationDelegate {
+class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate  {
   var window: UIWindow?
 
   var reactNativeDelegate: ReactNativeDelegate?
@@ -14,6 +19,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     _ application: UIApplication,
     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
   ) -> Bool {
+    GMSServices.provideAPIKey("AIzaSyAVzs860l2Iuu1zG80IT1Zu4w7OvbVmJ4g")
+    FirebaseApp.configure()
+    Messaging.messaging().delegate = self
+    
     let delegate = ReactNativeDelegate()
     let factory = RCTReactNativeFactory(delegate: delegate)
     delegate.dependencyProvider = RCTAppDependencyProvider()
@@ -29,8 +38,93 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
       launchOptions: launchOptions
     )
 
+    let center = UNUserNotificationCenter.current()
+    center.delegate = self
+
     return true
   }
+
+  // MARK: - Linking (RN RCTLinkingManager)
+  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
+    return RCTLinkingManager.application(app, open: url, options: options)
+  }
+
+  func application(
+    _ application: UIApplication,
+    continue userActivity: NSUserActivity,
+    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
+  ) -> Bool {
+    return RCTLinkingManager.application(
+      application,
+      continue: userActivity,
+      restorationHandler: restorationHandler
+    )
+  }
+  
+  /*func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
+          guard let fcmToken = fcmToken else { return }
+          // 1. 组装数据字典并发送本地通知
+          let dataDict: [String: String] = ["token": fcmToken]
+          NotificationCenter.default.post(
+              name: Notification.Name("FCMToken"),
+              object: nil,
+              userInfo: dataDict
+          )
+          
+          // 2. 将字符串转换为 Data (UTF-8)
+          let deviceToken = fcmToken.data(using: .utf8)
+          
+          // 3. 将 Token 传递给 React Native Push Notification 插件
+          // 注意:确保已在 Swift 桥接头文件 (Bridging Header) 中导入了 RNCPushNotificationIOS.h
+          RNCPushNotificationIOS.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
+      }*/
+
+  // MARK: - Push Notifications (RNCPushNotificationIOS)
+  // Required to register for notifications
+  func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {
+    RNCPushNotificationIOS.didRegister(notificationSettings)
+  }
+
+  // Required for the register event
+  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
+    // 1. 将 APNs Device Token 关联至 Firebase Messaging
+    Messaging.messaging().apnsToken = deviceToken
+    // 2. 获取当前的 FCM Token 并通过通知中心发送给 RN 端
+    if let fcmToken = Messaging.messaging().fcmToken {
+      let userInfo: [AnyHashable: Any] = ["deviceToken": fcmToken]
+      NotificationCenter.default.post(
+        name: Notification.Name("RemoteNotificationsRegistered"),
+        object: self,
+        userInfo: userInfo
+      )
+    }
+    //RNCPushNotificationIOS.didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
+  }
+
+  // Required for the notification event
+  func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
+    RNCPushNotificationIOS.didReceiveRemoteNotification(userInfo, fetchCompletionHandler: completionHandler)
+  }
+
+  // Required for the registrationError event
+  func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
+    RNCPushNotificationIOS.didFailToRegisterForRemoteNotificationsWithError(error)
+  }
+
+  // iOS 10+ Required for localNotification event
+  func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
+    RNCPushNotificationIOS.didReceive(response)
+    completionHandler()
+  }
+
+  // Called when a notification is delivered to a foreground app
+  func userNotificationCenter(
+    _ center: UNUserNotificationCenter,
+    willPresent notification: UNNotification,
+    withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
+  ) {
+    completionHandler([.alert, .badge, .sound])
+  }
 }
 
 class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {

Some files were not shown because too many files changed in this diff