Skip to content

Commit

Permalink
Fix iOS Podspec issue; Update documentation to make use of pod file f…
Browse files Browse the repository at this point in the history
…or iOS setup rather than react-native link
  • Loading branch information
chrisbianca committed Mar 27, 2017
1 parent 3eb3013 commit f300149
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 45 deletions.
1 change: 0 additions & 1 deletion RNFirebase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/invertase/react-native-firebase.git", :tag => "v#{s.version}" }
s.social_media_url = 'http://twitter.com/mikediarmid'
s.platform = :ios, "8.0"
s.header_dir = 'ios/RNFirebase'
s.preserve_paths = 'README.md', 'package.json', '*.js'
s.source_files = 'ios/RNFirebase/*.{h,m}'
s.dependency 'React'
Expand Down
60 changes: 16 additions & 44 deletions docs/installation.ios.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,12 @@
# iOS Installation

Setup the Firebase ios frameworks first; check out the relevant Firebase docs [here](https://firebase.google.com/docs/ios/setup#frameworks) or see section `d` below.
Setup the Firebase ios frameworks first; check out the relevant Firebase docs [here](https://firebase.google.com/docs/ios/setup#frameworks).

## cocoapods

We've automated the process of setting up with cocoapods. This will happen automatically upon linking the package with `react-native-cli`.

**Remember to use the `ios/[YOUR APP NAME].xcworkspace` instead of the `ios/[YOUR APP NAME].xcproj` file from now on**.

We need to link the package with our development packaging. We have two options to handle linking:

#### Automatically with react-native-cli

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
```

Update the newly installed pods once the linking is done:

```bash
cd ios && pod update --verbose
```

#### Manually

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:
As such, using cocoapods is the easiest way to get started. Add or update a `Podfile` at `ios/Podfile` in your app with the following:

```ruby
# Required by RNFirebase
Expand All @@ -61,6 +20,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 do use this route, remember to use the `.xcworkspace` file.
Then you can run `(cd ios && pod install)` to get the pods installed.

**Remember to use the `ios/[YOUR APP NAME].xcworkspace` instead of the `ios/[YOUR APP NAME].xcproj` file from now on**.

## AppDelegate.m

You need to add the following to the top of `ios/AppDelegate.m`:

`#import <Firebase.h>

and this to the `didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method:

`[FIRApp configure];

5 comments on commit f300149

@designorant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please excuse my ignorance but I'm very curious about this.

Is this a replacement for react-native link react-native-firebase? I'm slightly concerned that the pod now installs React (0.11.0) and warns that [!] React has been deprecated. What was the Podspec issue?

I've had RNFirebase linked up until alpha9, and all was fine but since I've seen this commit, ran pod install (on the updated Podfile) I'm now getting the following on npm run start:

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: react-native
  Paths: /ios/Pods/React/package.json collides with /node_modules/react-native/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
  Duplicate module name: react-native
  Paths: /ios/Pods/React/package.json collides with /node_modules/react-native/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
    at HasteMap._updateHasteMap (/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:158:13)
    at p.getName.then.name (/node_modules/react-native/packager/src/node-haste/DependencyGraph/HasteMap.js:133:31)

Is there some cleaning up to be done in apps that were previously linked, or is this a bug?

@Salakar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @chrisbianca --^

@chrisbianca
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my bad, I took for granted that I have React set and imported as a pod from the node_modules directory too which makes using Pods a much simpler way to go (though does have the caveat that it doesn't work particularly well if you're building React from a fork). I'll update the documentation and re-insert the react-native link option and explain which is best for which circumstance.

Sorry for the inconvenience @designorant. Just remove the react-native-firebase Pod and re-run pod install and it should go back to the way it was.

@chrisbianca
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now updated. I will add in optional FCM setup instructions later once I've tested everything works ok

@designorant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying Chris!

Please sign in to comment.