question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS: custom module crashes on react-native 0.49+

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bpeyrouBDHIScommented, Mar 8, 2018

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

1reaction
adrianfalleirocommented, Jan 5, 2018

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native application crashing in device at launch time ...
I have created one react native app and successfully run in simulator. But it is crashing at launch time in device.
Read more >
ReactNative App Crashes when Deployed to TestFlight
When I download the app from TestFlight on the same device, the app crashes immediately upon opening the app.
Read more >
mqt_native_modules with React-Native app on Release APK
Issue solved ! I have fixed my problem by downgrading React-Native from 0.51.0 to 0.49.5, and I have no more crash. Noémie Kerroux...
Read more >
React Native (unmaintained) - Countly
If the crash occurred, SDK sends the crash data to Countly and shows an alert box having the crash message and a Restart...
Read more >
Get Started with React Native - Visual Studio App Center
The App Center SDK uses a modular architecture so you can use any or all of ... Select the appropriate OS (Android or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found