React-native-branch-deep-linking-attribution: Cannot link native module with link command or through pods

Created on 6 Jan 2018  路  12Comments  路  Source: BranchMetrics/react-native-branch-deep-linking-attribution

I've tried following along with your docs and instructions, but nothing seems to work properly. I do have a few other native modules included in this project -
https://github.com/facebook/react-native-fbsdk
https://github.com/devfd/react-native-google-signin
https://github.com/tipsi/tipsi-stripe

I am running on RN version 0.51

Everything is setup and working fine with all of these modules, but if I go through your docs and I use the react-native link react-native-branch command, in ios there doesn't seem to be reference to the branch sdk or any branch references anywhere in general. If I try and go the route of adding via pod install, it does not cooperate with the google sign in module, and all of a sudden it seems to be freaking out about google signin path length (which it doesnt otherwise), and beyond that, it has a host of other issues (I presume because there is a react folder stuck in with the pods now?). In any case, I can't seem to get past this.

Most helpful comment

I had to go through and manually link, and afterwards it seemed to work out okay. Maybe there should be docs added for manual linking as well. Also I found the documentation very unclear and I had to use a combination of the docs from the branch website, and the SDK setup in the dashboard. Just in case anyone else runs into issues, try and cross-reference that material. It's not ideal, but it worked for me.

All 12 comments

Experiencing the same thing. Can't seem to install it in any way.

I had to go through and manually link, and afterwards it seemed to work out okay. Maybe there should be docs added for manual linking as well. Also I found the documentation very unclear and I had to use a combination of the docs from the branch website, and the SDK setup in the dashboard. Just in case anyone else runs into issues, try and cross-reference that material. It's not ideal, but it worked for me.

+1

@trustfall How exactly did you do the manually linking of the branch.io libraries?

Hi! We've also experienced this issue. One of our team members suggested we should use rnpm and linking works. We haven't finished yet with the whole integration, but it seems promising while we wait for the react-native link fix.

Yeah, react-native link did not work. Fixed by linking manually: here's the manual linking guide.

Edit: nope, bit hasty, now it fails with a native exception on launch
Edit 2: ok, it _does_ work, I just forgot to add the branch config to my Info.plist

We still have the same issue, to make it work in both platforms we had to make use of both react-native link and rnpm link, discarding the changes that the former makes to the iOS project, if I'm not mistaken. Maybe @urikpd can confirm?

Yes!!! We made it work using:
npm install --save react-native-branch
react native link react-native-branch - discarding iOS changes - (android working)
rnpm link react-native-branch (iOS working)

Hope that helps!

@urikpd Im doing exactly that but I get this error 'react-native-branch/RNBranch.h' file not found

I can't reproduce this problem, but I have some feedback.

These steps work fine:

react-native init TestProject
cd TestProject
yarn add react-native-branch
react-native link react-native-branch
react-native run-ios

I doubt those steps will fail for anyone, but if anyone gets a failure, please post details. Environment info:

|component|version|
|---|---|
|node|10.15.0|
|npm|6.8.0|
|yarn|1.13.0|
|react-native-cli|2.0.1|
|react-native|0.58.4|

Here are the changes to the Xcode project made by react-native link:

diff --git a/ios/TestProject.xcodeproj/project.pbxproj b/ios/TestProject.xcodeproj/project.pbxproj
index 1db057e..325d607 100644
--- a/ios/TestProject.xcodeproj/project.pbxproj
+++ b/ios/TestProject.xcodeproj/project.pbxproj
@@ -5,7 +5,6 @@
        };
        objectVersion = 46;
        objects = {
-
 /* Begin PBXBuildFile section */
                00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
                00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -40,6 +39,7 @@
                ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
                ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
                ED2971652150620600B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2971642150620600B7C4FE /* JavaScriptCore.framework */; };
+               48FFE76069CE4DA4AD282092 /* libreact-native-branch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 92BDFA19A9D84D2387DEA5AA /* libreact-native-branch.a */; };
 /* End PBXBuildFile section */

 /* Begin PBXContainerItemProxy section */
@@ -347,6 +347,8 @@
                ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
                ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
                ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
