Skip to content

Commit b7b3b2a

Browse files
authored
Add support for macOS(Darwin) / Windows (#68)
* Update to use`sharedDarwinSource` in iOS * Renamed `iOS` to `darwin` * There doesn't seem to be any iOS-specific code. Therefore, by using shared Darwin (Apple) implementations, macOS can be easily supported. * Add support for macOS * Support for FlutterMacOS in Darwin * Fixed attempt to load `libwebcrypto.so` on macOS * Add macOS to example * Add support for Windows * Add windows plugin file * Add windows library path to `lookup.dart`
1 parent 68bc18f commit b7b3b2a

File tree

299 files changed

+3172
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+3172
-136
lines changed
File renamed without changes.
File renamed without changes.

ios/Classes/SwiftWebcryptoPlugin.swift renamed to darwin/Classes/SwiftWebcryptoPlugin.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,36 @@
1414
* limitations under the License.
1515
*/
1616

17+
#if os(iOS)
1718
import Flutter
18-
import UIKit
19+
#elseif os(macOS)
20+
import FlutterMacOS
21+
#endif
22+
23+
import Foundation
1924

2025
public class SwiftWebcryptoPlugin: NSObject, FlutterPlugin {
2126
public static func register(with registrar: FlutterPluginRegistrar) {
22-
let channel = FlutterMethodChannel(name: "webcrypto", binaryMessenger: registrar.messenger())
27+
#if os(iOS)
28+
let messenger = registrar.messenger()
29+
#else
30+
let messenger = registrar.messenger
31+
#endif
32+
33+
let channel = FlutterMethodChannel(name: "webcrypto", binaryMessenger: messenger)
2334
let instance = SwiftWebcryptoPlugin()
2435
registrar.addMethodCallDelegate(instance, channel: channel)
2536
}
2637

2738
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
28-
result("iOS " + UIDevice.current.systemVersion)
39+
#if os(iOS)
40+
let platform = "iOS "
41+
#elseif os(macOS)
42+
let platform = "macOS "
43+
#else
44+
let platform = "unknown "
45+
#endif
46+
47+
result(platform + ProcessInfo.processInfo.operatingSystemVersionString)
2948
}
3049
}

ios/Classes/WebcryptoPlugin.h renamed to darwin/Classes/WebcryptoPlugin.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import <Flutter/Flutter.h>
17+
#include <TargetConditionals.h>
18+
19+
#if TARGET_OS_IOS
20+
#import <Flutter/Flutter.h>
21+
#elif TARGET_OS_OSX
22+
#import <FlutterMacOS/FlutterMacOS.h>
23+
#endif
1824

1925
@interface WebcryptoPlugin : NSObject<FlutterPlugin>
2026
@end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)