1. 新建swift 文件
2.导入 模块名-Swith.h文件
#import "blue_open_door/blue_open_door-Swift.h"
3.定义的类用 public 和 @objc 修饰
//
// MyFlutterviewFactory.swift
// blue_open_door
//
// Created by edy on 2024/1/19.
//
import Foundation
import Flutter
public class MyFlutterViewFactory: NSObject,FlutterPlatformViewFactory {
var messenger:FlutterBinaryMessenger
@objc public init(messenger:FlutterBinaryMessenger) {
self.messenger = messenger
super.init()
}
public func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> FlutterPlatformView {
return MyFlutterView(frame,viewID: viewId,args: args,messenger: messenger)
}
public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
return FlutterStandardMessageCodec.sharedInstance()
}
}
class MyFlutterView: NSObject,FlutterPlatformView {
let label = UILabel()
init(_ frame: CGRect,viewID: Int64,args :Any?,messenger :FlutterBinaryMessenger) {
label.text = "我是 iOS View"
}
func view() -> UIView {
return label
}
}
4.主工程配置 SWIFT_VERSION
swift 引入 oc 的类
1.桥接文件导入头文件
2. heads 文件夹 位置调整