+               0D49A87E25884F03AE6F3C76 /* RNBranch.xcodeproj */ = {isa = PBXFileReference; name = "RNBranch.xcodeproj"; path = "../node_modules/react-native-branch/ios/RNBranch.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
+               92BDFA19A9D84D2387DEA5AA /* libreact-native-branch.a */ = {isa = PBXFileReference; name = "libreact-native-branch.a"; path = "libreact-native-branch.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
 /* End PBXFileReference section */

 /* Begin PBXFrameworksBuildPhase section */
@@ -375,6 +377,7 @@
                                832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
                                00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
                                139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
+                               48FFE76069CE4DA4AD282092 /* libreact-native-branch.a in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -564,6 +567,7 @@
                                832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
                                00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
                                139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
+                               0D49A87E25884F03AE6F3C76 /* RNBranch.xcodeproj */,
                        );
                        name = Libraries;
                        sourceTree = "<group>";
@@ -692,7 +696,7 @@
                83CBB9F71A601CBA00E9B192 /* Project object */ = {
                        isa = PBXProject;
                        attributes = {
-                               LastUpgradeCheck = 0940;
+                               LastUpgradeCheck = 940;
                                ORGANIZATIONNAME = Facebook;
                                TargetAttributes = {
                                        00E356ED1AD99517003FC87E = {
@@ -1189,6 +1193,14 @@
                                PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestProject.app/TestProject";
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "\"$(SRCROOT)/$(TARGET_NAME)\"",
+                               );
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Debug;
                };
@@ -1207,6 +1219,14 @@
                                PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestProject.app/TestProject";
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "\"$(SRCROOT)/$(TARGET_NAME)\"",
+                               );
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Release;
                };
@@ -1226,6 +1246,10 @@
                                PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
                                PRODUCT_NAME = TestProject;
                                VERSIONING_SYSTEM = "apple-generic";
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Debug;
                };
@@ -1244,6 +1268,10 @@
                                PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
                                PRODUCT_NAME = TestProject;
                                VERSIONING_SYSTEM = "apple-generic";
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Release;
                };
@@ -1270,6 +1298,14 @@
                                SDKROOT = appletvos;
                                TARGETED_DEVICE_FAMILY = 3;
                                TVOS_DEPLOYMENT_TARGET = 9.2;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "\"$(SRCROOT)/$(TARGET_NAME)\"",
+                               );
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Debug;
                };
@@ -1296,6 +1332,14 @@
                                SDKROOT = appletvos;
                                TARGETED_DEVICE_FAMILY = 3;
                                TVOS_DEPLOYMENT_TARGET = 9.2;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "\"$(SRCROOT)/$(TARGET_NAME)\"",
+                               );
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Release;
                };
@@ -1321,6 +1365,14 @@
                                SDKROOT = appletvos;
                                TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestProject-tvOS.app/TestProject-tvOS";
                                TVOS_DEPLOYMENT_TARGET = 10.1;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "\"$(SRCROOT)/$(TARGET_NAME)\"",
+                               );
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Debug;
                };
@@ -1346,6 +1398,14 @@
                                SDKROOT = appletvos;
                                TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestProject-tvOS.app/TestProject-tvOS";
                                TVOS_DEPLOYMENT_TARGET = 10.1;
+                               LIBRARY_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "\"$(SRCROOT)/$(TARGET_NAME)\"",
+                               );
+                               HEADER_SEARCH_PATHS = (
+                                       "$(inherited)",
+                                       "$(SRCROOT)/../node_modules/react-native-branch/ios/**",
+                               );
                        };
                        name = Release;
                };

These changes are all made by react-native link itself, not by any component of this SDK module. We have a postinstall hook that is only triggered if you have branch.json in the project, to automatically add it to your project. In this example, I had no branch.json. (In fact, to verify I totally removed the rnpm stanza from the bottom of the package.json.) These are changes made by react-native link itself, and not under our control. They are also usually necessary. I'd be very skeptical about ditching these changes.

The native Branch iOS SDK is included in the NPM module. Taking the Branch SDK from the CocoaPods repo is not supported. The only time CocoaPods should be used with this SDK at all is when integrating with a native app, not in a pure RN app. In that case, CocoaPods is just used as an integration mechanism to add the version of the SDK bundled in the NPM module. It's not really possible to support just taking the native SDKs from wherever they can be found. That's why a specific version is bundled into the module. This is precisely what React Native itself has done since 0.12. There is no current React pod in the CocoaPods repo. You get the RN native components in the NPM module. If you are integrating with a native app, you use a relative path for the React pod to get it from node_modules, not the CP repo. In particular, in a pure RN app, the native Branch SDK is built into the libreact-native-branch.a library. If you add it to a Podfile, you will be getting two different copies of the SDK, possibly different versions. This is likely to produce unexpected results, and at best you'll have a bunch of unused native code compiled into your app.

The repo examples all work, at least the iOS ones. Particularly webview_example, a pure RN app, and webview_example_native_ios, a Swift app with an RCTRootView embedded. Whatever happens in the examples is certainly supported. It's nearly certain that there is some difference between your app, if you're having this problem, and the examples. It would help to know in considerable detail what it is. If there is some other common configuration or way of building RN examples, I'd love to add another working example to the repo and be able to ensure we support it.

Is anyone still experiencing this issue?

Still an issue for me, I tried to react-native link``` andpod installbut doesn't work. It installsInstalling React (0.11.0)`` and others which breaks the whole project. Is it any guide to install it manually?

Was this page helpful?
0 / 5 - 0 ratings