From 74f97bd618dd0ddfe3d9d1b07be927027da8f95e Mon Sep 17 00:00:00 2001 From: Konstantin Wachendorff Date: Thu, 24 Nov 2022 18:16:37 +0100 Subject: [PATCH] fix for ios --- example/ios/Flutter/Debug.xcconfig | 1 + example/ios/Flutter/Release.xcconfig | 1 + example/ios/Podfile | 41 +++++++++++++++++++ example/pubspec.lock | 24 +++++------ ios/Classes/AppVersionCheckerPlugin.h | 4 -- ios/Classes/AppVersionCheckerPlugin.m | 15 ------- ios/Classes/FlutterAppVersionCheckerPlugin.h | 4 ++ ios/Classes/FlutterAppVersionCheckerPlugin.m | 15 +++++++ ...SwiftFlutterAppVersionCheckerPlugin.swift} | 6 +-- ...ec => flutter_app_version_checker.podspec} | 4 +- pubspec.lock | 24 +++++------ pubspec.yaml | 2 +- 12 files changed, 92 insertions(+), 49 deletions(-) create mode 100644 example/ios/Podfile delete mode 100644 ios/Classes/AppVersionCheckerPlugin.h delete mode 100644 ios/Classes/AppVersionCheckerPlugin.m create mode 100644 ios/Classes/FlutterAppVersionCheckerPlugin.h create mode 100644 ios/Classes/FlutterAppVersionCheckerPlugin.m rename ios/Classes/{SwiftAppVersionCheckerPlugin.swift => SwiftFlutterAppVersionCheckerPlugin.swift} (55%) rename ios/{app_version_checker.podspec => flutter_app_version_checker.podspec} (84%) diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..88359b2 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '11.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/pubspec.lock b/example/pubspec.lock index e4d619c..260ca29 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -127,21 +127,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" package_info_plus: dependency: transitive description: @@ -190,7 +190,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" plugin_platform_interface: dependency: transitive description: @@ -209,7 +209,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -230,21 +230,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: diff --git a/ios/Classes/AppVersionCheckerPlugin.h b/ios/Classes/AppVersionCheckerPlugin.h deleted file mode 100644 index a7db41f..0000000 --- a/ios/Classes/AppVersionCheckerPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface AppVersionCheckerPlugin : NSObject -@end diff --git a/ios/Classes/AppVersionCheckerPlugin.m b/ios/Classes/AppVersionCheckerPlugin.m deleted file mode 100644 index 2f028be..0000000 --- a/ios/Classes/AppVersionCheckerPlugin.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "AppVersionCheckerPlugin.h" -#if __has_include() -#import -#else -// Support project import fallback if the generated compatibility header -// is not copied when this plugin is created as a library. -// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 -#import "app_version_checker-Swift.h" -#endif - -@implementation AppVersionCheckerPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftAppVersionCheckerPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/ios/Classes/FlutterAppVersionCheckerPlugin.h b/ios/Classes/FlutterAppVersionCheckerPlugin.h new file mode 100644 index 0000000..f6bdc37 --- /dev/null +++ b/ios/Classes/FlutterAppVersionCheckerPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface FlutterAppVersionCheckerPlugin : NSObject +@end diff --git a/ios/Classes/FlutterAppVersionCheckerPlugin.m b/ios/Classes/FlutterAppVersionCheckerPlugin.m new file mode 100644 index 0000000..7af93cc --- /dev/null +++ b/ios/Classes/FlutterAppVersionCheckerPlugin.m @@ -0,0 +1,15 @@ +#import "FlutterAppVersionCheckerPlugin.h" +#if __has_include() +#import +#else +// Support project import fallback if the generated compatibility header +// is not copied when this plugin is created as a library. +// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 +#import "flutter_app_version_checker-Swift.h" +#endif + +@implementation FlutterAppVersionCheckerPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + [SwiftFlutterAppVersionCheckerPlugin registerWithRegistrar:registrar]; +} +@end diff --git a/ios/Classes/SwiftAppVersionCheckerPlugin.swift b/ios/Classes/SwiftFlutterAppVersionCheckerPlugin.swift similarity index 55% rename from ios/Classes/SwiftAppVersionCheckerPlugin.swift rename to ios/Classes/SwiftFlutterAppVersionCheckerPlugin.swift index 65e17ae..0818c5f 100644 --- a/ios/Classes/SwiftAppVersionCheckerPlugin.swift +++ b/ios/Classes/SwiftFlutterAppVersionCheckerPlugin.swift @@ -1,10 +1,10 @@ import Flutter import UIKit -public class SwiftAppVersionCheckerPlugin: NSObject, FlutterPlugin { +public class SwiftFlutterAppVersionCheckerPlugin: NSObject, FlutterPlugin { public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "app_version_checker", binaryMessenger: registrar.messenger()) - let instance = SwiftAppVersionCheckerPlugin() + let channel = FlutterMethodChannel(name: "flutter_app_version_checker", binaryMessenger: registrar.messenger()) + let instance = SwiftFlutterAppVersionCheckerPlugin() registrar.addMethodCallDelegate(instance, channel: channel) } diff --git a/ios/app_version_checker.podspec b/ios/flutter_app_version_checker.podspec similarity index 84% rename from ios/app_version_checker.podspec rename to ios/flutter_app_version_checker.podspec index 98fd210..85b7a04 100644 --- a/ios/app_version_checker.podspec +++ b/ios/flutter_app_version_checker.podspec @@ -1,9 +1,9 @@ # # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint app_version_checker.podspec` to validate before publishing. +# Run `pod lib lint flutter_app_version_checker.podspec` to validate before publishing. # Pod::Spec.new do |s| - s.name = 'app_version_checker' + s.name = 'flutter_app_version_checker' s.version = '0.0.1' s.summary = 'A new Flutter project.' s.description = <<-DESC diff --git a/pubspec.lock b/pubspec.lock index a599ba2..49132f5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" charcode: dependency: transitive description: @@ -35,7 +35,7 @@ packages: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" ffi: dependency: transitive description: @@ -113,21 +113,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" package_info_plus: dependency: "direct main" description: @@ -176,7 +176,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" plugin_platform_interface: dependency: transitive description: @@ -195,7 +195,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -216,21 +216,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 361ed8f..1c68ecc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,7 +33,7 @@ flutter: package: com.example.app_version_checker pluginClass: AppVersionCheckerPlugin ios: - pluginClass: AppVersionCheckerPlugin + pluginClass: FlutterAppVersionCheckerPlugin # To add assets to your plugin package, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg