bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
369 stars 121 forks source link

RCTGetReactNativeVersion from Bugsnag cause build failures after adding use_modular_headers! to Podfile on React Native 0.59.10 #442

Closed taylorkline closed 4 years ago

taylorkline commented 4 years ago

Issue

The iOS build fails after adding use_modular_headers! to ios/Podfile with errors from BugsnagReactNative:

error:  /Users/x/Desktop/z/z-mobile/node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.m:362:40: implicit declaration of function 'RCTGetReactNativeVersion' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

            NSDictionary *versionMap = RCTGetReactNativeVersion();
                ^

error:  /Users/x/Desktop/z/z-mobile/node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.m:362:40: declaration of 'RCTGetReactNativeVersion' must be imported from module 'React.React.RCTVersion' before it is required

In module 'React' imported from /Users/x/Desktop/z/z-mobile/node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.h:3:
                                       ^

warn:  /Users/x/Desktop/z/z-mobile/node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.m:362:40: this function declaration is not a prototype [-Wstrict-prototypes]

            NSDictionary *versionMap = RCTGetReactNativeVersion();
                     ^

error:  /Users/x/Desktop/z/z-mobile/node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.m:362:40: conflicting types for 'RCTGetReactNativeVersion'

In module 'React' imported from /Users/x/Desktop/z/z-mobile/node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.h:3:

Environment

Library versions:

$ yarn list react-native bugsnag-react-native react-native-code-push
yarn list v1.19.1
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ bugsnag-react-native@2.23.5
└─ react-native@0.59.10

Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

use_modular_headers!

target 'ZMobile' do
  rn_path = '../node_modules/react-native'

  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  # React Native third party dependencies podspecs
  pod 'DoubleConversion', :modular_headers => false, :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :modular_headers => false, :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :modular_headers => false, :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  pod 'BugsnagReactNative', :path => '../node_modules/bugsnag-react-native'

  pod 'z-react-native-payments', :path => '../node_modules/z-react-native-payments'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end

    targets_to_ignore = %w(React yoga)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end
  end
end
mattdyoung commented 4 years ago

Hi @taylorkline

Thanks for the report. By using a Podfile similar to what you provided I've now reproduced the issue which does look to be a bug in the library.

We'll take a look at what's involved to fix and provide an update soon.

taylorkline commented 4 years ago

Thanks so much for the prompt confirmation.

abigailbramble commented 4 years ago

@taylorkline a fix for this has now been released in v2.23.6

taylorkline commented 4 years ago

The fix works. Thanks!