react-native-community / upgrade-support

A central community-backed place to request and give help when upgrading your app.
MIT License
251 stars 2 forks source link

Issue upgrading to 0.74.2 #280

Closed connorpmullins closed 2 weeks ago

connorpmullins commented 2 weeks ago

Environment

System: OS: macOS 14.1.2 CPU: (10) arm64 Apple M1 Pro Memory: 78.89 MB / 32.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.15.0 path: ~/.nvm/versions/node/v18.15.0/bin/node Yarn: version: 1.22.21 path: ~/.nvm/versions/node/v18.15.0/bin/yarn npm: version: 9.5.0 path: ~/.nvm/versions/node/v18.15.0/bin/npm Watchman: version: 2023.12.04.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.14.3 path: /Users/connormullins/.rvm/gems/ruby-2.7.5/bin/pod SDKs: iOS SDK: Platforms:

Things I’ve done to figure out my issue

Upgrading version

0.74.2

Description

Disclaimer I may be un-helpable. I realize it's entirely unlikely that there's a significant bug with a stable version of react native that only I've encountered - so I probably have some weird configuration issue. I don't know where else to go with this, however.

I am currently seeing the below issue:

image

Here is my Podfile - the commented-out code is what I've removed during the upgrade and debugging process.

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")

# 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

ENV['RCT_NEW_ARCH_ENABLED'] = "1"

# platform :ios, '15.0'
platform :ios, min_ios_version_supported
prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

# require 'json'
# podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

# Custom Mapbox stuff
$RNMapboxMapsCustomPods = [['Navionics']]
$RNMapboxMapsVersion = '= 11.0.0'
# $RNMBX_USE_FRAMEWORKS = true

# def append_header_search_path(target, path)
#   target.build_configurations.each do |config|
#       # Note that there's a space character after `$(inherited)`.
#       config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) "
#       config.build_settings["HEADER_SEARCH_PATHS"] << path
#   end
# end

target 'omniafishingrn' do
  use_expo_modules!
  config = use_native_modules!

  $RNFirebaseAsStaticFramework = true

  # Uses modular headers
  pod 'FirebaseCore', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true

  # Custom Mapbox Navionics stuff
  pod 'Navionics', :path => './Navionics.podspec'

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => true,
    :app_path => "#{Pod::Config.instance.installation_root}/..",
  )

  pre_install do |installer|
# @generated begin @react-native-mapbox-gl/maps-pre_installer - expo prebuild (DO NOT MODIFY) sync-5a7ed0a20d5aff2d61639bc5bb4fd5551233d57c
    $RNMapboxMaps.pre_install(installer)
# @generated end @react-native-mapbox-gl/maps-pre_installer
  end

  post_install do |installer|
    $RNMapboxMaps.post_install(installer)
    # 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
    )

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    # installer.target_installation_results.pod_target_installation_results
    #   .each do |pod_name, target_installation_result|
    #   target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
    #     resource_bundle_target.build_configurations.each do |config|
    #       config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
    #     end
    #   end
    # end

    installer.pods_project.targets.each do |target|
      # if ["react-native-webview", "react-native-pager-view", "RNScreens", "RNSVG"].any? { |t| t == target.name }
      #   append_header_search_path(target, "${PODS_ROOT}/../../node_modules/react-native/ReactCommon")
      # end
      target.build_configurations.each do |config|
        # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
        # config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.4'
      end
      # Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
      # Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
      # if (target.name&.eql?('FBReactNativeSpec'))
      #   target.build_phases.each do |build_phase|
      #     if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
      #       target.build_phases.move(build_phase, 0)
      #     end
      #   end
      # end
    end
  end

  # use_frameworks! :linkage => :static
  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end

end

target 'RichNotificationExtension' do
  # use_frameworks! :linkage => :static
  pod 'Iterable-iOS-AppExtensions'
end

And since the error references my AppDelegate.mm file, I'll include it here:

#import "AppDelegate.h"
#import <Firebase.h>

#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <IntercomModule.h>
#import "IterableSDK-Swift.h"
#import <RNAppsFlyer.h>
#import <AppsFlyerLib/AppsFlyerLib.h>
#import "ExpoModulesCore-Swift.h" // https://github.com/expo/expo/issues/17705#issuecomment-1196251146
#import "app-Swift.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  [FIRApp configure];
  self.moduleName = @"main";
  // 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 = @{};

  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;

  [IntercomModule initialize:@"KEY" withAppId:@"ID"];

   [NavionicsInit initNavionics];

  signal(SIGPIPE, SIG_IGN); // prevents a crash for rnmapbox

  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
}

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  // If you'd like to export some custom RCTBridgeModules, add them here!
  return @[];
}

#pragma mark - UNUserNotificationCenterDelegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
    completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionBanner | UNNotificationPresentationOptionList | UNNotificationPresentationOptionSound);
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
    [IterableAppIntegration userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    // notify AppsFlyerLib
    [[AppsFlyerLib shared] registerUninstall:deviceToken];
    [IterableAPI registerToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    [IterableAppIntegration application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

// Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {

  //  Supports AppsFlyer Universal Links
  [[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler];

  // Handles Iterable Universal Iterable
   return [RCTLinkingManager application:application
                    continueUserActivity:userActivity
                      restorationHandler:restorationHandler];
}

// Linking API
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  // #if defined(EX_DEV_LAUNCHER_ENABLED)
  // if ([EXDevLauncherController.sharedInstance onDeepLink:url options:options]) {
  //   return true;
  // }
  // #endif

  //  Supports AppsFlyer Deeplinks
  [[AppsFlyerAttribution shared] handleOpenUrl:url options:options];

  // Handles Iterable Universal Iterable
  [RCTLinkingManager application:application openURL:url options:options];

  return YES;
}

// Open URI-scheme for iOS 8 and below
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
  [[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:annotation];
  return YES;
}

@end

#if defined(EX_DEV_LAUNCHER_ENABLED)
@implementation AppDelegate (EXDevLauncherControllerDelegate)

- (void)devLauncherController:(EXDevLauncherController *)developmentClientController
    didStartWithSuccess:(BOOL)success
{
  developmentClientController.appBridge = [self initializeReactNativeApp:[EXDevLauncherController.sharedInstance getLaunchOptions]];
}

@end
#endif

Additional (potentially) helpful info: This project is using Expo's bare workflow and there are artifacts from Expo's bare workflow upgrade docs throughout my ios project.

I'm sure this is not a surprise to anyone, but my largest continuing struggle with react-native upgrades is managing the difference in native configuration suggestions between react-native, expo, and the various packages we depend on.

Reproducible demo

I think that if I start a clean project and upgrade, this issue will not exist. I think if I managed to re-create the issue in a new project, then I would also know how to fix it for myself. I'm asking for help, I don't think I'm reporting a bug.

connorpmullins commented 2 weeks ago

@github-actions bot - I did specify my upgrading version!

connorpmullins commented 2 weeks ago

FIXED!

I increased the version diff in the React Native Upgrade helper from 0.73.6 -> 0.74.2 to 0.70.13 -> 0.74.2 in an attempt to broaden my search of what could have gone wrong.

I saw that CLANG_CXX_LANGUAGE_STANDARD was modified from "c++17" to "c++20". I must have missed that change during a prior upgrade, but it didn't cause a breaking issue until this release.

Here are some key words so anyone with similar bugs can find this issue: fnv1a, hash_combine, RawProps, too many errors