平台工程的Podfile中需在target ‘***’ do 前面加上以下代码(1 = debug 0 = release)
ENV['debug'] = '1'
或者 在 pod intall的前面加上参数
env debug=0 pod install
Podfile中需在target ‘***’ do 后面加入
pod 'MagpieBridge', :path => 'magpie/ios/source'
pod 'MagpieBridge', :path => 'magpie/ios/lib'
Podfile中需在target ‘***’ do 后面加入
pod 'Flutter', :path => 'magpie/ios/flutter'
使用Magpie 头文件的的Pod需在Podspec中加入依赖
*.dependency 'MagpieBridge'
使用Flutter 头文件的的Pod需在Podspec中加入依赖
*.dependency 'Flutter'
支持 x86_64 armv7 arm64
release支持 armv7 arm64 debug支持 x86_64 armv7 arm64
- MagpieBridge.a 静态库文件
- MagpieBridge.podspec podsepc文件
- Headers
- README.MD 说明
- App 库文件
- Info.plist
- flutter_assets 资源目录
- isolate_snapshot_data debug模式下用于加速isolate启动
- kernel_blob.bin debug模式下Dart代码产物
- vm_snapshot_data debug模式下用于加速dart vm启动
App.framework必须与Flutter.framework保持环境一致
本工程提供了demo的debug环境的app.framework,Podfile中需在target ‘***’ do 后面加入
pod 'FlutterBusiness', :path => 'magpie/ios/product'
debug模式下可通过attach命令调试Dart代码 1.安装iOS app并运行。 2.在Dart侧运行Flutter attach(建议使用IDE的attach功能) 3.输入R后进入Flutter页面 4.输入 r: hotreload R: hotrestart
s.vendored_frameworks = ‘App.framework’
@protocol MagpiePlatform <NSObject>
@optional
/**
* Dart代码入口,默认为main()
*/
- (NSString *)entryForDart;
/**
* Dart业务资源文件
* Bundle中必须有info.plist ,其中必须有 key:@"FLTAssetsPath",value为flutter_assets目录在bundle中的位置,例: @"/flutter_assets"
*/
- (NSBundle *)dartBundle;
@required
/**
* Dart的页面打开能力依赖这个实现
*
* @param url 打开的页面资源定位符
* @param urlParams 传人页面的参数;
* @param exts 额外参数
* @param completion 打开页面的即时回调,页面一旦打开即回调
*/
- (void)open:(NSString *)url
urlParams:(NSDictionary *)urlParams
exts:(NSDictionary *)exts
completion:(void (^)(BOOL finished))completion;
/**
* 关闭页面
*
* @param uid 关闭的页面唯一ID符
* @param result 页面要返回的结果,open方法参数resultCallback的回调参数
* @param exts 额外参数
* @param completion 关闭页面的即时回调,页面一旦关闭即回调
*/
- (void)close:(NSString *)uid
result:(NSDictionary *)result
exts:(NSDictionary *)exts
completion:(void (^)(BOOL finished))completion;
@end
+ (void)startFlutterWithPlatform:(id<MagpiePlatform>)platform onStart:(void (^)(FlutterEngine *engine))callback;
platform需要遵循协议。
+ (BOOL)isRunning;
+ (void)sendEvent:(NSString *)eventName params:(NSDictionary *)params;
+ (void)obtainData:(NSString *)key params:(NSDictionary *)params completion:(FlutterResult )result;
+ (void)setDataRequestHandler:(MagpieCallBack)handler;
- (void)setLogHandler:(MagpieVoidCallBack)handler;
+ (FlutterViewController <MagpieContainer> *)flutterViewController;
+ (FlutterViewController <MagpieContainer> *)currentViewController;
+ (void)open:(NSString *)url urlParams:(NSDictionary *)urlParams exts:(NSDictionary *)exts onPageFinished:(void (^)(NSDictionary *result))resultCallback completion:(void (^)(BOOL finished))completion;
具体的路由操作需要由实现了MagpiePlatform协议的对象实施。
+ (void)close:(NSString *)uniqueId result:(NSDictionary *)resultData exts:(NSDictionary *)exts completion:(void (^)(BOOL finished))completion;
注册Module的类需要遵循协议。
MAGPIE_EXPORT_MODULE(name)
MAGPIE_EXPORT_METHOD(action)
@synthesize params;
@synthesize result;
+ (void)load{
[MagpieBridge registerModule:@"testModule" forClass:self];
}
- (void)magpie_action{
//Do Something
}
具体API的使用见DEMO