diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6bb8291 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,32 @@ +name: Publish to pub.dev + +on: + release: + types: [published] + +jobs: + publish: + name: Publish package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: subosito/flutter-action@v2 + with: + flutter-version: '3.x' + channel: stable + + - name: Install dependencies + run: flutter pub get + + - name: Verify package + run: flutter pub publish --dry-run + + - name: Publish to pub.dev + env: + PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }} + run: | + mkdir -p ~/.config/dart + echo "$PUB_CREDENTIALS" > ~/.config/dart/pub-credentials.json + flutter pub publish --force \ No newline at end of file diff --git a/.gitignore b/.gitignore index c031f78..553f933 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ .pub/ build/ +.build/ +.swiftpm/ **/*.settings **/*.project **/*.classpath \ No newline at end of file diff --git a/.pubignore b/.pubignore new file mode 100644 index 0000000..8ec0d70 --- /dev/null +++ b/.pubignore @@ -0,0 +1,2 @@ +# Exclude old iOS class files that are tracked in git but no longer used +ios/Classes/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cc7d8..63ca232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,42 @@ +## 0.2.0 + +* Add Swift Package Manager (SPM) support for iOS. +* Prepare package for pub.dev publication (SDK constraint, CHANGELOG, .pubignore). + +## 0.1.5 + +* Fix unmanaged runLoopSource memory issue on iOS (backward compatibility with Xcode 15). +* Upgrade Android compileSdkVersion, add namespace, update Gradle plugin version. +* Use built-in constants for ProxyDict on iOS. + +## 0.1.4 + +* Add Xcode 16 support and fix compiler warnings. + +## 0.1.3 + +* Add namespace in Android build.gradle. + +## 0.1.2 + +* Fix iOS 17 proxy resolution issue. +* Fix crash when PAC file URL is invalid. + +## 0.1.1 + +* Minor fixes and stability improvements. + +## 0.1.0 + +* Use Android ProxySelector instead of environment variables for more reliable proxy detection. +* Use Foundation library for executing PAC scripts on iOS. +* Remove print statements; clean up code. + +## 0.0.2 + +* Disable proxy when fetching PAC file to avoid circular dependency. +* Update example app. + ## 0.0.1 -* TODO: Describe initial release. +* Initial release: detect system HTTP proxy on Android and iOS. \ No newline at end of file diff --git a/README.md b/README.md index 41149f2..30820c0 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,23 @@ A Flutter Plugin to detect System proxy. When using HTTP client that are not pro ### Installation +Add `flutter_system_proxy` to your `pubspec.yaml`: + ```yaml dependencies: - ... - flutter_system_proxy: - git: - url: https://github.com/BrowserStackCE/flutter_system_proxy.git - ref: main + flutter_system_proxy: ^0.2.0 +``` +Then run: + +```sh +flutter pub get +``` + +Alternatively, install from the command line: + +```sh +flutter pub add flutter_system_proxy ``` ### Basic Usage (Example With Dio) @@ -73,4 +82,4 @@ void getDio(){ return dio; } -``` +``` \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 7c56964..391a902 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1.0 - MinimumOSVersion - 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 2c068c4..10f3c9b 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '12.0' +platform :ios, '13.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 99a28d8..a0f79f2 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,22 +1,16 @@ PODS: - Flutter (1.0.0) - - flutter_system_proxy (0.0.1): - - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - - flutter_system_proxy (from `.symlinks/plugins/flutter_system_proxy/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter - flutter_system_proxy: - :path: ".symlinks/plugins/flutter_system_proxy/ios" SPEC CHECKSUMS: - Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_system_proxy: 96eb97e3857a1d1bc533a6f7387a1f0dcb63d782 + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 -PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 +PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b -COCOAPODS: 1.15.2 +COCOAPODS: 1.17.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 5723d28..fd1bd26 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,13 +3,14 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 60; objects = { /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 9501647E4D309C13C164EDC6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A8063015380F7AC9FFAAAD7E /* Pods_Runner.framework */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; @@ -37,6 +38,9 @@ 3D695DD80D4DCA36C1B83028 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 784666492D4C4C64000A1A5F /* FlutterFramework */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterFramework; path = Flutter/ephemeral/Packages/.packages/FlutterFramework; sourceTree = ""; }; + 78DABEA22ED26510000E7860 /* flutter_system_proxy */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = flutter_system_proxy; path = ../../ios/flutter_system_proxy; sourceTree = ""; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; @@ -54,6 +58,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, 9501647E4D309C13C164EDC6 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -82,6 +87,9 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 78DABEA22ED26510000E7860 /* flutter_system_proxy */, + 784666492D4C4C64000A1A5F /* FlutterFramework */, + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, @@ -138,13 +146,15 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 5972F2044B3398F3D4E6F225 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); productName = Runner; productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; @@ -173,6 +183,9 @@ Base, ); mainGroup = 97C146E51CF9000F007C117D; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, + ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; projectRoot = ""; @@ -213,23 +226,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 5972F2044B3398F3D4E6F225 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 83B088A8360721351FA1EFBC /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -342,7 +338,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -358,7 +354,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 58NJ4M43R4; + DEVELOPMENT_TEAM = 3FY8FKGN3A; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -420,7 +416,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -469,7 +465,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -486,7 +482,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 58NJ4M43R4; + DEVELOPMENT_TEAM = 3FY8FKGN3A; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -509,7 +505,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 58NJ4M43R4; + DEVELOPMENT_TEAM = 3FY8FKGN3A; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -548,6 +544,20 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index e67b280..2c3563b 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index b636303..c30b367 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -1,13 +1,16 @@ -import UIKit import Flutter +import UIKit @main -@objc class AppDelegate: FlutterAppDelegate { +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } } diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index c2e3ae8..b1e54b3 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -24,6 +24,27 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + UIApplicationSupportsIndirectInputEvents UILaunchStoryboardName diff --git a/example/pubspec.lock b/example/pubspec.lock index fbdf565..2e901d6 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -21,26 +21,26 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.1" cupertino_icons: dependency: "direct main" description: @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.3" flutter: dependency: "direct main" description: flutter @@ -76,7 +76,7 @@ packages: path: ".." relative: true source: path - version: "0.1.4" + version: "0.1.5" flutter_test: dependency: "direct dev" description: flutter @@ -94,63 +94,63 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" matcher: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.19" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" path: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -163,18 +163,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" string_scanner: dependency: transitive description: @@ -195,10 +195,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.11" typed_data: dependency: transitive description: @@ -211,10 +211,10 @@ packages: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: @@ -224,5 +224,5 @@ packages: source: hosted version: "14.2.5" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.10.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/ios/Classes/FlutterSystemProxyPlugin.h b/ios/Classes/FlutterSystemProxyPlugin.h deleted file mode 100644 index 364fdaf..0000000 --- a/ios/Classes/FlutterSystemProxyPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface FlutterSystemProxyPlugin : NSObject -@end diff --git a/ios/Classes/FlutterSystemProxyPlugin.m b/ios/Classes/FlutterSystemProxyPlugin.m deleted file mode 100644 index ad3b96b..0000000 --- a/ios/Classes/FlutterSystemProxyPlugin.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "FlutterSystemProxyPlugin.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_system_proxy-Swift.h" -#endif - -@implementation FlutterSystemProxyPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftFlutterSystemProxyPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/ios/flutter_system_proxy.podspec b/ios/flutter_system_proxy.podspec index a0446fb..618376d 100644 --- a/ios/flutter_system_proxy.podspec +++ b/ios/flutter_system_proxy.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'flutter_system_proxy' - s.version = '0.0.1' + s.version = '0.1.5' s.summary = 'A new flutter plugin project.' s.description = <<-DESC A new flutter plugin project. @@ -13,9 +13,9 @@ A new flutter plugin project. s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + s.source_files = 'flutter_system_proxy/Sources/flutter_system_proxy/**/*.swift' s.dependency 'Flutter' - s.platform = :ios, '8.0' + s.platform = :ios, '12.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/ios/flutter_system_proxy/Package.swift b/ios/flutter_system_proxy/Package.swift new file mode 100644 index 0000000..fab3ffc --- /dev/null +++ b/ios/flutter_system_proxy/Package.swift @@ -0,0 +1,24 @@ +// swift-tools-version: 5.9 +import PackageDescription + +let package = Package( + name: "flutter_system_proxy", + platforms: [.iOS("12.0")], + products: [ + .library(name: "flutter-system-proxy", targets: ["flutter_system_proxy"]) + ], + dependencies: [ + .package(name: "FlutterFramework", path: "../FlutterFramework") + ], + targets: [ + .target( + name: "flutter_system_proxy", + dependencies: [ + .product(name: "FlutterFramework", package: "FlutterFramework") + ], + linkerSettings: [ + .linkedFramework("CFNetwork") + ] + ) + ] +) diff --git a/ios/Classes/SwiftFlutterSystemProxyPlugin.swift b/ios/flutter_system_proxy/Sources/flutter_system_proxy/FlutterSystemProxyPlugin.swift similarity index 71% rename from ios/Classes/SwiftFlutterSystemProxyPlugin.swift rename to ios/flutter_system_proxy/Sources/flutter_system_proxy/FlutterSystemProxyPlugin.swift index 9cf3783..0facfad 100644 --- a/ios/Classes/SwiftFlutterSystemProxyPlugin.swift +++ b/ios/flutter_system_proxy/Sources/flutter_system_proxy/FlutterSystemProxyPlugin.swift @@ -1,31 +1,33 @@ +import CFNetwork import Flutter import UIKit -import JavaScriptCore -public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin { +public class FlutterSystemProxyPlugin: NSObject, FlutterPlugin { static var proxyCache : [String: [String: Any]] = [:] - + private static var cachedProxySettingsSignature: String? + public static func register(with registrar: FlutterPluginRegistrar) { let channel = FlutterMethodChannel(name: "flutter_system_proxy", binaryMessenger: registrar.messenger()) - let instance = SwiftFlutterSystemProxyPlugin() + let instance = FlutterSystemProxyPlugin() registrar.addMethodCallDelegate(instance, channel: channel) } public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { switch call.method { case "getDeviceProxy": + FlutterSystemProxyPlugin.invalidateCacheIfProxySettingsChanged() let args = call.arguments as! NSDictionary let url = args.value(forKey:"url") as! String var dict:[String:Any]? = [:] - if(SwiftFlutterSystemProxyPlugin.proxyCache[url] != nil){ - let res = SwiftFlutterSystemProxyPlugin.proxyCache[url] + if(FlutterSystemProxyPlugin.proxyCache[url] != nil){ + let res = FlutterSystemProxyPlugin.proxyCache[url] if(res != nil){ dict = res } } else { - let res = SwiftFlutterSystemProxyPlugin.resolve(url: url) + let res = FlutterSystemProxyPlugin.resolve(url: url) if(res != nil){ dict = res } @@ -38,8 +40,8 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin { } static func resolve(url:String)->[String:Any]?{ - if(SwiftFlutterSystemProxyPlugin.proxyCache[url] != nil){ - return SwiftFlutterSystemProxyPlugin.proxyCache[url] + if(FlutterSystemProxyPlugin.proxyCache[url] != nil){ + return FlutterSystemProxyPlugin.proxyCache[url] } let proxConfigDict = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() as NSDictionary? if proxConfigDict != nil { @@ -55,10 +57,10 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin { var dict: [String: Any] = [:] dict["host"] = proxConfigDict![kCFNetworkProxiesHTTPProxy] as? String dict["port"] = proxConfigDict![kCFNetworkProxiesHTTPPort] as? Int - SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict + FlutterSystemProxyPlugin.proxyCache[url] = dict } } - return SwiftFlutterSystemProxyPlugin.proxyCache[url] + return FlutterSystemProxyPlugin.proxyCache[url] } static func handlePacContent(pacContent: String,url: String){ @@ -71,7 +73,7 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin { var dict:[String: Any] = [:] dict["host"] = host dict["port"] = port - SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict + FlutterSystemProxyPlugin.proxyCache[url] = dict } } } @@ -93,7 +95,7 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin { dict["host"] = host dict["port"] = port let url = client.assumingMemoryBound(to: String.self).pointee - SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict + FlutterSystemProxyPlugin.proxyCache[url] = dict } } CFRunLoopStop(CFRunLoopGetCurrent()); @@ -113,6 +115,30 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin { return runLoopSource as! CFRunLoopSource } } - -} + private static func invalidateCacheIfProxySettingsChanged() { + let signature = proxySettingsSignature() + if cachedProxySettingsSignature != signature { + proxyCache.removeAll(keepingCapacity: true) + cachedProxySettingsSignature = signature + } + } + + private static func proxySettingsSignature() -> String { + guard let settings = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() as? NSDictionary else { + return "" + } + + let signatureComponents: [Any] = [ + settings[kCFNetworkProxiesProxyAutoConfigEnable] ?? NSNull(), + settings[kCFNetworkProxiesProxyAutoConfigURLString] ?? NSNull(), + settings[kCFNetworkProxiesProxyAutoConfigJavaScript] ?? NSNull(), + settings[kCFNetworkProxiesHTTPEnable] ?? NSNull(), + settings[kCFNetworkProxiesHTTPProxy] ?? NSNull(), + settings[kCFNetworkProxiesHTTPPort] ?? NSNull(), + ] + + return signatureComponents.map { String(describing: $0) }.joined(separator: "\u{1F}") + } + +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index df9b838..7beb0b1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,34 +21,34 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.1" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.3" flutter: dependency: "direct main" description: flutter @@ -63,63 +63,63 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" matcher: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.19" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" path: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -132,18 +132,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" string_scanner: dependency: transitive description: @@ -164,18 +164,18 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.11" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: @@ -185,5 +185,5 @@ packages: source: hosted version: "14.2.5" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.10.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index 8de951d..1d0ec52 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: flutter_system_proxy description: A Flutter Plugin to detect System proxy. When using HTTP client that are not proxy aware this plugin can help with finding the proxy from system settings which then can be used with HTTP Client to make a successful request. -version: 0.1.5 +version: 0.2.0 homepage: https://github.com/BrowserStackCE/flutter_system_proxy.git environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" flutter: ">=1.20.0" dependencies: @@ -22,4 +22,4 @@ flutter: package: com.browserstack.fluttersystemproxy.flutter_system_proxy pluginClass: FlutterSystemProxyPlugin ios: - pluginClass: FlutterSystemProxyPlugin + pluginClass: FlutterSystemProxyPlugin \ No newline at end of file