BranchMetrics / cordova-ionic-phonegap-branch-deep-linking-attribution

The Branch Cordova Ionic Phonegap SDK for deep linking and attribution. Branch helps mobile apps grow with deep links / deeplinks that power paid acquisition and re-engagement campaigns, referral programs, content sharing, deep linked emails, smart banners, custom user onboarding, and more.
https://docs.branch.io/apps/cordova-phonegap-ionic/
MIT License
234 stars 145 forks source link

Error: Cannot find module 'xml2js' #246

Closed spotsadmin closed 7 years ago

spotsadmin commented 7 years ago

Please see details below.. The error seems to be triggered from here:

...\plugins\io.branch.sdk\hooks\lib\configXmlParser.js:10:16

>cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Activity: MainActivity
        Android target: android-23
Android project created with cordova-android@5.0.0
Error: Cannot find module 'xml2js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at ...\plugins\io.branch.sdk\hooks\lib\configXmlParser.js:10:16
    at Object.<anonymous> (...\plugins\io.branch.sdk\hooks\lib\configXmlParser.js:133:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
renesansz commented 7 years ago

Hello @spotsadmin , We have a similar issue with this before but for iOS (see issue #150).

However, I cannot replicate the issue you are having for Android build. Can you provide additional details? (eg: cordova version, android version, installation procedure, and anything that might help us investigate the issue)

Best,

ethanneff commented 7 years ago

Hello @spotsadmin,

Thank you for reaching out. This is a known bug on our end which happens whenever cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=xxxx --variable URI_SCHEME=xxxx; gets terminated before completion.

Can you please reinstall Branch to make sure all the npm dependencies are installed? Please run the commands one at a time to prevent early termination of the branch-cordova-sdk.

spotsadmin commented 7 years ago

Hi @ethanneff and @renesansz, thanks for the response.

We tried re-installing branchio plugin and ran into different error this time. (NOTE: when I reported the problem it was trying to fetch version 2.2.3 of the plugin - Now after uninstall, it is trying to fetch version 2.4.2)

> cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=key_live_xxxx --variable URI_SCHEME=xxxxx --save
Fetching plugin "branch-cordova-sdk" via npm
Saved plugin info for "io.branch.sdk" to config.xml
Installing "io.branch.sdk" for android
Checking dependencies:
    Can't find module mkpath, running npm install
Installing "io.branch.sdk" for browser
    Failed to install module mkpath:Error: Command failed: The system cannot find the path specified.
renesansz commented 7 years ago

@spotsadmin I haven't encountered this kind of issue before. Can you verify that you have configured properly your NPM? Do note that your NPM might need root access so you might try running the command with sudo. Another thing is to re-setup your platform and plugins again, this can be done by removing the plugins & platforms folder, then re-install the platforms first before the plugins.

I cannot replicate the issue so I'm not sure how to resolve this one.

Let me know if this does not help.

Best,

ethanneff commented 7 years ago

Hello @spotsadmin,

Thank you for bringing this to our attention. We were able to reproduce the error by doing the following. Basically, running a command after cordova plugin add branch-cordova-sdk could cause the script to not install all the npm dependencies. I have made the hook to install npm dependencies async so this issue should not happen again. #256. Please update reinstall the Branch SDK to the latest version to fix this error.

cordova platform add ios; cordova platform add android;

cordova plugin remove io.branch.sdk; cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=key_live_icCccJIpd7GlYY5oOmoEtpafuDiuyXhT --variable URI_SCHEME=enefftest;


* breaks 
```bash
cordova platform remove ios;
cordova platform remove android;
cordova platform remove browser;

cordova plugin remove io.branch.sdk;
cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=key_live_icCccJIpd7GlYY5oOmoEtpafuDiuyXhT --variable URI_SCHEME=enefftest;

cordova platform add ios;
cordova platform add android;
spotsadmin commented 7 years ago

Thanks for the update - it worked well for android.. however ios failed.. pls see details below.

CompileC build/theapp.build/Debug-iphoneos/theapp.build/Objects-normal/armv7/BranchSDK.o theapp/Plugins/io.branch.sdk/BranchSDK.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

    cd /clientx/platforms/ios

    export LANG=en_US.US-ASCII

    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 -x objective-c -arch armv7 -fmessage-length=134 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=c99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=6.0 -iquote /clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/theapp-generated-files.hmap -I/clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/theapp-own-target-headers.hmap -I/clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/theapp-all-target-headers.hmap -iquote /clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/theapp-project-headers.hmap -I/clientx/platforms/ios/build/device/include -I/clientx/platforms/ios/build/device/usr/local/lib/include -I/clientx/platforms/ios/build/UninstalledProducts/include -I/clientx/platforms/ios/build/device -I/clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/DerivedSources/armv7 -I/clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/DerivedSources -F/clientx/platforms/ios/build/device -include /clientx/platforms/ios/build/sharedpch/theapp-Prefix-edtxaddddaawssdtsgomcxrrixpf/theapp-Prefix.pch -MMD -MT dependencies -MF /clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/Objects-normal/armv7/BranchSDK.d --serialize-diagnostics /clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/Objects-normal/armv7/BranchSDK.dia -c /projectx/Plugins/io.branch.sdk/BranchSDK.m -o /clientx/platforms/ios/build/theapp.build/Debug-iphoneos/theapp.build/Objects-normal/armv7/BranchSDK.o

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:12:

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:14:61: error: 

      expected ')'

typedef void (^callbackWithParams) (NSDictionary * _Nonnull params, NSError * _Nullable error);

                                                            ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:14:36: note: to match

      this '('

typedef void (^callbackWithParams) (NSDictionary * _Nonnull params, NSError * _Nullable error);

                                   ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:15:54: error: 

      expected ')'

typedef void (^callbackWithUrl) (NSString * _Nonnull url, NSError * _Nullable error);

                                                     ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:15:33: note: to match

      this '('

typedef void (^callbackWithUrl) (NSString * _Nonnull url, NSError * _Nullable error);

                                ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:16:71: error: 

      expected ')'

typedef void (^callbackWithStatus) (BOOL changed, NSError * _Nullable error);

                                                                      ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:16:36: note: to match

      this '('

typedef void (^callbackWithStatus) (BOOL changed, NSError * _Nullable error);

                                   ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:17:55: error: 

      expected ')'

typedef void (^callbackWithList) (NSArray * _Nullable list, NSError * _Nullable error);

                                                      ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:17:34: note: to match

      this '('

typedef void (^callbackWithList) (NSArray * _Nullable list, NSError * _Nullable error);

                                 ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:18:77: error: 

      expected ')'

typedef void (^callbackWithUrlAndSpotlightIdentifier) (NSString * _Nullable url, NSString * _Nullable spotlightIdentifier, NSE...

                                                                            ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:18:55: note: to match

      this '('

typedef void (^callbackWithUrlAndSpotlightIdentifier) (NSString * _Nullable url, NSString * _Nullable spotlightIdentifier, NSE...

                                                      ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:19:85: error: 

      expected ')'

typedef void (^callbackWithBranchUniversalObject) (BranchUniversalObject * _Nonnull universalObject, BranchLinkProperties * _N...

                                                                                    ^

/projectx/Plugins/io.branch.sdk/BNCCallbacks.h:19:51: note: to match

      this '('

typedef void (^callbackWithBranchUniversalObject) (BranchUniversalObject * _Nonnull universalObject, BranchLinkProperties * _N...

                                                  ^

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:18:

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:14:55: error: 

      expected ')'

typedef void (^shareCompletion) (NSString * _Nullable activityType, BOOL completed);

                                                      ^

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:14:33: note: 

      to match this '('

typedef void (^shareCompletion) (NSString * _Nullable activityType, BOOL completed);

                                ^

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:15:64: error: 

      expected ')'

typedef void (^shareCompletionWithError) (NSString * _Nullable activityType, BOOL completed, NSError * _Nullable activityError);

                                                               ^

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:15:42: note: 

      to match this '('

typedef void (^shareCompletionWithError) (NSString * _Nullable activityType, BOOL completed, NSError * _Nullable activityError);

                                         ^

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:14:43: warning: 

      pointer is missing a nullability type specifier (__nonnull or __nullable) [-Wnullability-completeness]

typedef void (^shareCompletion) (NSString * _Nullable activityType, BOOL completed);

                                          ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:87:73: error: 

      incompatible block pointer types sending 'void (^)(NSDictionary *__strong, NSError *__strong)' to parameter of type

      'callbackWithParams' (aka 'void (^)(NSDictionary *__strong)')

    [branch initSessionWithLaunchOptions:nil andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {

                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

/projectx/Plugins/io.branch.sdk/Branch.h:276:109: note: passing

      argument to parameter 'callback' here

- (void)initSessionWithLaunchOptions:(NSDictionary *)options andRegisterDeepLinkHandler:(callbackWithParams)callback;

                                                                                                            ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:204:74: error: 

      incompatible block pointer types sending 'void (^)(NSDictionary *__strong, NSError *__strong)' to parameter of type

      'callbackWithParams' (aka 'void (^)(NSDictionary *__strong)')

    [branch setIdentity:[command.arguments objectAtIndex:0] withCallback:^(NSDictionary *params, NSError *error) {

                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

/projectx/Plugins/io.branch.sdk/Branch.h:552:73: note: passing

      argument to parameter 'callback' here

- (void)setIdentity:(NSString *)userId withCallback:(callbackWithParams)callback;

                                                                        ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:341:42: error: 

      incompatible block pointer types sending 'void (^)(NSArray *__strong, NSError *__strong)' to parameter of type

      'callbackWithList' (aka 'void (^)(NSArray *__strong)')

    [branch getCreditHistoryWithCallback:^(NSArray *list, NSError *error) {

                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

/projectx/Plugins/io.branch.sdk/Branch.h:632:56: note: passing

      argument to parameter 'callback' here

- (void)getCreditHistoryWithCallback:(callbackWithList)callback;

                                                       ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:424:50: error: 

      incompatible block pointer types sending 'void (^)(NSDictionary *__strong, NSError *__strong)' to parameter of type

      'callbackWithParams __nullable' (aka 'void (^)(NSDictionary *__strong)')

    [branchUniversalObj registerViewWithCallback:^(NSDictionary *params, NSError *error) {

                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:18:

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:47:63: note: 

      passing argument to parameter 'callback' here

- (void)registerViewWithCallback:(nullable callbackWithParams)callback;

                                                              ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:476:73: error: 

      incompatible block pointer types sending 'void (^)(NSString *__strong, NSError *__strong)' to parameter of type

      'callbackWithUrl __nonnull' (aka 'void (^)(NSString *__strong)')

    [branchUniversalObj getShortUrlWithLinkProperties:props andCallback:^(NSString *url, NSError *error) {

                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:18:

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:53:123: note: 

      passing argument to parameter 'callback' here

- (void)getShortUrlWithLinkProperties:(nonnull BranchLinkProperties *)linkProperties andCallback:(nonnull callbackWithUrl)callback;

                                                                                                                          ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:538:90: error: 

      incompatible block pointer types sending 'void (^)(NSString *__strong, NSError *__strong)' to parameter of type

      'callbackWithUrl __nonnull' (aka 'void (^)(NSString *__strong)')

            [branchUniversalObj getShortUrlWithLinkProperties:linkProperties andCallback:^(NSString *url, NSError *error) {

                                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:18:

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:53:123: note: 

      passing argument to parameter 'callback' here

- (void)getShortUrlWithLinkProperties:(nonnull BranchLinkProperties *)linkProperties andCallback:(nonnull callbackWithUrl)callback;

                                                                                                                          ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:532:60: error: 

      incompatible block pointer types sending 'void (^)(NSString *__strong, BOOL)' to parameter of type 'shareCompletion __nullable'

      (aka 'void (^)(NSString *__strong)')

                                                completion:^(NSString *activityType, BOOL completed) {

                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:18:

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:58:234: note: 

      passing argument to parameter 'completion' here

  ...*)shareText fromViewController:(nullable UIViewController *)viewController completion:(nullable shareCompletion)completion;

                                                                                                                     ^

/projectx/Plugins/io.branch.sdk/BranchSDK.m:591:53: error: 

      incompatible block pointer types sending 'void (^)(NSString *__strong, NSError *__strong)' to parameter of type

      'callbackWithUrl __nullable' (aka 'void (^)(NSString *__strong)')

    [branchUniversalObj listOnSpotlightWithCallback:^(NSString *string, NSError *error) {

                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.m:8:

In file included from /projectx/Plugins/io.branch.sdk/BranchSDK.h:11:

In file included from /projectx/Plugins/io.branch.sdk/Branch.h:18:

/projectx/Plugins/io.branch.sdk/BranchUniversalObject.h:67:63: note: 

      passing argument to parameter 'callback' here

- (void)listOnSpotlightWithCallback:(nullable callbackWithUrl)callback;

                                                              ^

1 warning and 16 errors generated.

** BUILD FAILED **