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

iOS Build Error: Include of a non-modular header inside framework module 'BugsnagReactNative.Bugsnag' #466

Closed fbartho closed 4 years ago

fbartho commented 4 years ago

Description

We have code that is importing <BugsnagReactNative/BugsnagReactNative.h> from this, we were calling [BugsnagReactNative start]; inside of a section of code (called from appDidFinishLaunching)

Issue

Screenshot of error

This wasn't an issue, until we upgraded one of our cocoapods dependencies (ZendeskChat) to their V2.

I'm a maintainer of react-native-zendesk-chat and I'm trying to upgrade it.

That updated pod spec has these lines: ```ruby Pod::Spec.new do |s| s.name = "RNZendeskChat" s.version = package['version'] s.summary = package['description'] s.license = package['license'] s.authors = package['author'] s.homepage = package['homepage'] s.platform = :ios, "10" s.source = { :git => "https://github.com/taskrabbit/react-native-zendesk-chat.git", :tag => "v#{s.version}" } s.source_files = "ios/*.{h,m}" s.static_framework = true s.framework = 'Foundation' s.framework = 'UIKit' s.dependency 'React' s.dependency 'ZendeskChatSDK' end ```

Environment

Library versions:

$ yarn list --pattern "(react-native|bugsnag)" # we don't have code-push
yarn list v1.22.4
├─ @expo/react-native-action-sheet@3.6.0
├─ @react-native-community/cli-debugger-ui@4.9.0
├─ @react-native-community/cli-platform-android@4.9.0
├─ @react-native-community/cli-platform-ios@4.9.0
├─ @react-native-community/cli-server-api@4.9.0
├─ @react-native-community/cli-tools@4.9.0
├─ @react-native-community/cli-types@4.9.0
├─ @react-native-community/cli@4.9.0
├─ @react-native-community/masked-view@0.1.9
├─ @react-native-community/netinfo@5.6.2
├─ @react-native-community/slider@2.0.9
├─ @stream-io/react-native-simple-markdown@1.1.2
├─ @types/react-native-fbsdk@1.0.0
├─ @types/react-native-permissions@2.0.0
├─ @types/react-native@0.62.12
├─ bugsnag-react-native@2.23.6
├─ css-to-react-native@2.3.2
├─ eslint-plugin-react-native-globals@0.1.2
├─ eslint-plugin-react-native@3.8.1
├─ jest-react-native@18.0.0
├─ metro-react-native-babel-preset@0.58.0
├─ metro-react-native-babel-transformer@0.58.0
├─ modal-react-native-web@0.2.0
├─ react-native-actionsheet@2.4.2
├─ react-native-config@0.12.0
├─ react-native-country-picker-modal@1.10.0
├─ react-native-document-picker@3.2.4
├─ react-native-fbsdk@1.1.2
├─ react-native-flipper@0.34.0
├─ react-native-gesture-handler@1.6.1
├─ react-native-image-crop-picker@0.28.0
├─ react-native-image-pan-zoom@2.1.11
├─ react-native-image-picker@0.28.1
├─ react-native-image-zoom-viewer@2.2.27
├─ react-native-iphone-x-helper@1.2.1
├─ react-native-keychain@4.0.5
├─ react-native-kochava-tracker@1.3.1
├─ react-native-permissions@2.0.10
├─ react-native-rate@1.2.1
├─ react-native-reanimated@1.8.0
├─ react-native-safe-area-context@0.7.3
├─ react-native-safe-area-view@0.14.9
├─ react-native-schemes-manager@2.0.0
├─ react-native-screens@2.4.0
├─ react-native-tab-view@2.13.0
├─ react-native-typescript-transformer@1.2.13
├─ react-native-webview@7.6.0
├─ react-native-zendesk-chat@0.3.1
├─ react-native@0.62.2
├─ reactotron-react-native@5.0.0
├─ stream-chat-react-native-core@0.10.2
│  └─ metro-react-native-babel-preset@0.53.1
├─ stream-chat-react-native@0.10.2
└─ urbanairship-react-native@6.0.1

Interesting Podfile details

platform :ios, '11.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

# …snipped for brevity

    use_native_modules!
    use_frameworks!

Also, we have flipper disabled!

Example code snippet

Code is just:

import <BugsnagReactNative/BugsnagReactNative.h>

// in appDidFinishLaunching:
[BugsnagReactNative start];
Error messages: ``` Showing All Messages /Users/fbarthelemy/Code/TRClient5/node_modules/bugsnag-react-native/cocoa/vendor/bugsnag-cocoa/Source/Bugsnag.h:30:9: Include of non-modular header inside framework module 'BugsnagReactNative.Bugsnag': '../node_modules/bugsnag-react-native/cocoa/vendor/bugsnag-cocoa/Source/BugsnagPlugin.h' /Users/fbarthelemy/Code/TRClient5/ios/TRClient/AppDelegate.m:23:9: Could not build module 'BugsnagReactNative' ``` Error is in Bugsnag.h: ![Screenshot of the error in Bugsnag.h](https://user-images.githubusercontent.com/209712/86411817-83197a00-bc72-11ea-94fd-5b28afa7faf3.png)

Potentially related ticket: #442

fbartho commented 4 years ago

Workaround is to allow non-modular headers at a Project level (temporarily -- as this is considered a problem in one of your libraries -- and probably a sign that other build weirdness will happen)

steve-nester-uk commented 4 years ago

Thanks for raising @fbartho, I agree that the temporary solution is not ideal. We are going to look into a better fix by moving the import into the .m file (tbc).

steve-nester-uk commented 4 years ago

@fbartho, I've just learned that a patch was applied in 2.23.7 to the missing BugsnagPlugin.h header to the podspec file. Please can you upgrade to 2.23.7 and confirm if this fixes the issue?

fbartho commented 4 years ago

@steve-nester-uk -- I tested against 2.23.9, and there's a new error:

image

Trying 2.23.7 now.

fbartho commented 4 years ago

Problem is resolved with exactly 2.23.7 -- Do you need me to file a different Github Issue about 2.23.9 or is this sufficient?

xljones commented 4 years ago

Hey @fbartho, thanks for letting us know. We're already aware of this issue (moving to v2.23.8 or v2.23.9) you can track it here: https://github.com/bugsnag/bugsnag-react-native/issues/462. When making this upgrade, what steps did you take to produce the error? We've not reproduced this error, so are unable to test fixes against it.