[docs][ios] Remove react native link support due to issues and update documentation

This commit is contained in:
Chris Bianca 2017-06-13 16:18:12 +01:00
parent d68703da64
commit 280145da9f
8 changed files with 42 additions and 201 deletions

View File

@ -1,55 +0,0 @@
#!/bin/sh
ios_dir=`pwd`/ios
if [ -d ios_dir ]
then
exit 0
fi
podfile="$ios_dir/Podfile"
template=`pwd`/node_modules/react-native-firebase/ios/Podfile.template
template_content=`cat $template`
project_name=$(node -pe "require('./package.json').name")
echo "Checking Podfile in iOS project $project_name ($podfile)"
if [ -f $podfile ]
then
echo ""
echo "Found an existing Podfile, Do you want to override it? [N/y]"
read generate_env_file
if [ "$generate_env_file" != "y" ]
then
echo "Add the following pods":
echo ""
echo ""
cat $template
echo ""
echo ""
echo "and run 'pod install' to install RNFirebase for iOS"
exit 0
fi
rm -f $podfile
rm -f "$podfile.lock"
fi
echo "Adding Podfile to iOS project"
touch ios/Podfile
cat >ios/Podfile <<EOL
target '${project_name}' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for '${project_name}'
end
# RNFirebase
${template_content}
EOL
echo "Installing Pods"
pod install --project-directory=ios

View File

@ -1,15 +0,0 @@
#!/bin/sh
## https://github.com/auth0/react-native-lock/blob/master/bin/prepare.sh
echo "Preparing to link react-native-firebase for iOS"
echo "Checking CocoaPods..."
has_cocoapods=`which pod >/dev/null 2>&1`
if [ -z "$has_cocoapods" ]
then
echo "CocoaPods already installed"
else
echo "Installing CocoaPods..."
gem install cocoapods
fi

View File

@ -1,7 +1,7 @@
- Getting started
- [Initial setup](/initial-setup)
- [Installation - iOS](/installation-ios)
- [Installation - Android](/installation-android)
- [Firebase Setup](/firebase-setup.md)
- [Usage](/usage)
- Contributing

View File

