Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: custom module crashes on react-native 0.49+ #17430

Closed
af-fess opened this issue Jan 3, 2018 · 11 comments
Closed

iOS: custom module crashes on react-native 0.49+ #17430

af-fess opened this issue Jan 3, 2018 · 11 comments
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@af-fess
Copy link

af-fess commented Jan 3, 2018

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

OS: macOS High Sierra 10.13.1
Node: 7.2.1
Yarn: Not Found
npm: 4.6.1
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 2.2 AI-145.3537739

Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.51.0 => 0.51.0

Steps to Reproduce

We try to integrate AppsFlyer module, it works great on react-native <= 0.48 but crashes on 0.49+ (in my example - latest 0.51.0)

  1. Create empty project with $ react-native init Demo_4_10

  2. $ cd Demo_4_10/

  3. Install AppsFlyer plugin by running $ npm install react-native-appsflyer --save

  4. run $ cd ios/

  5. $ pod init - it will create Podfile

  6. Add to Podfile following row: pod 'react-native-appsflyer',:path => '../node_modules/react-native-appsflyer' so it will look like:

     ```
     target 'Demo_4_10' do
     pod 'react-native-appsflyer',:path => '../node_modules/react-native-appsflyer
     end
     ```
    
  7. run $ pod install

    Output:

    	Analyzing dependencies
    	Fetching podspec for `react-native-appsflyer` from `../node_modules/react-native-appsflyer`
    	Downloading dependencies
    	Installing AppsFlyerFramework (4.8.1)
    	Installing React (0.11.0)
    	Installing react-native-appsflyer (1.1.9)
    	Generating Pods project
    	Integrating client project
    
  8. Open in Xcode new crested Demo_4_10.xcworkspace and run the project on Device.

Expected Behavior

The app should run without any error or crash. Keep in mind we even do not load AppsFlyer module in Javascript

Actual Behavior

The crash happens in react-native/ReactCommon/cxxreact/ModuleRegistry.cpp row 116:

std::vector<MethodDescriptor> methods = module->getMethods();

The app output is so far till crash happens:

2018-01-03 09:50:49.986 [info][tid:main][RCTCxxBridge.mm:213] Initializing <RCTCxxBridge: 0x17d29740> (parent: <RCTBridge: 0x17d400f0>, executor: (null))
2018-01-03 09:50:49.990338+0200 Demo_4_10[552:243335] Initializing <RCTCxxBridge: 0x17d29740> (parent: <RCTBridge: 0x17d400f0>, executor: (null))
2018-01-03 09:50:50.061 [warn][tid:main][RCTBridge.m:121] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-01-03 09:50:50.060873+0200 Demo_4_10[552:243335] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-01-03 09:50:50.197 [info][tid:main][RCTRootView.m:301] Running application Demo_4_10 ({
    initialProps =     {
    };
    rootTag = 1;
})
2018-01-03 09:50:50.197195+0200 Demo_4_10[552:243335] Running application Demo_4_10 ({
    initialProps =     {
    };
    rootTag = 1;
})
2018-01-03 09:50:52.485 [info][tid:main][RCTCxxBridge.mm:905] Invalidating <RCTCxxBridge: 0x17d29740> (parent: <RCTBridge: 0x17d400f0>, executor: RCTWebSocketExecutor)
2018-01-03 09:50:52.485292+0200 Demo_4_10[552:243335] Invalidating <RCTCxxBridge: 0x17d29740> (parent: <RCTBridge: 0x17d400f0>, executor: RCTWebSocketExecutor)
2018-01-03 09:50:52.487 [info][tid:main][RCTCxxBridge.mm:213] Initializing <RCTCxxBridge: 0x17e6bf10> (parent: <RCTBridge: 0x17d400f0>, executor: RCTWebSocketExecutor)
2018-01-03 09:50:52.487328+0200 Demo_4_10[552:243335] Initializing <RCTCxxBridge: 0x17e6bf10> (parent: <RCTBridge: 0x17d400f0>, executor: RCTWebSocketExecutor)

The crash print screen:

screen shot 2018-01-03 at 9 54 59 am

Crash frequency: Always


If I'll manually paste both files RNAppsFlyer.m and RNAppsFlyer.h into the project - everything will work, however from pods - it fails.

The second problem:

The manual way to integrate the module also fails with compilation error:

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_AppsFlyerTracker", referenced from:
objc-class-ref in libRNAppsFlyer.a(RNAppsFlyer.o)

I found that new generated libRNAppsFlyer.a file size 2Kb less then for working version 0.48.

Full Stack Trace:


