• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - ionic cordova build ios 使用 xcode swift 3 框架安装自定义插件失败

[复制链接]
菜鸟教程小白 发表于 2022-12-13 02:19:04 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在尝试从我创建的 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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap