Nevaan
Nevaan

Reputation: 129

Using 3rd party, native SDK in nativescript project - Framework does not appear to be a dynamic framework

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.

Upvotes: 1

Views: 567

Answers (2)

Nevaan
Nevaan

Reputation: 129

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

Upvotes: 1

Naxos84
Naxos84

Reputation: 2028

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.

Upvotes: 0

Related Questions