Showing All Messages
Ld /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/Demo_4_9.app/Demo_4_9 normal armv7
    cd /Users/maxim/Appsflyer/projects/react-native-appsflyer/demos/Demo_4_9/ios
    export IPHONEOS_DEPLOYMENT_TARGET=10.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -L/Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos -F/Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos -filelist /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Intermediates.noindex/Demo_4_9.build/Debug-iphoneos/Demo_4_9.build/Objects-normal/armv7/Demo_4_9.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -miphoneos-version-min=10.0 -Xlinker -object_path_lto -Xlinker /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Intermediates.noindex/Demo_4_9.build/Debug-iphoneos/Demo_4_9.build/Objects-normal/armv7/Demo_4_9_lto.o -Xlinker -no_deduplicate -fembed-bitcode-marker -fobjc-arc -fobjc-link-runtime -ObjC -ObjC -lc++ /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRNAppsFlyer.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTBlob.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTAnimation.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libReact.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTAnimation.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTActionSheet.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTGeolocation.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTImage.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTLinking.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTNetwork.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTSettings.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTText.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTVibration.a /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/libRCTWebSocket.a -lPods-Demo_4_9 -Xlinker -dependency_info -Xlinker /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Intermediates.noindex/Demo_4_9.build/Debug-iphoneos/Demo_4_9.build/Objects-normal/armv7/Demo_4_9_dependency_info.dat -o /Users/maxim/Library/Developer/Xcode/DerivedData/Demo_4_9-faoikaedeqmvmefyordscfynjfsd/Build/Products/Debug-iphoneos/Demo_4_9.app/Demo_4_9

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_AppsFlyerTracker", referenced from:
      objc-class-ref in libRNAppsFlyer.a(RNAppsFlyer.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reproducible Demo

Download Demo

@dioxide
Copy link

dioxide commented Jan 4, 2018

+1, same problem, i don't know why is React (0.11.0) in Pods ?

@adrianfalleiro
Copy link

@af-fess I had a look at your linked project. I think you might be missing some React dependencies in your Podfile. I believe that the React pod has been deprecated and the podspecs are now distributed as part of the NPM package.

I was able to replicate your issue with the supplied project in the iOS simulator and it stopped ocurring when I updated (and ran pod install) the Podfile to the following below.

target 'Demo_4_10' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Your 'node_modules' directory is probably in the root of your project,
  # but if not, adjust the `:path` accordingly
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'GLog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

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

end

You may want to add or remove some of the subspecs based on the components you require for your project.

Have a look at the documentation for using CocoaPods with React Native for more info: http://facebook.github.io/react-native/docs/0.51/integration-with-existing-apps.html#configuring-cocoapods-dependencies

Also worth looking at is the Podfile for the react-native-maps example project https://github.com/react-community/react-native-maps/blob/master/example/ios/Podfile

@af-fess
Copy link
Author

af-fess commented Jan 5, 2018

@adrianfalleiro thank you for details, Ill check it out. Weird that for 0.48 everything works fine.

@btoueg
Copy link

btoueg commented Feb 23, 2018

I have the exact same issue here. Here is my stacktrace:

image 21

I'm using RN 0.53.0 and my Podfile is the following:

platform :ios, '8.0'

ENV['COCOAPODS_DISABLE_STATS'] = "true"

def install_pods
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'GLog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # To use CocoaPods with React Native, you need to add this specific Yoga spec as well
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTPushNotification',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  pod 'AWSCore', '~> 2.3.6'
  pod 'AWSS3', '~> 2.3.6'
  pod 'Firebase/Messaging', '~> 4.8.2'
  pod 'Firebase/Core', '~> 4.8.2'
  pod 'Firebase/Crash', '~> 4.8.2'
  pod 'GoogleMaps', '2.5.0'
  pod 'FBSDKCoreKit', '~> 4.23'
  pod 'FBSDKShareKit', '~> 4.23'
  pod 'FBSDKLoginKit', '~> 4.23'
  
  pod 'BVLinearGradient', path: '../node_modules/react-native-linear-gradient'
  pod 'RNFS', path: '../node_modules/react-native-fs'
  pod 'RNVectorIcons', path: '../node_modules/react-native-vector-icons'
  pod 'react-native-blur', path: '../node_modules/react-native-blur'
  pod 'react-native-camera', path: '../node_modules/react-native-camera'
  pod 'react-native-fbsdk', path: '../node_modules/react-native-fbsdk/ios'
  pod 'react-native-fcm', path: '../node_modules/react-native-fcm'
  pod 'react-native-image-picker', path: '../node_modules/react-native-image-picker'
  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-orientation', path: '../node_modules/react-native-orientation'
  pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support Google Maps on iOS
  pod 'react-native-video', path: '../node_modules/react-native-video'
  pod 'SentryReactNative', path: '../node_modules/react-native-sentry'
end

target "MyProject" do
  install_pods
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Funnily enough, the issue arise only on one of our 4 dev machines.

I haven't found a work-around yet, otherwise than banning development on that machine 😢

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon. labels Feb 24, 2018
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 24, 2018
@joshjhargreaves
Copy link
Contributor

joshjhargreaves commented Feb 28, 2018

@btoueg is reporting that this issue is still present in 0.53+, so re-opening & closing the issue that he created, in favour of keeping this issue open until we figure out what the issue is.

@joshjhargreaves joshjhargreaves added the Platform: iOS iOS applications. label Feb 28, 2018
@joshjhargreaves
Copy link
Contributor

@btoueg would you mind providing an updated example project?

@joshjhargreaves
Copy link
Contributor

@af-fess did you fix your issue?

@joshjhargreaves joshjhargreaves removed the Ran Commands One of our bots successfully processed a command. label Feb 28, 2018
@bpeyrouBDHIS
Copy link

Hi everyone,

We tried to have a working example of the problem that we saw with @btoueg.
Except that starting with a fresh project didn't bring the problem that we were experiencing on the updated project.

After some time, we tried uninstalling and cleaning the cache of Xcode. We deleted the project and cloned it from GitHub, after that no more problem, the project compiled and ran. So it may not work for everyone but it seems that this method worked for us. Hope it helps.

Cheers

@stale
Copy link

stale bot commented Jun 6, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 6, 2018
@stale
Copy link

stale bot commented Jul 6, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jul 6, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

7 participants