OGeek|极客世界-中国程序员成长平台

标题: ios - ionic cordova build ios 使用 xcode swift 3 框架安装自定义插件失败 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 02:19
标题: ios - ionic cordova build ios 使用 xcode swift 3 框架安装自定义插件失败

我正在尝试从我创建的 iOS 框架中读取一个函数,该框架已添加到自定义 cordova 插件中。 我已将框架编译为“通用 iOS 设备”,正如一些帖子中所建议的那样,但我在使用框架功能时仍然遇到问题..

我正在使用cordova cli 7.0.1 和cordova-ios”:^4.4.0。 在我正在使用的插件 config.xml 文件中

添加我的框架但调用我的函数(在尝试读取框架函数的插件中)返回: 错误:“打印机”不可用:找不到此类的 Swift 声明: 让 printtt = testtest.printer(); ^~~~~~~ testtest.printer:2:12:注意:“打印机”已在此处明确标记为不可用 开放类打印机:NSObject { ^ /platforms/ios/MyApp/Plugins/com-moduscreate-plugins-echo/ModusEchoSwift.swift:11:5: 错误:“打印机”类型的值没有成员“printlocal” printtt.printlocal(); ^~~~~~~ ~~~~~~~~~~

** BUILD FAILED **

有人遇到过这样的问题吗? PS。我的框架包含一个带有公共(public)方法的公共(public)类打印机 我在 xcode 8.xx 下测试过的 printlocal

**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>

我的 swift 文件:

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 文件:

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



Best Answer-推荐答案


发现问题: 由于我使用了“cordova-plugin-add-swift-support”插件,它已将项目的 ios min 部署目标设置为 7.0,因此框架(动态库)仅从 8.0 开始引入 将插件 IOS_MIN_DEPLOYMENT_TARGET 全局变量值更改为 8.0 时,(重新编译后),它已经开始工作了! 因此,上面的代码是使用 swift3 编写的来自 cordova 自定义插件的 xcode 框架的方式。

关于ios - ionic cordova build ios 使用 xcode swift 3 框架安装自定义插件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45281556/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4