@ -1,20 +0,0 @@
# Firebase Setup
The RNFirebase library is intended on making it easy to work with [Firebase](https://firebase.google.com/) and provides a small native shim to the Firebase native code.
To add Firebase to your project, make sure to create a project in the [Firebase console](https://firebase.google.com/console)
![Create a new project](https://i.imgur.com/KbbamwD.png)
Each platform uses a different setup method after creating the project.
## iOS
For iOS, ensure you've followed the instructions provided by Firebase; adding your [GoogleService-Info.plist](https://github.com/invertase/react-native-firebase/blob/master/tests/ios/GoogleService-Info.plist)
file to the project, and [configuring your AppDelegate](https://github.com/invertase/react-native-firebase/blob/master/tests/ios/ReactNativeFirebaseDemo/AppDelegate.m#L20).
## Android
For Android, ensure you've followed the instructions provided by Firebase; adding your [google-services.json](https://github.com/invertase/react-native-firebase/blob/master/tests/android/app/google-services.json)
file to the project, installing the [google-services](https://github.com/invertase/react-native-firebase/blob/master/tests/android/build.gradle#L9)
plugin and applying **at the end** of your [`build.gradle`](https://github.com/invertase/react-native-firebase/blob/master/tests/android/app/build.gradle#L144).

21
docs/initial-setup.md Normal file
View File

@ -0,0 +1,21 @@
# Install the library
`npm install --save react-native-firebase`
# Initial Setup
The RNFirebase library is intended on making it easy to work with [Firebase](https://firebase.google.com/) and provides a small native shim to the Firebase native code.
To add Firebase to your project, make sure to create a project in the [Firebase console](https://firebase.google.com/console)
![Create a new project](https://i.imgur.com/KbbamwD.png)
Each platform uses a different setup method after creating the project.
## iOS
For iOS, follow the instructions [here](/installation-ios).
## Android
For Android, follow the instructions [here](/installation-android).

View File

@ -1,84 +1,27 @@
# iOS Installation
## 1) Setup google-services.plist and dependencies
Setup the `google-services.plist` file and Firebase ios frameworks first; check out the relevant Firebase docs [here](https://firebase.google.com/docs/ios/setup#frameworks).
## 1) Setup `GoogleService-Info.plist`
Setup the `GoogleService-Info.plist` file by following the instructions and adding it to the root of your project at `ios/[YOUR APP NAME]/GoogleService-Info.plist` [here](https://firebase.google.com/docs/ios/setup#add_firebase_to_your_app).
### 1.1) Initialisation
Make sure you've added the following to the top of your `ios/[YOUR APP NAME]]/AppDelegate.m` file:
`#import <Firebase.h>`
and this to the `didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method:
and this to the `didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method before the `return` statement:
`[FIRApp configure];`
## 2) Link RNFirebase
There are multiple ways to install RNFirebase depending on how your project is currently setup:
Unfortunately, due to the fact that Firebase is much easier to setup using Cocoapods, `react-native link` is not recommended as it is not customisable enough for our needs and we have had numerous problems reported.
### 2.1) You already use Cocoapods and have React Native installed as a pod
### 2.0) If you don't already have Cocoapods set up
Follow the instructions to install Cocoapods and create your Podfile [here](https://firebase.google.com/docs/ios/setup#add_the_sdk).
### 2.1) Add the required pods
Simply add the following to your `Podfile`:
```ruby
# Required by RNFirebase - you should already have some of these from step 1.
pod 'Firebase/Auth'
pod 'Firebase/Analytics'
pod 'Firebase/AppIndexing'
pod 'Firebase/Core'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
```
### 2.2) You're not using Cocoapods or don't have React Native installed as a pod (Automatic install)
React native ships with a `link` command that can be used to link the projects together, which can help automate the process of linking our package environments.
```bash
react-native link react-native-firebase
```
#### cocoapods
We've automated the process of setting up with cocoapods. This will happen automatically upon linking the package with `react-native-cli`.
Update the newly installed pods once the linking is done:
```bash
cd ios && pod update --verbose
```
**NOTE: You need to use the `ios/[YOUR APP NAME].xcworkspace` instead of the `ios/[YOUR APP NAME].xcproj` file from now on.**
### 2.3) You're not using Cocoapods or don't have React Native installed as a pod (Manual install)
If you prefer not to use `react-native link`, we can manually link the package together with the following steps, after `npm install`:
**A.** In XCode, right click on `Libraries` and find the `Add Files to [project name]`.
![Firebase.xcodeproj add to files](https://cloud.githubusercontent.com/assets/5347038/24249673/0fccdbec-0fcc-11e7-83eb-c058f8898525.png)
**B.** Add the `node_modules/react-native-firebase/ios/Firebase.xcodeproj`
![Firebase.xcodeproj in Libraries listing](https://cloud.githubusercontent.com/assets/21329063/24249440/9494e19c-0fd3-11e7-95c0-c2baa85092e8.png)
**C.** Ensure that the `Build Settings` of the `RNFirebase.xcodeproj` project is ticked to _All_ and it's `Header Search Paths` include both of the following paths _and_ are set to _recursive_:
1. `$(SRCROOT)/../../react-native/React`
2. `$(SRCROOT)/../node_modules/react-native/React`
3. `${PROJECT_DIR}/../../../ios/Pods`
![Recursive paths](https://cloud.githubusercontent.com/assets/21329063/24250349/da91284c-0fd6-11e7-8328-6008e462039e.png)
**D.** Setting up cocoapods
Since we're dependent upon cocoapods (or at least the Firebase libraries being available at the root project -- i.e. your application), we have to make them available for RNFirebase to find them.
Using cocoapods is the easiest way to get started with this linking. Add or update a `Podfile` at `ios/Podfile` in your app with the following:
```ruby
# Required by RNFirebase
pod 'Firebase/Auth'
@ -91,9 +34,19 @@ pod 'Firebase/DynamicLinks'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
```
Then you can run `(cd ios && pod install)` to get the pods opened.
If you are new to Cocoapods do not already have React installed as a pod, then add Yoga and React to your `Podfile` as follows:
```ruby
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'BatchedBridge', # For React Native 0.45.0+
'Core',
# Add any other subspecs you want to use in your project
]
```
**NOTE: You need to use the `ios/[YOUR APP NAME].xcworkspace` instead of the `ios/[YOUR APP NAME].xcproj` file from now on.**
@ -155,7 +108,7 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
[RNFirebaseMessaging didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

View File

@ -1,31 +0,0 @@
pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
# Add any other subspecs you want to use in your project
'BatchedBridge',
'Core',
#'DevSupport'
#'RCTActionSheet',
#'RCTAnimation',
#'RCTCameraRoll',
#'RCTGeolocation',
#'RCTImage',
#'RCTLinkingIOS',
#'RCTNetwork',
#'RCTPushNotification',
#'RCTSettings',
#'RCTText',
#'RCTVibration',
#'RCTWebSocket'
]
pod 'Firebase/Auth'
pod 'Firebase/Analytics'
pod 'Firebase/AppIndexing'
pod 'Firebase/Core'
pod 'Firebase/Crash'
pod 'Firebase/Database'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'

View File

@ -50,18 +50,6 @@
"react": "*",
"react-native": ">= 0.38.0"
},
"rnpm": {
"commands": {
"prelink": "node_modules/react-native-firebase/bin/prepare.sh",
"postlink": "node_modules/react-native-firebase/bin/cocoapods.sh"
},
"ios": {
"project": "ios/RNFirebase.xcodeproj"
},
"android": {
"packageInstance": "new RNFirebasePackage()"
}
},
"devDependencies": {
"babel-eslint": "^7.0.0",
"babel-jest": "^14.1.0",