From ac99c45043f0f639850cea745430d2f8b8179267 Mon Sep 17 00:00:00 2001 From: Yakov Manshin Date: Mon, 17 May 2021 09:59:31 +0300 Subject: [PATCH 1/3] [#63] CocoaPods Support (#64) * Created `YMFF.podspec` to support YMFF installation via CocoaPods * Updated sources to support both SPM and CocoaPods * Added podspec linting on CI * Updated `README` with CocoaPods installation instructions --- .../workflows/{spm-ci.yml => run-tests.yml} | 16 +++++-- README.md | 11 +++++ Sources/YMFF/FeatureFlag/FeatureFlag.swift | 2 + .../FeatureFlagResolverConfiguration.swift | 2 + .../FeatureFlagResolver.swift | 2 + .../Store/RuntimeOverridesStore.swift | 2 + .../Store/TransparentFeatureFlagStore.swift | 2 + .../Store/UserDefaultsStore.swift | 2 + .../YMFFTests/FeatureFlagResolverTests.swift | 2 + Tests/YMFFTests/FeatureFlagTests.swift | 2 + Tests/YMFFTests/MutableStoreTests.swift | 2 + .../RuntimeOverridesStoreTests.swift | 2 + .../YMFFTests/SharedAssets/SharedAssets.swift | 2 + YMFF.podspec | 48 +++++++++++++++++++ 14 files changed, 93 insertions(+), 4 deletions(-) rename .github/workflows/{spm-ci.yml => run-tests.yml} (62%) create mode 100644 YMFF.podspec diff --git a/.github/workflows/spm-ci.yml b/.github/workflows/run-tests.yml similarity index 62% rename from .github/workflows/spm-ci.yml rename to .github/workflows/run-tests.yml index f23a63b..aac4fcb 100644 --- a/.github/workflows/spm-ci.yml +++ b/.github/workflows/run-tests.yml @@ -1,9 +1,10 @@ -name: SPM CI +name: Run Tests on: [pull_request, push] jobs: - macos-test: + + spm-macos-test: runs-on: macos-11.0 steps: - uses: actions/checkout@v2 @@ -11,10 +12,17 @@ jobs: run: sudo xcode-select -switch /Applications/Xcode_12.5.app - name: Run tests run: swift test -v - - linux-test: + + spm-linux-test: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - name: Run tests run: swift test -v + + cocoapods-podspec-lint: + runs-on: macos-11.0 + steps: + - uses: actions/checkout@v2 + - name: Lint Podspec + run: pod lib lint --verbose diff --git a/README.md b/README.md index 8cfb9e2..03e48b2 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ YMFF is a nice little library that makes management of features with feature fla YMFF ships completely ready for use, right out of the box: you get everything you need to start in just a few minutes. But you can also replace nearly any component of the system with your own, customized implementation. Since version 2.0, the implementation and the protocols are in two separate targets (YMFF and YMFFProtocols, respectively). ## Installation + +### Swift Package Manager (SPM) To add YMFF to your project, use Xcode’s built-in support for Swift packages. Click File → Swift Packages → Add Package Dependency, and paste the following URL into the search field: ``` @@ -23,6 +25,15 @@ If you need to use YMFF in another Swift package, add it as a dependency: .package(url: "https://github.com/yakovmanshin/YMFF", .upToNextMajor(from: "2.0.0")) ``` +### CocoaPods +YMFF now supports installation via [CocoaPods](https://youtu.be/iEAjvNRdZa0). + +Add the following to your Podfile: + +```ruby +pod 'YMFF', '~> 2.1' +``` + ## Setup All you need to start managing features with YMFF is at least one feature flag *store*—an object which conforms to `FeatureFlagStoreProtocol` and provides values that correspond to feature flag keys. diff --git a/Sources/YMFF/FeatureFlag/FeatureFlag.swift b/Sources/YMFF/FeatureFlag/FeatureFlag.swift index db22edb..9b94591 100644 --- a/Sources/YMFF/FeatureFlag/FeatureFlag.swift +++ b/Sources/YMFF/FeatureFlag/FeatureFlag.swift @@ -6,7 +6,9 @@ // Copyright © 2020 Yakov Manshin. See the LICENSE file for license info. // +#if !COCOAPODS import YMFFProtocols +#endif /// An object that facilitates access to feature flag values. @propertyWrapper diff --git a/Sources/YMFF/FeatureFlagResolver/Configuration/FeatureFlagResolverConfiguration.swift b/Sources/YMFF/FeatureFlagResolver/Configuration/FeatureFlagResolverConfiguration.swift index c71a981..a2b9ace 100644 --- a/Sources/YMFF/FeatureFlagResolver/Configuration/FeatureFlagResolverConfiguration.swift +++ b/Sources/YMFF/FeatureFlagResolver/Configuration/FeatureFlagResolverConfiguration.swift @@ -6,7 +6,9 @@ // Copyright © 2020 Yakov Manshin. See the LICENSE file for license info. // +#if !COCOAPODS import YMFFProtocols +#endif // MARK: - FeatureFlagResolverConfiguration diff --git a/Sources/YMFF/FeatureFlagResolver/FeatureFlagResolver.swift b/Sources/YMFF/FeatureFlagResolver/FeatureFlagResolver.swift index e1f007c..bd92dde 100644 --- a/Sources/YMFF/FeatureFlagResolver/FeatureFlagResolver.swift +++ b/Sources/YMFF/FeatureFlagResolver/FeatureFlagResolver.swift @@ -6,7 +6,9 @@ // Copyright © 2020 Yakov Manshin. See the LICENSE file for license info. // +#if !COCOAPODS import YMFFProtocols +#endif // MARK: - FeatureFlagResolver diff --git a/Sources/YMFF/FeatureFlagResolver/Store/RuntimeOverridesStore.swift b/Sources/YMFF/FeatureFlagResolver/Store/RuntimeOverridesStore.swift index 80c7316..7845346 100644 --- a/Sources/YMFF/FeatureFlagResolver/Store/RuntimeOverridesStore.swift +++ b/Sources/YMFF/FeatureFlagResolver/Store/RuntimeOverridesStore.swift @@ -6,7 +6,9 @@ // Copyright © 2020 Yakov Manshin. See the LICENSE file for license info. // +#if !COCOAPODS import YMFFProtocols +#endif // MARK: - RuntimeOverridesStore diff --git a/Sources/YMFF/FeatureFlagResolver/Store/TransparentFeatureFlagStore.swift b/Sources/YMFF/FeatureFlagResolver/Store/TransparentFeatureFlagStore.swift index 54f962f..d2a32e0 100644 --- a/Sources/YMFF/FeatureFlagResolver/Store/TransparentFeatureFlagStore.swift +++ b/Sources/YMFF/FeatureFlagResolver/Store/TransparentFeatureFlagStore.swift @@ -6,7 +6,9 @@ // Copyright © 2020 Yakov Manshin. See the LICENSE file for license info. // +#if !COCOAPODS import YMFFProtocols +#endif // MARK: - TransparentFeatureFlagStore diff --git a/Sources/YMFF/FeatureFlagResolver/Store/UserDefaultsStore.swift b/Sources/YMFF/FeatureFlagResolver/Store/UserDefaultsStore.swift index e9dcb76..5bb5ec0 100644 --- a/Sources/YMFF/FeatureFlagResolver/Store/UserDefaultsStore.swift +++ b/Sources/YMFF/FeatureFlagResolver/Store/UserDefaultsStore.swift @@ -9,7 +9,9 @@ #if canImport(Foundation) import Foundation +#if !COCOAPODS import YMFFProtocols +#endif // MARK: - UserDefaultsStore diff --git a/Tests/YMFFTests/FeatureFlagResolverTests.swift b/Tests/YMFFTests/FeatureFlagResolverTests.swift index 5c0410a..d5fb020 100644 --- a/Tests/YMFFTests/FeatureFlagResolverTests.swift +++ b/Tests/YMFFTests/FeatureFlagResolverTests.swift @@ -7,7 +7,9 @@ // import XCTest +#if !COCOAPODS import YMFFProtocols +#endif @testable import YMFF // MARK: - Configuration diff --git a/Tests/YMFFTests/FeatureFlagTests.swift b/Tests/YMFFTests/FeatureFlagTests.swift index ee7e91c..a51a3f9 100644 --- a/Tests/YMFFTests/FeatureFlagTests.swift +++ b/Tests/YMFFTests/FeatureFlagTests.swift @@ -7,7 +7,9 @@ // import XCTest +#if !COCOAPODS import YMFFProtocols +#endif @testable import YMFF // MARK: - Configuration diff --git a/Tests/YMFFTests/MutableStoreTests.swift b/Tests/YMFFTests/MutableStoreTests.swift index a1f46f3..14bb3cf 100644 --- a/Tests/YMFFTests/MutableStoreTests.swift +++ b/Tests/YMFFTests/MutableStoreTests.swift @@ -7,7 +7,9 @@ // import XCTest +#if !COCOAPODS import YMFFProtocols +#endif @testable import YMFF diff --git a/Tests/YMFFTests/RuntimeOverridesStoreTests.swift b/Tests/YMFFTests/RuntimeOverridesStoreTests.swift index 8c1f607..9c6430b 100644 --- a/Tests/YMFFTests/RuntimeOverridesStoreTests.swift +++ b/Tests/YMFFTests/RuntimeOverridesStoreTests.swift @@ -7,7 +7,9 @@ // import XCTest +#if !COCOAPODS import YMFFProtocols +#endif @testable import YMFF // MARK: - Configuration diff --git a/Tests/YMFFTests/SharedAssets/SharedAssets.swift b/Tests/YMFFTests/SharedAssets/SharedAssets.swift index adb5e34..27b9c5f 100644 --- a/Tests/YMFFTests/SharedAssets/SharedAssets.swift +++ b/Tests/YMFFTests/SharedAssets/SharedAssets.swift @@ -7,7 +7,9 @@ // import YMFF +#if !COCOAPODS import YMFFProtocols +#endif // MARK: - Shared diff --git a/YMFF.podspec b/YMFF.podspec new file mode 100644 index 0000000..a1b4d66 --- /dev/null +++ b/YMFF.podspec @@ -0,0 +1,48 @@ +Pod::Spec.new do |s| + + # Basic Info + + s.name = "YMFF" + s.version = "2.1.0" + s.summary = "Feature management made easy." + + s.description = <<-DESC + YMFF is a nice little library that makes management of features + with feature flags—and management of the feature flags themselves—a bliss. + DESC + + s.homepage = "https://github.com/yakovmanshin/YMFF" + s.documentation_url = "https://opensource.ym.dev/YMFF/" + + s.license = { :type => "Apache License, version 2.0", :file => "LICENSE" } + + s.author = { "Yakov Manshin" => "contact@yakovmanshin.com" } + s.social_media_url = "https://github.com/yakovmanshin" + + # Sources & Build Settings + + s.source = { :git => "https://github.com/yakovmanshin/YMFF.git", :tag => "#{s.version}" } + + s.swift_version = "5.3" + s.osx.deployment_target = "10.13" + s.ios.deployment_target = "11.0" + + # Subspecs + + s.default_subspec = "YMFF" + + s.subspec "YMFF" do |is| + is.source_files = "Sources/YMFF/**/*.{swift}" + is.dependency "YMFF/YMFFProtocols" + end + + s.subspec "YMFFProtocols" do |ps| + ps.source_files = "Sources/YMFFProtocols/**/*.{swift}" + end + + s.test_spec "Tests" do |ts| + ts.source_files = "Tests/YMFFTests/**/*.{swift}" + ts.dependency "YMFF/YMFF" + end + +end From aaa19086a3d27b87920482ebc59bb3489d077a9a Mon Sep 17 00:00:00 2001 From: Yakov Manshin Date: Mon, 17 May 2021 10:01:28 +0300 Subject: [PATCH 2/3] Updated Imports in Tests --- Tests/YMFFTests/FeatureFlagResolverTests.swift | 1 + Tests/YMFFTests/FeatureFlagTests.swift | 1 + Tests/YMFFTests/RuntimeOverridesStoreTests.swift | 1 + Tests/YMFFTests/UserDefaultsStoreTests.swift | 1 + 4 files changed, 4 insertions(+) diff --git a/Tests/YMFFTests/FeatureFlagResolverTests.swift b/Tests/YMFFTests/FeatureFlagResolverTests.swift index d5fb020..a597f05 100644 --- a/Tests/YMFFTests/FeatureFlagResolverTests.swift +++ b/Tests/YMFFTests/FeatureFlagResolverTests.swift @@ -10,6 +10,7 @@ import XCTest #if !COCOAPODS import YMFFProtocols #endif + @testable import YMFF // MARK: - Configuration diff --git a/Tests/YMFFTests/FeatureFlagTests.swift b/Tests/YMFFTests/FeatureFlagTests.swift index a51a3f9..2e05230 100644 --- a/Tests/YMFFTests/FeatureFlagTests.swift +++ b/Tests/YMFFTests/FeatureFlagTests.swift @@ -10,6 +10,7 @@ import XCTest #if !COCOAPODS import YMFFProtocols #endif + @testable import YMFF // MARK: - Configuration diff --git a/Tests/YMFFTests/RuntimeOverridesStoreTests.swift b/Tests/YMFFTests/RuntimeOverridesStoreTests.swift index 9c6430b..9375783 100644 --- a/Tests/YMFFTests/RuntimeOverridesStoreTests.swift +++ b/Tests/YMFFTests/RuntimeOverridesStoreTests.swift @@ -10,6 +10,7 @@ import XCTest #if !COCOAPODS import YMFFProtocols #endif + @testable import YMFF // MARK: - Configuration diff --git a/Tests/YMFFTests/UserDefaultsStoreTests.swift b/Tests/YMFFTests/UserDefaultsStoreTests.swift index 0720a71..ee44373 100644 --- a/Tests/YMFFTests/UserDefaultsStoreTests.swift +++ b/Tests/YMFFTests/UserDefaultsStoreTests.swift @@ -9,6 +9,7 @@ #if canImport(Foundation) import XCTest + @testable import YMFF final class UserDefaultsStoreTests: XCTestCase { From 93d45697e9cfe75036ab6787e9135de3456b7e10 Mon Sep 17 00:00:00 2001 From: Yakov Manshin Date: Mon, 17 May 2021 10:10:46 +0300 Subject: [PATCH 3/3] [#65] Removed Redundant Linux Test Manifest (#66) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Explicit listing of Linux tests is no longer required: “tests are automatically discovered on all platforms” --- Tests/LinuxMain.swift | 8 --- Tests/YMFFTests/XCTestManifests.swift | 91 --------------------------- 2 files changed, 99 deletions(-) delete mode 100644 Tests/LinuxMain.swift delete mode 100644 Tests/YMFFTests/XCTestManifests.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 7e97d46..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,8 +0,0 @@ -import XCTest - -import YMFFTests - -var tests = [XCTestCaseEntry]() -tests += YMFFTests.__allTests() - -XCTMain(tests) diff --git a/Tests/YMFFTests/XCTestManifests.swift b/Tests/YMFFTests/XCTestManifests.swift deleted file mode 100644 index 6769494..0000000 --- a/Tests/YMFFTests/XCTestManifests.swift +++ /dev/null @@ -1,91 +0,0 @@ -#if !canImport(ObjectiveC) -import XCTest - -extension FeatureFlagResolverTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__FeatureFlagResolverTests = [ - ("testIfValueIsOptional", testIfValueIsOptional), - ("testIntValueResolution", testIntValueResolution), - ("testNonexistentValueResolution", testNonexistentValueResolution), - ("testOptionalIntValueResolution", testOptionalIntValueResolution), - ("testOverrideFailureNoMutableStores", testOverrideFailureNoMutableStores), - ("testOverrideFailureTypeMismatch", testOverrideFailureTypeMismatch), - ("testOverrideForNewKeys", testOverrideForNewKeys), - ("testOverrideRemovalFailureNoMutableStoreContainsValue", testOverrideRemovalFailureNoMutableStoreContainsValue), - ("testOverrideSuccess", testOverrideSuccess), - ("testOverrideValueValidationFailureOptional", testOverrideValueValidationFailureOptional), - ("testOverrideValueValidationFailureTypeMismatch", testOverrideValueValidationFailureTypeMismatch), - ("testOverrideValueValidationSuccess", testOverrideValueValidationSuccess), - ("testStringValueResolution", testStringValueResolution), - ("testValueRetrieval", testValueRetrieval), - ("testValueRetrievalFromEmptyStoresArray", testValueRetrievalFromEmptyStoresArray), - ("testValueValidation", testValueValidation), - ] -} - -extension FeatureFlagTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__FeatureFlagTests = [ - ("testBoolProjectedValue", testBoolProjectedValue), - ("testBoolWrappedValue", testBoolWrappedValue), - ("testIntProjectedValue", testIntProjectedValue), - ("testIntWrappedValue", testIntWrappedValue), - ("testNonexistentIntProjectedValue", testNonexistentIntProjectedValue), - ("testNonexistentIntWrappedValue", testNonexistentIntWrappedValue), - ("testNonexistentWrappedValueOverride", testNonexistentWrappedValueOverride), - ("testOptionalIntProjectedValue", testOptionalIntProjectedValue), - ("testOptionalIntValue", testOptionalIntValue), - ("testStringProjectedValue", testStringProjectedValue), - ("testStringWrappedValue", testStringWrappedValue), - ("testWrappedValueOverride", testWrappedValueOverride), - ] -} - -extension MutableStoreTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MutableStoreTests = [ - ("testChangeSaving", testChangeSaving), - ("testOverride", testOverride), - ("testOverrideRemoval", testOverrideRemoval), - ] -} - -extension RuntimeOverridesStoreTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__RuntimeOverridesStoreTests = [ - ("testRuntimeOverride", testRuntimeOverride), - ("testRuntimeOverrideRemoval", testRuntimeOverrideRemoval), - ] -} - -extension UserDefaultsStoreTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__UserDefaultsStoreTests = [ - ("testChangeSaving", testChangeSaving), - ("testReadValueWithResolver", testReadValueWithResolver), - ("testRemoveValueWithResolver", testRemoveValueWithResolver), - ("testWriteAndReadValueWithResolver", testWriteAndReadValueWithResolver), - ("testWriteValueWithResolver", testWriteValueWithResolver), - ] -} - -public func __allTests() -> [XCTestCaseEntry] { - return [ - testCase(FeatureFlagResolverTests.__allTests__FeatureFlagResolverTests), - testCase(FeatureFlagTests.__allTests__FeatureFlagTests), - testCase(MutableStoreTests.__allTests__MutableStoreTests), - testCase(RuntimeOverridesStoreTests.__allTests__RuntimeOverridesStoreTests), - testCase(UserDefaultsStoreTests.__allTests__UserDefaultsStoreTests), - ] -} -#endif