iOS: custom module crashes on react-native 0.49+
See original GitHub issueIs 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)
-
Create empty project with
$ react-native init Demo_4_10
-
$ cd Demo_4_10/
-
Install AppsFlyer plugin by running
$ npm install react-native-appsflyer --save
-
run
$ cd ios/
-
$ pod init
- it will createPodfile
-
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 ```
-
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
-
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:
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:
- Created 6 years ago
- Reactions:1
- Comments:11 (3 by maintainers)
Top GitHub Comments
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
@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.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