Swift 为爱奥尼亚应用程序开发Cordova插件时出错,应用程序未使用爱奥尼亚2构建Ios命令构建,它不';找不到框架类
我正在开发一个Ionic 2应用程序,它使用一些本机功能来录制带有特殊设置的视频,并允许用户在popover窗口中更改这些设置,这是作为Swift中的一个框架开发的,并作为Cordova插件集成到Ionic应用程序中 这是我的config.xml:Swift 为爱奥尼亚应用程序开发Cordova插件时出错,应用程序未使用爱奥尼亚2构建Ios命令构建,它不';找不到框架类,swift,cordova,ionic2,cordova-plugins,Swift,Cordova,Ionic2,Cordova Plugins,我正在开发一个Ionic 2应用程序,它使用一些本机功能来录制带有特殊设置的视频,并允许用户在popover窗口中更改这些设置,这是作为Swift中的一个框架开发的,并作为Cordova插件集成到Ionic应用程序中 这是我的config.xml: <?xml version='1.0' encoding='utf-8'?> <plugin id="com.brainshark.camerarecording" version="0.0.1" xmlns="http:/
<?xml version='1.0' encoding='utf-8'?>
<plugin id="com.brainshark.camerarecording" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>CameraRecording</name>
<js-module name="CameraRecording" src="www/CameraRecording.js">
<clobbers target="CameraRecording" /></js-module>
<platform name="ios">
<config-file parent="/*" target="config.xml">
<feature name="CameraRecording">
<param name="ios-package" value="CameraRecording" />
</feature>
</config-file>
<source-file src="src/ios/CameraRecording.swift" />
<framework src="libs/CameraRecording.framework" custom="true" />
</platform>
</plugin>
这是Swift代码:
import CameraRecording
@objc(CameraRecording) class CameraRecording : CDVPlugin, VideoRecorderPluginDelegate {
private var callbackId:String?
@objc(echo:) func echo(_ command: CDVInvokedUrlCommand) {
self.callbackId = command.callbackId
self.commandDelegate.run {
let uuid = UUID().uuidString
let fileName = command.arguments[0] as? String ?? "\(uuid).mp4"
let defaultResolution = command.arguments[1] as? String ?? "640x480"
let defaultFPS = command.arguments[2] as? String ?? "30"
let maxRecordingTime = command.arguments[3] as? String ?? "0"
if fileName.characters.count > 0 {
let frameworkBundle = Bundle(identifier: "com.brainshark.CameraRecording")
let storyboard = UIStoryboard(name: "Main", bundle: frameworkBundle)
let viewController = storyboard.instantiateViewController(withIdentifier: "VideRecordingViewController") as! VideoRecordingViewController
viewController.delegate = self
viewController.fileName=fileName
viewController.defaultResolution = defaultResolution
viewController.defaultFPS = defaultFPS
viewController.maxRecordingTime=maxRecordingTime
self.viewController?.present(
viewController,
animated: true,
completion: nil
)
}
}
}
func videoRecordDidFinish(_ filePath: String, recordedDuration:String, fileSize:String) {
let pluginResult = CDVPluginResult(
status: CDVCommandStatus_OK,
messageAs:["filePath":filePath,"recordedDuration":recordedDuration, "fileSize":fileSize]
)
self.commandDelegate!.send(
pluginResult,
callbackId: self.callbackId
)
}
func videoRecordDidFail(error: String) {
let pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR,
messageAs:error
)
self.commandDelegate!.send(
pluginResult,
callbackId: self.callbackId
)
}
}
如果我从XCode构建应用程序,一切正常,但是当使用Ionic控制台命令构建应用程序时,我得到错误:“'VideoRecorderPluginDelegate'不可用:找不到此协议的Swift声明”和“'VideoRecordingViewController'不可用:找不到此类的Swift声明”这些类在框架内声明为公共的,并且使用@objc public class,那么我会缺少什么呢
请帮忙 我是在特定于设备的架构上构建框架的,选择“通用iOS设备”解决了这个问题
import CameraRecording
@objc(CameraRecording) class CameraRecording : CDVPlugin, VideoRecorderPluginDelegate {
private var callbackId:String?
@objc(echo:) func echo(_ command: CDVInvokedUrlCommand) {
self.callbackId = command.callbackId
self.commandDelegate.run {
let uuid = UUID().uuidString
let fileName = command.arguments[0] as? String ?? "\(uuid).mp4"
let defaultResolution = command.arguments[1] as? String ?? "640x480"
let defaultFPS = command.arguments[2] as? String ?? "30"
let maxRecordingTime = command.arguments[3] as? String ?? "0"
if fileName.characters.count > 0 {
let frameworkBundle = Bundle(identifier: "com.brainshark.CameraRecording")
let storyboard = UIStoryboard(name: "Main", bundle: frameworkBundle)
let viewController = storyboard.instantiateViewController(withIdentifier: "VideRecordingViewController") as! VideoRecordingViewController
viewController.delegate = self
viewController.fileName=fileName
viewController.defaultResolution = defaultResolution
viewController.defaultFPS = defaultFPS
viewController.maxRecordingTime=maxRecordingTime
self.viewController?.present(
viewController,
animated: true,
completion: nil
)
}
}
}
func videoRecordDidFinish(_ filePath: String, recordedDuration:String, fileSize:String) {
let pluginResult = CDVPluginResult(
status: CDVCommandStatus_OK,
messageAs:["filePath":filePath,"recordedDuration":recordedDuration, "fileSize":fileSize]
)
self.commandDelegate!.send(
pluginResult,
callbackId: self.callbackId
)
}
func videoRecordDidFail(error: String) {
let pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR,
messageAs:error
)
self.commandDelegate!.send(
pluginResult,
callbackId: self.callbackId
)
}
}