How to call a function in Xcode framework which is embedded inside a Cordova custom plugin?

Viewed 305

i have created a cordova plugin using plugman, created a framework in ios (cocoa pods) and added it to my plugin. when i try to call a function from that framework (swift file which contain the function to be called by cordova) i get an error that i dont have the declaration of the function in swift. I have compiled the framework as "Generic iOS Device", as was suggested in some post but i still have a problem in using the framework function..

i'm working with Cordova cli 7.0.1 and Cordova-ios": ^4.4.0. in the plugin config.xml file I'm using

which add my framework but calling my function (in the plugin which try to read a framework function) return: error: 'printer' is unavailable: cannot find Swift declaration for this class: let printtt = testtest.printer(); ^~~~~~~ testtest.printer:2:12: note: 'printer' has been explicitly marked unavailable here open class printer : NSObject { ^ /platforms/ios/MyApp/Plugins/com-moduscreate-plugins-echo/ModusEchoSwift.swift:11:5: error: value of type 'printer' has no member 'printlocal' printtt.printlocal(); ^~~~~~~ ~~~~~~~~~~

** BUILD FAILED **

does any one have encountered such a problem? PS. my framework contains a public class printer with public method printlocal which i have tested under xcode 8.xx

**my plugin.xml file:** 
<?xml version='1.0' encoding='utf-8'?>
<plugin id="com-moduscreate-plugins-echo" version="0.0.1" 
xmlns="http://apache.org/cordova/ns/plugins/1.0" 
xmlns:android="http://schemas.android.com/apk/res/android">
    <name>ModusEcho</name>
    <js-module name="ModusEcho" src="www/ModusEcho.js">
        <clobbers target="modusEcho" />
    </js-module>
    <platform name="ios">
       <framework src="src/ios/testtest.framework" custom="true" embed="true" />
        <config-file target="config.xml" parent="/*">
            <feature name="ModusEcho">
                <param name="ios-package" value="ModusEchoSwift" />
            </feature>
        </config-file>
        <source-file src="src/ios/ModusEchoSwift.swift" />
    </platform>
</plugin>

my swift file:

import testtest
@objc(ModusEchoSwift) class ModusEchoSwift : CDVPlugin{
  @objc(echocrypt:)
  func echocrypt(command: CDVInvokedUrlCommand) {
    var pluginResult = CDVPluginResult(
      status: CDVCommandStatus_ERROR
    )

    let printtt = testtest.printer();
    printtt.printlocal();
  }
}

**my dynamic framework class:** 
import Foundation
public class printer:NSObject {
    public func printlocal() {
        print("from printer!!!");

    }
}

www/modusecoh.js file:

var exec = require('cordova/exec');
exports.echocrypt = function(arg0, success, error) {
    exec(success, error, "ModusEcho", "echocrypt"`enter code here`, [arg0]);
};
0 Answers
Related