Ver código fonte

ios修改为swift

gaoyf 6 anos atrás
pai
commit
3d2b69d491

+ 2 - 14
ios/Classes/DubbingLibPlugin.m

@@ -1,20 +1,8 @@
 #import "DubbingLibPlugin.h"
+#import <dubbing_lib/dubbing_lib-Swift.h>
 
 @implementation DubbingLibPlugin
 + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
-  FlutterMethodChannel* channel = [FlutterMethodChannel
-      methodChannelWithName:@"dubbing_lib"
-            binaryMessenger:[registrar messenger]];
-  DubbingLibPlugin* instance = [[DubbingLibPlugin alloc] init];
-  [registrar addMethodCallDelegate:instance channel:channel];
+  [SwiftDubbingLibPlugin registerWithRegistrar:registrar];
 }
-
-- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
-  if ([@"getPlatformVersion" isEqualToString:call.method]) {
-    result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
-  } else {
-    result(FlutterMethodNotImplemented);
-  }
-}
-
 @end

+ 14 - 0
ios/Classes/SwiftDubbingLibPlugin.swift

@@ -0,0 +1,14 @@
+import Flutter
+import UIKit
+
+public class SwiftDubbingLibPlugin: NSObject, FlutterPlugin {
+  public static func register(with registrar: FlutterPluginRegistrar) {
+    let channel = FlutterMethodChannel(name: "dubbing_lib", binaryMessenger: registrar.messenger())
+    let instance = SwiftDubbingLibPlugin()
+    registrar.addMethodCallDelegate(instance, channel: channel)
+  }
+
+  public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
+    result("iOS " + UIDevice.current.systemVersion)
+  }
+}

+ 7 - 5
ios/dubbing_lib.podspec

@@ -1,12 +1,13 @@
 #
-# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
+# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
+# Run `pod lib lint dubbing_lib.podspec' to validate before publishing.
 #
 Pod::Spec.new do |s|
   s.name             = 'dubbing_lib'
   s.version          = '0.0.1'
-  s.summary          = 'A new Flutter plugin for dubbing'
+  s.summary          = 'A new Flutter plugin.'
   s.description      = <<-DESC
-A new Flutter plugin for dubbing
+A new Flutter plugin.
                        DESC
   s.homepage         = 'http://example.com'
   s.license          = { :file => '../LICENSE' }
@@ -15,7 +16,8 @@ A new Flutter plugin for dubbing
   s.source_files = 'Classes/**/*'
   s.public_header_files = 'Classes/**/*.h'
   s.dependency 'Flutter'
+  s.platform = :ios, '8.0'
 
-  s.ios.deployment_target = '8.0'
+  # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
+  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
 end
-