离子cordova构建ios无法使用xcode swift 3框架安装自定义插件

编程入门 行业动态 更新时间:2024-10-25 21:23:03
本文介绍了离子cordova构建ios无法使用xcode swift 3框架安装自定义插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I'm trying to read a function from an iOS framework i have created which I have added into a custom cordova plugin. 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..

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

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

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

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

有人遇到过这样的问题吗? PS。我的框架包含一个公共类打印机,使用公共方法 printlocal,我已经在xcode 8.xx下测试了

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="apache/cordova/ns/plugins/1.0" xmlns:android="schemas.android/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]); };

推荐答案

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

Found the problem: Since i have used "cordova-plugin-add-swift-support" plugin, it has set the ios min deployment target of the project to 7.0 hence the frameworks (dynamic library), were introduced only from 8.0 when changing the plugin IOS_MIN_DEPLOYMENT_TARGET global var value to 8.0, (after recompile), it has started working! so, the above code is the way of working with a xcode framework written in swift3 from cordova custom plugin.

更多推荐

离子cordova构建ios无法使用xcode swift 3框架安装自定义插件

本文发布于:2023-11-26 15:18:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   离子   插件   框架   cordova

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!