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 ```
This commit is contained in:
committed by
GitHub
parent
d85571b46b
commit
5a63b1df95
@@ -1,4 +0,0 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface {{pluginClass}} : NSObject<FlutterPlugin>
|
||||
@end
|
||||
@@ -1,20 +0,0 @@
|
||||
#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
|
||||
@@ -13,8 +13,14 @@ Pod::Spec.new do |s|
|
||||
s.license = { :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
{{#withSwiftPackageManager}}
|
||||
s.source_files = '{{projectName}}/Sources/{{projectName}}/**/*'
|
||||
s.public_header_files = '{{projectName}}/Sources/{{projectName}}/include/{{projectName}}/**/*.h'
|
||||
{{/withSwiftPackageManager}}
|
||||
{{^withSwiftPackageManager}}
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
{{/withSwiftPackageManager}}
|
||||
s.dependency 'Flutter'
|
||||
s.platform = :ios, '12.0'
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
public class {{pluginClass}}: NSObject, FlutterPlugin {
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: "{{projectName}}", binaryMessenger: registrar.messenger())
|
||||
let instance = {{pluginClass}}()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
}
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "getPlatformVersion":
|
||||
result("iOS " + UIDevice.current.systemVersion)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,12 @@ Pod::Spec.new do |s|
|
||||
s.license = { :file => '../LICENSE' }
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
{{#withSwiftPackageManager}}
|
||||
s.source_files = '{{projectName}}/Sources/{{projectName}}/**/*'
|
||||
{{/withSwiftPackageManager}}
|
||||
{{^withSwiftPackageManager}}
|
||||
s.source_files = 'Classes/**/*'
|
||||
{{/withSwiftPackageManager}}
|
||||
s.dependency 'Flutter'
|
||||
s.platform = :ios, '12.0'
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
|
||||
public class {{pluginClass}}: NSObject, FlutterPlugin {
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: "{{projectName}}", binaryMessenger: registrar.messenger)
|
||||
let instance = {{pluginClass}}()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
}
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "getPlatformVersion":
|
||||
result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user