diff --git a/splitio/CONTRIBUTORS-GUIDE.md b/CONTRIBUTORS-GUIDE.md similarity index 100% rename from splitio/CONTRIBUTORS-GUIDE.md rename to CONTRIBUTORS-GUIDE.md diff --git a/splitio/example/ios/Podfile.lock b/splitio/example/ios/Podfile.lock index bd44637..38ef52f 100644 --- a/splitio/example/ios/Podfile.lock +++ b/splitio/example/ios/Podfile.lock @@ -1,13 +1,13 @@ PODS: - Flutter (1.0.0) - Split (2.15.0) - - splitio (0.1.0): + - splitio_ios (0.1.0): - Flutter - Split (~> 2.15.0) DEPENDENCIES: - Flutter (from `Flutter`) - - splitio (from `.symlinks/plugins/splitio/ios`) + - splitio_ios (from `.symlinks/plugins/splitio_ios/ios`) SPEC REPOS: trunk: @@ -16,13 +16,13 @@ SPEC REPOS: EXTERNAL SOURCES: Flutter: :path: Flutter - splitio: - :path: ".symlinks/plugins/splitio/ios" + splitio_ios: + :path: ".symlinks/plugins/splitio_ios/ios" SPEC CHECKSUMS: Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a Split: d103c6afa47b5d1eac21e066c6bc09c879b21798 - splitio: 6ef65e65e042489e9d30fe1f56abe9340bf69039 + splitio_ios: 665651004a4984a415386b1eed4ae315b50bc069 PODFILE CHECKSUM: 6ab177d3659abbf5f15e864674366127c98cb8c0 diff --git a/splitio/example/ios/Runner.xcodeproj/project.pbxproj b/splitio/example/ios/Runner.xcodeproj/project.pbxproj index ca1a98b..7f3b9bb 100644 --- a/splitio/example/ios/Runner.xcodeproj/project.pbxproj +++ b/splitio/example/ios/Runner.xcodeproj/project.pbxproj @@ -193,7 +193,7 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 030A5D79BA57E380D8657A73 /* [CP] Embed Pods Frameworks */, + 83B902C28BA5AB1DD426315E /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -212,7 +212,7 @@ C512775C2847F3D800B7D1A2 /* Sources */, C512775D2847F3D800B7D1A2 /* Frameworks */, C512775E2847F3D800B7D1A2 /* Resources */, - 8639C5B3E80E5EE46CFFE931 /* [CP] Embed Pods Frameworks */, + 456FD0F25BD4B27148539A17 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -285,23 +285,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 030A5D79BA57E380D8657A73 /* [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; - }; 06FEC5AC68198B8F6612EC6F /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -338,6 +321,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 456FD0F25BD4B27148539A17 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-SplitTests/Pods-SplitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-SplitTests/Pods-SplitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SplitTests/Pods-SplitTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 6EB34F8858EB9AEFDA66439B /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -360,21 +360,21 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 8639C5B3E80E5EE46CFFE931 /* [CP] Embed Pods Frameworks */ = { + 83B902C28BA5AB1DD426315E /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-SplitTests/Pods-SplitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + "${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-SplitTests/Pods-SplitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + "${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-SplitTests/Pods-SplitTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 9740EEB61CF901F6004384FC /* Run Script */ = { diff --git a/splitio/example/ios/SplitTests/ArgumentParserTests.swift b/splitio/example/ios/SplitTests/ArgumentParserTests.swift index 9b67744..dcdf716 100644 --- a/splitio/example/ios/SplitTests/ArgumentParserTests.swift +++ b/splitio/example/ios/SplitTests/ArgumentParserTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import splitio +@testable import splitio_ios class ArgumentParserTests: XCTestCase { diff --git a/splitio/example/ios/SplitTests/SplitClientConfigHelperTests.swift b/splitio/example/ios/SplitTests/SplitClientConfigHelperTests.swift index 6534c9f..69b43a5 100644 --- a/splitio/example/ios/SplitTests/SplitClientConfigHelperTests.swift +++ b/splitio/example/ios/SplitTests/SplitClientConfigHelperTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import splitio +@testable import splitio_ios class SplitClientConfigHelperTests: XCTestCase { diff --git a/splitio/example/ios/SplitTests/SplitMethodParserTests.swift b/splitio/example/ios/SplitTests/SplitMethodParserTests.swift index 7e65312..12fa488 100644 --- a/splitio/example/ios/SplitTests/SplitMethodParserTests.swift +++ b/splitio/example/ios/SplitTests/SplitMethodParserTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import splitio +@testable import splitio_ios @testable import Split class SplitMethodParserTests: XCTestCase { diff --git a/splitio/example/ios/SplitTests/SplitProviderHelperTests.swift b/splitio/example/ios/SplitTests/SplitProviderHelperTests.swift index e9269fd..4de13ea 100644 --- a/splitio/example/ios/SplitTests/SplitProviderHelperTests.swift +++ b/splitio/example/ios/SplitTests/SplitProviderHelperTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import splitio +@testable import splitio_ios @testable import Split class SplitProviderHelperTests: XCTestCase { diff --git a/splitio/example/ios/SplitTests/SplitTests.swift b/splitio/example/ios/SplitTests/SplitTests.swift index 217e792..d94c831 100644 --- a/splitio/example/ios/SplitTests/SplitTests.swift +++ b/splitio/example/ios/SplitTests/SplitTests.swift @@ -1,5 +1,5 @@ import XCTest -@testable import splitio +@testable import splitio_ios @testable import Split class SplitTests: XCTestCase { diff --git a/splitio/example/pubspec.lock b/splitio/example/pubspec.lock index a216ab7..9c2f871 100644 --- a/splitio/example/pubspec.lock +++ b/splitio/example/pubspec.lock @@ -142,6 +142,13 @@ packages: relative: true source: path version: "0.1.2" + splitio_ios: + dependency: transitive + description: + path: "../../splitio_ios" + relative: true + source: path + version: "0.1.2" splitio_platform_interface: dependency: transitive description: diff --git a/splitio/pubspec.yaml b/splitio/pubspec.yaml index 87f2500..bd23fb1 100644 --- a/splitio/pubspec.yaml +++ b/splitio/pubspec.yaml @@ -14,15 +14,17 @@ flutter: android: default_package: splitio_android ios: - pluginClass: SplitioPlugin + default_package: splitio_ios dependencies: flutter: sdk: flutter splitio_platform_interface: # ^1.0.0 path: ../splitio_platform_interface - splitio_android: # ^1.0.0 + splitio_android: # ^0.1.2 path: ../splitio_android + splitio_ios: # ^0.1.2 + path: ../splitio_ios dev_dependencies: flutter_test: diff --git a/splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java b/splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java index 6cc5c2c..372c399 100644 --- a/splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java +++ b/splitio_android/android/src/main/java/io/split/splitio/SplitioPlugin.java @@ -23,7 +23,7 @@ public class SplitioPlugin implements FlutterPlugin, MethodCallHandler { @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { - channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "splitio.io/splitio_android"); + channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "split.io/splitio_android"); channel.setMethodCallHandler(this); SplitFactoryProvider provider = getSplitFactoryProvider(flutterPluginBinding.getApplicationContext()); methodParser = new SplitMethodParserImpl(flutterPluginBinding.getApplicationContext(), channel, provider); diff --git a/splitio_android/lib/splitio_android.dart b/splitio_android/lib/splitio_android.dart index 78cd29f..bdffa45 100644 --- a/splitio_android/lib/splitio_android.dart +++ b/splitio_android/lib/splitio_android.dart @@ -1,8 +1,7 @@ import 'package:flutter/services.dart'; import 'package:splitio_platform_interface/splitio_platform_interface.dart'; -const MethodChannel _methodChannel = - MethodChannel('splitio.io/splitio_android'); +const MethodChannel _methodChannel = MethodChannel('split.io/splitio_android'); /// Implementation for Android of [SplitioPlatform]. class SplitioAndroid extends MethodChannelPlatform { diff --git a/splitio_android/test/splitio_android_test.dart b/splitio_android/test/splitio_android_test.dart index e33332e..308d056 100644 --- a/splitio_android/test/splitio_android_test.dart +++ b/splitio_android/test/splitio_android_test.dart @@ -4,7 +4,7 @@ import 'package:splitio_android/splitio_android.dart'; import 'package:splitio_platform_interface/split_configuration.dart'; void main() { - const MethodChannel _channel = MethodChannel('splitio.io/splitio_android'); + const MethodChannel _channel = MethodChannel('split.io/splitio_android'); String methodName = ''; dynamic methodArguments; diff --git a/splitio_ios/.gitignore b/splitio_ios/.gitignore new file mode 100644 index 0000000..9be145f --- /dev/null +++ b/splitio_ios/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# 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/ +.packages +build/ diff --git a/splitio_ios/CHANGELOG.md b/splitio_ios/CHANGELOG.md new file mode 100644 index 0000000..cd0d685 --- /dev/null +++ b/splitio_ios/CHANGELOG.md @@ -0,0 +1,3 @@ +# 0.1.2 + +Splits from `splitio` as federated implementation. diff --git a/splitio_ios/LICENSE b/splitio_ios/LICENSE new file mode 100644 index 0000000..20e4bd8 --- /dev/null +++ b/splitio_ios/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/splitio_ios/README.md b/splitio_ios/README.md new file mode 100644 index 0000000..20af48e --- /dev/null +++ b/splitio_ios/README.md @@ -0,0 +1,11 @@ +# splitio\_android + +The iOS implementation of [`splitio`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `splitio` +normally. This package will be automatically included in your app when you do. + +[1]: https://pub.dev/packages/splitio +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin diff --git a/splitio_ios/analysis_options.yaml b/splitio_ios/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/splitio_ios/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/splitio/ios/.gitignore b/splitio_ios/ios/.gitignore similarity index 100% rename from splitio/ios/.gitignore rename to splitio_ios/ios/.gitignore diff --git a/splitio/ios/Assets/.gitkeep b/splitio_ios/ios/Assets/.gitkeep similarity index 100% rename from splitio/ios/Assets/.gitkeep rename to splitio_ios/ios/Assets/.gitkeep diff --git a/splitio/ios/Classes/ArgumentParser.swift b/splitio_ios/ios/Classes/ArgumentParser.swift similarity index 100% rename from splitio/ios/Classes/ArgumentParser.swift rename to splitio_ios/ios/Classes/ArgumentParser.swift diff --git a/splitio/ios/Classes/Constants.swift b/splitio_ios/ios/Classes/Constants.swift similarity index 100% rename from splitio/ios/Classes/Constants.swift rename to splitio_ios/ios/Classes/Constants.swift diff --git a/splitio/ios/Classes/Extensions.swift b/splitio_ios/ios/Classes/Extensions.swift similarity index 100% rename from splitio/ios/Classes/Extensions.swift rename to splitio_ios/ios/Classes/Extensions.swift diff --git a/splitio/ios/Classes/SplitClientConfigHelper.swift b/splitio_ios/ios/Classes/SplitClientConfigHelper.swift similarity index 100% rename from splitio/ios/Classes/SplitClientConfigHelper.swift rename to splitio_ios/ios/Classes/SplitClientConfigHelper.swift diff --git a/splitio/ios/Classes/SplitFactoryProvider.swift b/splitio_ios/ios/Classes/SplitFactoryProvider.swift similarity index 100% rename from splitio/ios/Classes/SplitFactoryProvider.swift rename to splitio_ios/ios/Classes/SplitFactoryProvider.swift diff --git a/splitio/ios/Classes/SplitMethodParser.swift b/splitio_ios/ios/Classes/SplitMethodParser.swift similarity index 100% rename from splitio/ios/Classes/SplitMethodParser.swift rename to splitio_ios/ios/Classes/SplitMethodParser.swift diff --git a/splitio/ios/Classes/SplitWrapper.swift b/splitio_ios/ios/Classes/SplitWrapper.swift similarity index 100% rename from splitio/ios/Classes/SplitWrapper.swift rename to splitio_ios/ios/Classes/SplitWrapper.swift diff --git a/splitio/ios/Classes/SplitioPlugin.h b/splitio_ios/ios/Classes/SplitioPlugin.h similarity index 100% rename from splitio/ios/Classes/SplitioPlugin.h rename to splitio_ios/ios/Classes/SplitioPlugin.h diff --git a/splitio/ios/Classes/SplitioPlugin.m b/splitio_ios/ios/Classes/SplitioPlugin.m similarity index 77% rename from splitio/ios/Classes/SplitioPlugin.m rename to splitio_ios/ios/Classes/SplitioPlugin.m index 68beac7..0b18eab 100644 --- a/splitio/ios/Classes/SplitioPlugin.m +++ b/splitio_ios/ios/Classes/SplitioPlugin.m @@ -1,11 +1,11 @@ #import "SplitioPlugin.h" -#if __has_include() -#import +#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 "splitio-Swift.h" +#import "splitio_ios-Swift.h" #endif @implementation SplitioPlugin diff --git a/splitio/ios/Classes/SwiftSplitioPlugin.swift b/splitio_ios/ios/Classes/SwiftSplitioPlugin.swift similarity index 87% rename from splitio/ios/Classes/SwiftSplitioPlugin.swift rename to splitio_ios/ios/Classes/SwiftSplitioPlugin.swift index 659b2d3..30df9c7 100644 --- a/splitio/ios/Classes/SwiftSplitioPlugin.swift +++ b/splitio_ios/ios/Classes/SwiftSplitioPlugin.swift @@ -6,7 +6,7 @@ public class SwiftSplitioPlugin: NSObject, FlutterPlugin { private var methodParser: SplitMethodParser? public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "splitio", binaryMessenger: registrar.messenger()) + let channel = FlutterMethodChannel(name: "split.io/splitio_ios", binaryMessenger: registrar.messenger()) let instance = SwiftSplitioPlugin() let externalProvider: SplitFactoryProvider? = UIApplication.shared.delegate as? SplitFactoryProvider instance.methodParser = DefaultSplitMethodParser(methodChannel: channel, splitFactoryProvider: externalProvider) diff --git a/splitio/ios/splitio.podspec b/splitio_ios/ios/splitio_ios.podspec similarity index 87% rename from splitio/ios/splitio.podspec rename to splitio_ios/ios/splitio_ios.podspec index d501394..6999409 100644 --- a/splitio/ios/splitio.podspec +++ b/splitio_ios/ios/splitio_ios.podspec @@ -1,9 +1,9 @@ # # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint splitio.podspec` to validate before publishing. +# Run `pod lib lint splitio_ios.podspec` to validate before publishing. # Pod::Spec.new do |s| - s.name = 'splitio' + s.name = 'splitio_ios' s.version = '0.1.0' s.summary = 'split.io official Flutter plugin.' s.description = <<-DESC diff --git a/splitio_ios/lib/splitio_ios.dart b/splitio_ios/lib/splitio_ios.dart new file mode 100644 index 0000000..3d4c812 --- /dev/null +++ b/splitio_ios/lib/splitio_ios.dart @@ -0,0 +1,15 @@ +import 'package:flutter/services.dart'; +import 'package:splitio_platform_interface/splitio_platform_interface.dart'; + +const MethodChannel _methodChannel = MethodChannel('split.io/splitio_ios'); + +/// Implementation for iOS of [SplitioPlatform]. +class SplitioIOS extends MethodChannelPlatform { + /// Registers this class as the default platform implementation. + static void registerWith() { + SplitioPlatform.instance = SplitioIOS(); + } + + @override + MethodChannel get methodChannel => _methodChannel; +} diff --git a/splitio_ios/pubspec.yaml b/splitio_ios/pubspec.yaml new file mode 100644 index 0000000..9cbd442 --- /dev/null +++ b/splitio_ios/pubspec.yaml @@ -0,0 +1,28 @@ +name: splitio_ios +description: The official Android implementation of splitio Flutter plugin. +repository: https://github.com/splitio/flutter-sdk-plugin/splitio/splitio_ios +version: 0.1.2 +publish_to: 'none' + +environment: + sdk: ">=2.16.2 <3.0.0" + flutter: ">=2.5.0" + +flutter: + plugin: + implements: splitio + platforms: + ios: + pluginClass: SwiftSplitioPlugin + dartPluginClass: SplitioIOS + +dependencies: + flutter: + sdk: flutter + splitio_platform_interface: # ^1.0.0 + path: ../splitio_platform_interface + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 diff --git a/splitio_ios/test/splitio_ios_test.dart b/splitio_ios/test/splitio_ios_test.dart new file mode 100644 index 0000000..a68a007 --- /dev/null +++ b/splitio_ios/test/splitio_ios_test.dart @@ -0,0 +1,515 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:splitio_ios/splitio_ios.dart'; +import 'package:splitio_platform_interface/split_configuration.dart'; + +void main() { + const MethodChannel _channel = MethodChannel('split.io/splitio_ios'); + + String methodName = ''; + dynamic methodArguments; + + TestWidgetsFlutterBinding.ensureInitialized(); + + SplitioIOS _platform = SplitioIOS(); + + void _simulateMethodInvocation(String methodName, + {String key = 'key', + String? bucketingKey, + Map? arguments}) { + arguments ??= {}; + arguments.addAll({'matchingKey': key, 'bucketingKey': bucketingKey}); + _channel.invokeMethod(methodName, arguments); + } + + setUp(() { + _channel.setMockMethodCallHandler((MethodCall methodCall) async { + methodName = methodCall.method; + methodArguments = methodCall.arguments; + + _platform.handle(methodCall); + switch (methodCall.method) { + case 'getTreatment': + return ''; + case 'getTreatments': + return {'split1': 'on', 'split2': 'off'}; + case 'getTreatmentsWithConfig': + return { + 'split1': {'treatment': 'on', 'config': null}, + 'split2': {'treatment': 'off', 'config': null} + }; + case 'track': + return true; + case 'getAttribute': + return true; + case 'getAllAttributes': + return { + 'attr_1': true, + 'attr_2': ['list-element'], + 'attr_3': 28.20 + }; + case 'setAttribute': + case 'setAttributes': + case 'removeAttribute': + case 'clearAttributes': + return true; + } + }); + }); + + group('evaluation', () { + test('getTreatment without attributes', () async { + _platform.getTreatment( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split'); + + expect(methodName, 'getTreatment'); + expect(methodArguments, { + 'splitName': 'split', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatment with attributes', () async { + _platform.getTreatment( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split', + attributes: {'attr1': true}); + + expect(methodName, 'getTreatment'); + expect(methodArguments, { + 'splitName': 'split', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatments without attributes', () async { + _platform.getTreatments( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2']); + + expect(methodName, 'getTreatments'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatments with attributes', () async { + _platform.getTreatments( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2'], + attributes: {'attr1': true}); + + expect(methodName, 'getTreatments'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentWithConfig with attributes', () async { + _platform.getTreatmentWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split1', + attributes: {'attr1': true}); + + expect(methodName, 'getTreatmentWithConfig'); + expect(methodArguments, { + 'splitName': 'split1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + + test('getTreatmentWithConfig without attributes', () async { + _platform.getTreatmentWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitName: 'split1'); + + expect(methodName, 'getTreatmentWithConfig'); + expect(methodArguments, { + 'splitName': 'split1', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsWithConfig without attributes', () async { + _platform.getTreatmentsWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2']); + + expect(methodName, 'getTreatmentsWithConfig'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {} + }); + }); + + test('getTreatmentsWithConfig with attributes', () async { + _platform.getTreatmentsWithConfig( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + splitNames: ['split1', 'split2'], + attributes: {'attr1': true}); + + expect(methodName, 'getTreatmentsWithConfig'); + expect(methodArguments, { + 'splitName': ['split1', 'split2'], + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': {'attr1': true} + }); + }); + }); + + group('track', () { + test('track with traffic type & value', () async { + _platform.track( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + eventType: 'my_event', + trafficType: 'my_traffic_type', + value: 25.10); + expect(methodName, 'track'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'eventType': 'my_event', + 'trafficType': 'my_traffic_type', + 'value': 25.10 + }); + }); + + test('track with value', () async { + _platform.track( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + eventType: 'my_event', + value: 25.10); + expect(methodName, 'track'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'eventType': 'my_event', + 'value': 25.10 + }); + }); + + test('track with traffic type', () async { + _platform.track( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + eventType: 'my_event', + trafficType: 'my_traffic_type'); + expect(methodName, 'track'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'eventType': 'my_event', + 'trafficType': 'my_traffic_type', + }); + }); + }); + + group('attributes', () { + test('get single attribute', () async { + _platform.getAttribute( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributeName: 'attribute-name'); + expect(methodName, 'getAttribute'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributeName': 'attribute-name', + }); + }); + + test('get all attributes', () async { + _platform.getAllAttributes( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'getAllAttributes'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + + test('set attribute', () async { + _platform.setAttribute( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributeName: 'my_attr', + value: 'attr_value'); + expect(methodName, 'setAttribute'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributeName': 'my_attr', + 'value': 'attr_value', + }); + }); + + test('set multiple attributes', () async { + _platform.setAttributes( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributes: { + 'bool_attr': true, + 'number_attr': 25.56, + 'string_attr': 'attr-value', + 'list_attr': ['one', 'two'], + }); + expect(methodName, 'setAttributes'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributes': { + 'bool_attr': true, + 'number_attr': 25.56, + 'string_attr': 'attr-value', + 'list_attr': ['one', 'two'], + } + }); + }); + + test('remove attribute', () async { + _platform.removeAttribute( + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + attributeName: 'attr-name'); + expect(methodName, 'removeAttribute'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'attributeName': 'attr-name', + }); + }); + + test('clear attributes', () async { + _platform.clearAttributes( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'clearAttributes'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + + test('flush', () async { + _platform.flush( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'flush'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + + test('destroy', () async { + _platform.destroy( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + expect(methodName, 'destroy'); + expect(methodArguments, { + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + }); + }); + }); + + group('initialization', () { + test('init with matching key only', () { + _platform.init( + apiKey: 'api-key', matchingKey: 'matching-key', bucketingKey: null); + + expect(methodName, 'init'); + expect(methodArguments, { + 'apiKey': 'api-key', + 'matchingKey': 'matching-key', + 'sdkConfiguration': {} + }); + }); + + test('init with bucketing key', () { + _platform.init( + apiKey: 'api-key', + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key'); + expect(methodName, 'init'); + expect(methodArguments, { + 'apiKey': 'api-key', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'sdkConfiguration': {} + }); + }); + + test('init with config', () { + _platform.init( + apiKey: 'api-key', + matchingKey: 'matching-key', + bucketingKey: 'bucketing-key', + sdkConfiguration: + SplitConfiguration(enableDebug: true, streamingEnabled: false)); + expect(methodName, 'init'); + expect(methodArguments, { + 'apiKey': 'api-key', + 'matchingKey': 'matching-key', + 'bucketingKey': 'bucketing-key', + 'sdkConfiguration': {'enableDebug': true, 'streamingEnabled': false}, + }); + }); + }); + + group('client', () { + test('get client with no keys', () { + _platform.getClient(matchingKey: 'matching-key', bucketingKey: null); + + expect(methodName, 'getClient'); + expect(methodArguments, {'matchingKey': 'matching-key'}); + }); + + test('get client with new matching key', () { + _platform.getClient(matchingKey: 'new-matching-key', bucketingKey: null); + + expect(methodName, 'getClient'); + expect(methodArguments, {'matchingKey': 'new-matching-key'}); + }); + + test('get client with new matching key and bucketing key', () { + _platform.getClient( + matchingKey: 'new-matching-key', bucketingKey: 'bucketing-key'); + + expect(methodName, 'getClient'); + expect(methodArguments, + {'matchingKey': 'new-matching-key', 'bucketingKey': 'bucketing-key'}); + }); + }); + + group('manager', () { + test('get split names', () { + _platform.splitNames(); + + expect(methodName, 'splitNames'); + }); + + test('get splits', () { + _platform.splits(); + + expect(methodName, 'splits'); + }); + + test('get split', () { + _platform.split(splitName: 'my_split'); + + expect(methodName, 'split'); + expect(methodArguments, {'splitName': 'my_split'}); + }); + }); + + group('events', () { + test('onReady', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onReady = _platform + .onReady(matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.then((value) => true); + + _simulateMethodInvocation('clientReady', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onReady, completion(equals(true))); + }); + + test('onReadyFromCache', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onReadyFromCache = _platform + .onReadyFromCache( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.then((value) => true); + + _simulateMethodInvocation('clientReadyFromCache', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onReadyFromCache, completion(equals(true))); + }); + + test('onTimeout', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onTimeout = _platform + .onTimeout(matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.then((value) => true); + + _simulateMethodInvocation('clientTimeout', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onTimeout, completion(equals(true))); + }); + + test('onUpdated', () { + _platform.getClient( + matchingKey: 'matching-key', bucketingKey: 'bucketing-key'); + + Future? onUpdated = _platform + .onUpdated(matchingKey: 'matching-key', bucketingKey: 'bucketing-key') + ?.first + .then((value) => true); + + _simulateMethodInvocation('clientUpdated', + key: 'matching-key', bucketingKey: 'bucketing-key'); + + expect(onUpdated, completion(equals(true))); + }); + }); + + test('impressions', () { + _platform.impressionsStream().listen( + expectAsync1((impression) { + expect(impression.key, 'key'); + expect(impression.bucketingKey, null); + expect(impression.split, 'split'); + expect(impression.treatment, 'treatment'); + expect(impression.time, 3000); + expect(impression.appliedRule, 'appliedRule'); + expect(impression.changeNumber, 200); + expect(impression.attributes, {}); + }), + ); + _simulateMethodInvocation('impressionLog', key: 'matching-key', arguments: { + 'key': 'key', + 'bucketingKey': 'bucketingKey', + 'split': 'split', + 'treatment': 'treatment', + 'time': 3000, + 'appliedRule': 'appliedRule', + 'changeNumber': 200, + 'attributes': {} + }); + }); +}