1

I am developing a Nativescript + Angular shared web&mobile application. I am using most recent versions of frameworks (TNS 6 and Angular 8). I need to use a SDK which is available natively for iOS - https://github.com/dotpay/Mobile-SDK-iOS . I tried to wrap it as a plugin, and tried to do this in two ways:

  1. Creating plugin with Podfile - in this case, when I try to access DotPay object in my final project, I add
declare var DotPay;

at the top of file, but I am getting and error

Can't find variable: DotPay

when I run the code.

  1. Adding the whole library in platforms/ios/ directory. In this case, I cannot even build the project, because I am getting this error:
The bundle at $PROJECT_DIR/node_modules/nativescript-dotpay/platforms/ios/DotPaySDK.framework does not appear to be a dynamic framework.

I tried to add module.modulemap file in several locations (/platforms/ios, /platforms/ios/DotPaySDK.framework, /platforms/ios/DotPaySDK.framework/Modules) but it did not change anything.

Also, after calling this command

TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios

no definition file for this SDK is generated (in both cases).

The structure of SDK is: DotPay iOS SDK structure

I've also run the second option with

tns build ios --log trace

And I've found out that it fails at ios-project-service.js, lines 499-502

      const packageType = plistJson["CFBundlePackageType"];
        if (packageType !== "FMWK") {
            this.$errors.failWithoutHelp("The bundle at %s does not appear to be a dynamic framework.", libraryPath);
        }

Because of the fact, that CFBundlePackageType key of SDK Info.plist is BNDL instead of FMWK.

Nevaan
  • 129
  • 2
  • 11
  • 1
    Try generating typings, that should help you understand if the APIs are public and accessible, generally it should be. Can you share the plugin repo? – Manoj Aug 12 '19 at 15:21
  • Hi Manoj, as I described in my question - I was trying to generate the typings. I've created example repo showing the problem: https://github.com/Nevaan/nativescript-dotpay-ios-sdk-showcase . All my attempts are on different branches – Nevaan Aug 12 '19 at 17:41
  • It looks like app repo, not plugin. Are you trying to use the framework within your project without building a plugin? Can you please point where you have place `.framework` file. – Manoj Aug 12 '19 at 19:48
  • Ok, you are right- something is wrong with branch podfile-attempt. I just fixed it. On branch modified-sdk-source "plugin" is in directory tns-modified-dotpay-sdk, on branch unmodified-sdk-source this is in tns-unmodified-dotpay-sdk and now in branch podfile-attempt this is tns-pod-dotpay. In all of this cases its in platforms/ios/DotPaySDK.framework (ofc besides the podfile attempt). Please ignore master branch. It is possible that i misunderstood some docs or other resources I used. For now, I dont want to publish the plugin and I want it to be local for my project. My apologies for mistake. – Nevaan Aug 12 '19 at 20:05
  • What I exactly want to achieve is to take some native, 3rd party library (DotPaySDK for iOS) , and make it accessible and usable in my ng+tns project. I dont want to place it in my "root" platform/ios directory, because its out of VCS and is generated automatically, so I would have to take care of it manually. – Nevaan Aug 12 '19 at 20:08
  • @Manoj I created another repo based on plugin seed - you can take a look if you think it may be more clear - link in comment to Naxos84's answer – Nevaan Aug 13 '19 at 09:28

2 Answers2

1

At the end, I received help on ios-runtime repository of Nativescript. Here is the issue: https://github.com/NativeScript/ios-runtime/issues/1187

Nevaan
  • 129
  • 2
  • 11
0

To build a plugin for the iOS sdk you should start with the Nativescript Plugin Seed.

Inside that Plugin Project put your *.framework inside $myproject/src/platforms/ios.

After that generate typings from the created demo project. Then you can see what is "visible" and what not.

Naxos84
  • 1,890
  • 1
  • 22
  • 34
  • Ok, I created another repo based on seed, but it is generating same errors ( https://github.com/Nevaan/nativescript-dotpay ) - so I think that this is not the issue. We were talking on nativescript slack with Naxos84, and I tried some suggestions of him but nothins seemed to work – Nevaan Aug 13 '19 at 09:27
  • Naxos84 (on nativescript.slack) === Naxos84 (StackOverflow) ;) If you get to know what is causing the issue please let me/us know. – Naxos84 Aug 14 '19 at 05:55