Hi !
My app was running Firebase ^6.2.0 and I needed to update it to fix issues with CloudMessaging, so I did run the following command:
yarn add @react-native-firebase/analytics@^6.4.0 @react-native-firebase/app@^6.4.0 @react-native-firebase/messaging@^6.4.0 @react-native-firebase/remote-config@^6.4.0
I updated my Pods as well, but when I'm trying to start the app, I get the following error:
2020-05-09 13:29:39.207 [fatal][tid:main] NSInvalidArgumentException: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
2020-05-09 13:29:39.206875+0200 Pletos[61492:17904876] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1ad46096c 0x1ad179028 0x1ad4b9500 0x1ad4c3350 0x1ad347540 0x1ad338ca4 0x102bcc654 0x102ac118c 0x1ad467554 0x1ad330080 0x1ad330c98 0x102af9ae8 0x102afbbd4 0x102afb938 0x103551e1c 0x10355327c 0x10356132c 0x1ad3dbcc8 0x1ad3d6a24 0x1ad3d5f40 0x1b7666534 0x1b1561580 0x10298fbf4 0x1ad254e18)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Apart from that, the only things I changed compared to the last working version are:
@import Firebase; to #import <Firebase.h> in AppDelegate.m
and
if ([FIRApp defaultApp] == nil) {
[FIRApp configure];
}
to
[FIRApp configure];
Because somehow Firebase gets me an error while running the app with the condition.
Click To Expand
#### `package.json`:
{
"name": "pletos",
"version": "0.1.5",
"private": true,
"scripts": {
"android:clean": "(cd android; ./gradlew clean)",
"android:dev": "ENVFILE=.env.dev react-native run-android",
"android:dev:build": "(cd android; ENVFILE=.env.dev ./gradlew bundleRelease)",
"android:prod": "ENVFILE=.env.prod react-native run-android",
"android:prod:build": "(cd android; ENVFILE=.env.prod ./gradlew bundleRelease)",
"lint": "eslint 'src/**/*.ts{,x}'",
"lint:fix": "eslint 'src/**/*.ts{,x}' --fix",
"postinstall": "(cd ios; pod install); exit 0;",
"start": "react-native start",
"test": "jest",
"test:watch": "jest --watchAll",
"ts": "tsc --noEmit"
},
"dependencies": {
"@invertase/react-native-apple-authentication": "^0.1.1",
"@react-native-community/async-storage": "^1.6.2",
"@react-native-community/datetimepicker": "^2.1.0",
"@react-native-community/google-signin": "^3.0.4",
"@react-native-community/masked-view": "^0.1.6",
"@react-native-community/push-notification-ios": "^1.0.6",
"@react-native-firebase/analytics": "^6.4.0",
"@react-native-firebase/app": "^6.4.0",
"@react-native-firebase/messaging": "^6.4.0",
"@react-native-firebase/remote-config": "^6.4.0",
"@react-navigation/bottom-tabs": "^5.0.5",
"@react-navigation/native": "^5.0.5",
"@react-navigation/stack": "^5.0.5",
"@sentry/react-native": "^1.2.1",
"@tryghost/content-api": "^1.3.4",
"axios": "^0.19.0",
"humps": "^2.0.1",
"lodash": "^4.17.15",
"luxon": "^1.21.3",
"react": "16.11.0",
"react-native": "0.61.3",
"react-native-config": "^0.12.0",
"react-native-dark-mode": "^0.2.2",
"react-native-fast-image": "^7.0.2",
"react-native-gesture-handler": "^1.6.0",
"react-native-inappbrowser-reborn": "^3.3.3",
"react-native-rate": "^1.1.10",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.0.0-beta.7",
"react-native-vector-icons": "^6.6.0",
"react-native-webview": "^7.5.1",
"react-redux": "^7.1.3",
"redux": "^4.0.5",
"styled-components": "^5.0.1"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/runtime": "^7.6.3",
"@react-native-community/eslint-config": "^0.0.5",
"@types/jest": "^24.0.21",
"@types/lodash": "^4.14.144",
"@types/react": "^16.9.11",
"@types/react-native": "^0.60.22",
"@types/react-test-renderer": "^16.9.1",
"@types/styled-components": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^2.6.0",
"@typescript-eslint/parser": "^2.6.0",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.4.0",
"husky": "^3.0.9",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-dom": "16.11.0",
"react-native-typescript-transformer": "^1.2.13",
"react-test-renderer": "16.11.0",
"ts-jest": "^24.1.0",
"typescript": "^3.6.4"
},
"jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"preset": "react-native",
"setupFilesAfterEnv": [
"<rootDir>/jest-env.js"
],
"transform": {
"^.+\\.(js)$": "<rootDir>/node_modules/babel-jest",
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"testPathIgnorePatterns": [
"\\.snap$",
"<rootDir>/node_modules/"
],
"cacheDirectory": ".jest/cache"
}
}
#### `firebase.json` for react-native-firebase v6:
I just learned about this file and couldn't find a place where to correctly set it up, so I put this in my root folder.
The Getting started section of the docs should definitely have a paragraph about this.
{
"react-native": {
}
}
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:
# frozen_string_literal: true
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'pletos' do
pod 'FBLazyVector', path: '../node_modules/react-native/Libraries/FBLazyVector'
pod 'FBReactNativeSpec', path: '../node_modules/react-native/Libraries/FBReactNativeSpec'
pod 'RCTRequired', path: '../node_modules/react-native/Libraries/RCTRequired'
pod 'RCTTypeSafety', path: '../node_modules/react-native/Libraries/TypeSafety'
# Pods for pletos
pod 'React', path: '../node_modules/react-native/'
pod 'React-Core', path: '../node_modules/react-native/'
pod 'React-CoreModules', path: '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', path: '../node_modules/react-native/'
pod 'React-RCTActionSheet', path: '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', path: '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', path: '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', path: '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', path: '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', path: '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', path: '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', path: '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', path: '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', path: '../node_modules/react-native/'
pod 'React-cxxreact', path: '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', path: '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', path: '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', path: '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', path: '../node_modules/react-native/ReactCommon'
pod 'ReactCommon/turbomodule/core', path: '../node_modules/react-native/ReactCommon'
pod 'Yoga', path: '../node_modules/react-native/ReactCommon/yoga'
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 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
use_native_modules!
end
#### `AppDelegate.m`:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <Firebase.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"pletos"
initialProperties:nil];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[application registerForRemoteNotifications];
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
return [RNGoogleSignin application:application openURL:url options:options];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
Click To Expand
**`react-native info` output:**
System:
OS: macOS 10.15.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 1.12 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.20.1 - /var/folders/z6/d49mb72j6fq31yvh24xbnrww0000gn/T/yarn--1589024660333-0.5759835860767231/node
Yarn: 1.22.4 - /var/folders/z6/d49mb72j6fq31yvh24xbnrww0000gn/T/yarn--1589024660333-0.5759835860767231/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v10.20.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
npmPackages:
react: 16.11.0 => 16.11.0
react-native: 0.61.3 => 0.61.3
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [ ] Android
- [x] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- `6.7.1`
- **`Firebase` module(s) you're using that has the issue:**
- All I guess ?
- **Are you using `TypeScript`?**
- `Y` & `^3.6.4`
React Native Firebase and Invertase on Twitter for updates on the library.Any time you do an upgrade and receive an unexpected result (like, crashing when obviously the project has a large test suite, and others are using it) you should suspect a local issue, and you should definitely suspect some corrupt local state
For that: npx react-native-clean-project
Then try again
Seems like it's fixed. Thank you.
May I insist that the firebase.json should be documented in the Getting Started guide ?
Well, no one can insist on anything in open source, but you can certainly make PRs to the docs, there is an edit button at the top of each page, and unfortunately as maintainers we don't really have perspective anymore, so the PRs from users on getting started have more value than what we can do at this point
@mikehardy do you know if this package supports the new build system, or only legacy right now?
@mikehardy do you know if this package supports the new build system, or only legacy right now?
It supports both
Any time you do an upgrade and receive an unexpected result (like, crashing when obviously the project has a large test suite, and others are using it) you should suspect a local issue, and you should definitely suspect some corrupt local state
For that:
npx react-native-clean-projectThen try again
after doing this
i can't start run-ios and run-android too,
error Unrecognized command "run-ios".
With apologies - this sounds like some very basic react-native things going terribly wrong.
Are you sure you ran yarn (or npm i) after cleaning your project?
This module definitely works. You can see a clean build by running this https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh