Skip to content

Commit

Permalink
chore: iOS implements migration to protocol_handler_ios package
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Jan 28, 2024
1 parent ca97cb4 commit f59394a
Show file tree
Hide file tree
Showing 20 changed files with 257 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion packages/protocol_handler/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
16 changes: 8 additions & 8 deletions packages/protocol_handler/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
PODS:
- Flutter (1.0.0)
- protocol_handler (0.0.1):
- protocol_handler_ios (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- protocol_handler (from `.symlinks/plugins/protocol_handler/ios`)
- protocol_handler_ios (from `.symlinks/plugins/protocol_handler_ios/ios`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
protocol_handler:
:path: ".symlinks/plugins/protocol_handler/ios"
protocol_handler_ios:
:path: ".symlinks/plugins/protocol_handler_ios/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
protocol_handler: ae9efcf3b307f3fdffcd9d5252775b9f7d9f0d09
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
protocol_handler_ios: a5db8abc38526ee326988b808be621e5fd568990

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -421,7 +421,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -470,7 +470,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions packages/protocol_handler/macos/protocol_handler.podspec

This file was deleted.

3 changes: 2 additions & 1 deletion packages/protocol_handler/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ environment:
dependencies:
flutter:
sdk: flutter
protocol_handler_ios: ^0.2.0
protocol_handler_macos: ^0.2.0
protocol_handler_platform_interface: ^0.2.0
win32_registry: ^1.0.2
Expand All @@ -32,7 +33,7 @@ flutter:
package: org.leanflutter.plugins.protocol_handler
pluginClass: ProtocolHandlerPlugin
ios:
pluginClass: ProtocolHandlerPlugin
default_package: protocol_handler_ios
macos:
default_package: protocol_handler_macos
windows:
Expand Down
29 changes: 29 additions & 0 deletions packages/protocol_handler_ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/
30 changes: 30 additions & 0 deletions packages/protocol_handler_ios/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4"
channel: "stable"

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
- platform: ios
create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4
base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions packages/protocol_handler_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.2.0

* First release.
21 changes: 21 additions & 0 deletions packages/protocol_handler_ios/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-2024 LiJianying <lijy91@foxmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions packages/protocol_handler_ios/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# protocol_handler_ios

[![pub version][pub-image]][pub-url]

[pub-image]: https://img.shields.io/pub/v/protocol_handler_ios.svg
[pub-url]: https://pub.dev/packages/protocol_handler_ios

The iOS implementation of [protocol_handler](https://pub.dev/packages/protocol_handler).

## License

[MIT](./LICENSE)
1 change: 1 addition & 0 deletions packages/protocol_handler_ios/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:mostly_reasonable_lints/flutter.yaml
38 changes: 38 additions & 0 deletions packages/protocol_handler_ios/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.idea/
.vagrant/
.sconsign.dblite
.svn/

.DS_Store
*.swp
profile

DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m

.generated/

*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3

!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3

xcuserdata

*.moved-aside

*.pyc
*sync/
Icon?
.tags*

/Flutter/Generated.xcconfig
/Flutter/ephemeral/
/Flutter/flutter_export_environment.sh
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import Flutter
import UIKit

public class ProtocolHandlerIosPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
private var _eventSink: FlutterEventSink?

private var _initialUrl: String?

public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "dev.leanflutter.plugins/protocol_handler", binaryMessenger: registrar.messenger())
let instance = ProtocolHandlerIosPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
registrar.addApplicationDelegate(instance)
let eventChannel = FlutterEventChannel(name: "dev.leanflutter.plugins/protocol_handler_event", binaryMessenger: registrar.messenger())
eventChannel.setStreamHandler(instance)
}

public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
self._eventSink = events
return nil;
}

public func onCancel(withArguments arguments: Any?) -> FlutterError? {
self._eventSink = nil
return nil
}

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "getInitialUrl":
result(self._initialUrl ?? "");
break;
default:
result(FlutterMethodNotImplemented)
}
}

public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [AnyHashable : Any] = [:]) -> Bool {
let url: Any? = launchOptions[UIApplication.LaunchOptionsKey.url];
if (url != nil) {
self._initialUrl = (url as! URL).absoluteString
}
return true
}

public func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
guard let eventSink = self._eventSink else {
return false
}
eventSink(url.absoluteString)
return false
}
}
23 changes: 23 additions & 0 deletions packages/protocol_handler_ios/ios/protocol_handler_ios.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint protocol_handler_ios.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'protocol_handler_ios'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '11.0'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end
Loading

0 comments on commit f59394a

Please sign in to comment.