flutter/packages/flutter_tools/templates/plugin_cocoapods/ios-objc.tmpl/Classes/pluginClass.m.tmpl
Victoria Ashworth 5a63b1df95
Add create app and plugin templates for Swift Package Manager (#147082)
When Swift Package Manager feature is enabled, create app and create plugin will have Swift Package Manager integration already added and will not need to undergo a migration.

Fixes https://github.com/flutter/flutter/issues/146371.

```
flutter config --enable-swift-package-manager

flutter create --ios-language swift --platforms ios,macos swift_app_name

flutter create --ios-language objc --platforms ios objc_app_name

flutter create --template=plugin --ios-language swift --platforms ios,macos swift_plugin_name

flutter create --template=plugin --ios-language objc --platforms ios objc_plugin_name
```
2024-04-24 22:46:20 +00:00

21 lines
714 B
Cheetah

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