Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for macos #156

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if TARGET_OS_OSX
#import <FlutterMacOS/FlutterMacOS.h>
#else
#import <Flutter/Flutter.h>
#endif

@interface AmplitudeFlutterPlugin : NSObject<FlutterPlugin>
@end
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import Amplitude

#if os(iOS)
import Flutter
import UIKit
import Amplitude
#elseif os(macOS)
import FlutterMacOS
#endif

@objc public class SwiftAmplitudeFlutterPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "amplitude_flutter", binaryMessenger: registrar.messenger())
#if os(iOS)
let messenger = registrar.messenger()
#else
let messenger = registrar.messenger
#endif
let channel = FlutterMethodChannel(name: "amplitude_flutter", binaryMessenger: messenger)
let instance = SwiftAmplitudeFlutterPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ Pod::Spec.new do |s|
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.dependency 'Amplitude', '8.16.1'

s.ios.deployment_target = '10.0'
s.osx.deployment_target = '10.14'
end

4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ flutter:
pluginClass: AmplitudeFlutterPlugin
ios:
pluginClass: AmplitudeFlutterPlugin
sharedDarwinSource: true
macos:
pluginClass: AmplitudeFlutterPlugin
sharedDarwinSource: true
web:
pluginClass: AmplitudeFlutterPlugin
fileName: amplitude_web.dart