Skip to content

Commit

Permalink
refactor(ios): replace FeatureFlagsService with swift-utilities Featu…
Browse files Browse the repository at this point in the history
…reFlagsService
  • Loading branch information
autoreleasefool committed May 20, 2024
1 parent 3eca943 commit 813bdc9
Show file tree
Hide file tree
Showing 30 changed files with 88 additions and 730 deletions.
7 changes: 0 additions & 7 deletions ios/Approach.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
CAD15BBB29FDF8E40015E4CB /* GamesRepository in Frameworks */ = {isa = PBXBuildFile; productRef = CAD15BBA29FDF8E40015E4CB /* GamesRepository */; };
CAD15BC129FDFF890015E4CB /* TestDatabaseUtilitiesLibrary in Frameworks */ = {isa = PBXBuildFile; productRef = CAD15BC029FDFF890015E4CB /* TestDatabaseUtilitiesLibrary */; };
CAECBAEB2ABD7323007713A8 /* LanesRepository in Frameworks */ = {isa = PBXBuildFile; productRef = CAECBAEA2ABD7323007713A8 /* LanesRepository */; };
CAF80290295D67FC00B19459 /* FeatureFlagsService in Frameworks */ = {isa = PBXBuildFile; productRef = CAF8028F295D67FC00B19459 /* FeatureFlagsService */; };
CAFF2FCB2AB19B3000AE31BF /* AvatarService in Frameworks */ = {isa = PBXBuildFile; productRef = CAFF2FCA2AB19B3000AE31BF /* AvatarService */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -144,7 +143,6 @@
CA626E2F2A842032002BCC13 /* TipsService in Frameworks */,
CA5952BB2A1FF51D0002494C /* StatisticsRepository in Frameworks */,
CAA3D74D29CFB48D00876EDC /* BowlersRepository in Frameworks */,
CAF80290295D67FC00B19459 /* FeatureFlagsService in Frameworks */,
CA318B402999E1F500BD4BEC /* AnalyticsService in Frameworks */,
CAC56853291F54A100192D12 /* RecentlyUsedService in Frameworks */,
);
Expand Down Expand Up @@ -304,7 +302,6 @@
CA2890DD28F87FF2003C1EE9 /* AppFeature */,
CAC56850291F54A100192D12 /* PreferenceService */,
CAC56852291F54A100192D12 /* RecentlyUsedService */,
CAF8028F295D67FC00B19459 /* FeatureFlagsService */,
CA318B3F2999E1F500BD4BEC /* AnalyticsService */,
CA681DED29B94BE900535750 /* AvatarService */,
CABEC0CE29CBF9CD003CF669 /* AddressLookupService */,
Expand Down Expand Up @@ -717,10 +714,6 @@
isa = XCSwiftPackageProductDependency;
productName = LanesRepository;
};
CAF8028F295D67FC00B19459 /* FeatureFlagsService */ = {
isa = XCSwiftPackageProductDependency;
productName = FeatureFlagsService;
};
CAFF2FCA2AB19B3000AE31BF /* AvatarService */ = {
isa = XCSwiftPackageProductDependency;
productName = AvatarService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"location" : "https://github.com/autoreleasefool/swift-utilities.git",
"state" : {
"branch" : "main",
"revision" : "8b406f005b27805742dfb2eee653f11e76a7d499"
"revision" : "da6794300b2f41ec925e3982def20b425626d41d"
}
},
{
Expand Down
46 changes: 10 additions & 36 deletions ios/Approach/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ let package = Package(
.library(name: "DatabaseServiceInterface", targets: ["DatabaseServiceInterface"]),
.library(name: "EmailService", targets: ["EmailService"]),
.library(name: "EmailServiceInterface", targets: ["EmailServiceInterface"]),
.library(name: "FeatureFlagsService", targets: ["FeatureFlagsService"]),
.library(name: "FeatureFlagsServiceInterface", targets: ["FeatureFlagsServiceInterface"]),
.library(name: "ImportExportService", targets: ["ImportExportService"]),
.library(name: "ImportExportServiceInterface", targets: ["ImportExportServiceInterface"]),
.library(name: "LaunchService", targets: ["LaunchService"]),
Expand Down Expand Up @@ -223,7 +221,7 @@ let package = Package(
name: "AlleysListFeature",
dependencies: [
"AlleyEditorFeature",
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"ResourceListLibrary",
]
),
Expand Down Expand Up @@ -256,6 +254,7 @@ let package = Package(
.product(name: "AnalyticsPackageService", package: "swift-utilities"),
.product(name: "AppInfoPackageService", package: "swift-utilities"),
.product(name: "BundlePackageService", package: "swift-utilities"),
.product(name: "FeatureFlagsPackageService", package: "swift-utilities"),
.product(name: "FileManagerPackageService", package: "swift-utilities"),
.product(name: "PasteboardPackageService", package: "swift-utilities"),
.product(name: "SentryErrorReportingPackageService", package: "swift-utilities"),
Expand Down Expand Up @@ -372,7 +371,7 @@ let package = Package(
dependencies: [
"AnalyticsServiceInterface",
"FeatureActionLibrary",
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"LoggingServiceInterface",
"StringsLibrary",
]
Expand Down Expand Up @@ -402,7 +401,7 @@ let package = Package(
dependencies: [
.product(name: "StoreReviewPackageServiceInterface", package: "swift-utilities"),
"AvatarServiceInterface",
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"FramesRepositoryInterface",
"GearRepositoryInterface",
"LanesRepositoryInterface",
Expand Down Expand Up @@ -572,7 +571,7 @@ let package = Package(
.target(
name: "OpponentsListFeature",
dependencies: [
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"ModelsViewsLibrary",
"OpponentDetailsFeature",
"RecentlyUsedServiceInterface",
Expand Down Expand Up @@ -605,7 +604,7 @@ let package = Package(
dependencies: [
"AlleysRepositoryInterface",
"DateTimeLibrary",
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"FormFeature",
"ModelsViewsLibrary",
"PickableModelsLibrary",
Expand Down Expand Up @@ -1053,7 +1052,7 @@ let package = Package(
dependencies: [
.product(name: "UserDefaultsPackageServiceInterface", package: "swift-utilities"),
"DatabaseServiceInterface",
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"PreferenceServiceInterface",
"RepositoryLibrary",
"StatisticsModelsLibrary",
Expand Down Expand Up @@ -1260,27 +1259,6 @@ let package = Package(
"EmailService",
]
),
.target(
name: "FeatureFlagsService",
dependencies: [
.product(name: "UserDefaultsPackageServiceInterface", package: "swift-utilities"),
"FeatureFlagsServiceInterface",
]
),
.target(
name: "FeatureFlagsServiceInterface",
dependencies: [
.product(name: "Dependencies", package: "swift-dependencies"),
"FeatureFlagsLibrary",
]
),
.testTarget(
name: "FeatureFlagsServiceTests",
dependencies: [
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"FeatureFlagsService",
]
),
.target(
name: "ImportExportService",
dependencies: [
Expand Down Expand Up @@ -1310,7 +1288,7 @@ let package = Package(
.product(name: "StoreReviewPackageServiceInterface", package: "swift-utilities"),
.product(name: "UserDefaultsPackageServiceInterface", package: "swift-utilities"),
"AnalyticsServiceInterface",
"FeatureFlagsServiceInterface",
"FeatureFlagsLibrary",
"LaunchServiceInterface",
"PreferenceServiceInterface",
"ProductsServiceInterface",
Expand Down Expand Up @@ -1561,13 +1539,9 @@ let package = Package(
),
.target(
name: "FeatureFlagsLibrary",
dependencies: []
),
.testTarget(
name: "FeatureFlagsLibraryTests",
dependencies: [
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"FeatureFlagsLibrary",
.product(name: "FeatureFlagsPackageLibrary", package: "swift-utilities"),
.product(name: "FeatureFlagsPackageServiceInterface", package: "swift-utilities"),
]
),
.target(
Expand Down
41 changes: 23 additions & 18 deletions ios/Approach/Package.swift.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ supported = [ "\"17.0\"" ]
[features.App]
features = [ "AccessoriesOverview", "BowlersList", "Onboarding", "Settings", "StatisticsOverview" ]
services = [ "Launch" ]
dependencies = [ "AnalyticsPackageService", "AppInfoPackageService", "BundlePackageService", "FileManagerPackageService", "PasteboardPackageService", "SentryErrorReportingPackageService", "StoreReviewPackageService", "TelemetryDeckAnalyticsPackageService", "UserDefaultsPackageService" ]
dependencies = [ "AnalyticsPackageService", "AppInfoPackageService", "BundlePackageService", "FeatureFlagsPackageService", "FileManagerPackageService", "PasteboardPackageService", "SentryErrorReportingPackageService", "StoreReviewPackageService", "TelemetryDeckAnalyticsPackageService", "UserDefaultsPackageService" ]

[features.AccessoriesOverview]
features = [ "AlleysList", "GearList" ]
Expand All @@ -31,8 +31,7 @@ libraries = [ "ModelsViews" ]

[features.AlleysList]
features = [ "AlleyEditor" ]
services = [ "FeatureFlags" ]
libraries = [ "ResourceList" ]
libraries = [ "FeatureFlags", "ResourceList" ]

[features.Announcements]
services = [ "Announcements" ]
Expand Down Expand Up @@ -61,16 +60,16 @@ libraries = [ "Constants", "Toast", "Views" ]
dependencies = [ "AppInfoPackageServiceInterface", "EquatablePackageLibrary", "FileManagerPackageServiceInterface", "PasteboardPackageServiceInterface" ]

[features.FeatureFlagsList]
services = [ "FeatureFlags" ]
libraries = [ "Strings" ]
libraries = [ "FeatureFlags", "Strings" ]

[features.Form]
features = [ "Errors" ]

[features.GamesEditor]
features = [ "Sharing", "StatisticsDetails" ]
repositories = [ "Frames", "Gear", "Lanes" ]
services = [ "Avatar", "FeatureFlags", "RecentlyUsed" ]
services = [ "Avatar", "RecentlyUsed" ]
libraries = [ "FeatureFlags" ]
dependencies = [ "StoreReviewPackageServiceInterface" ]

[features.GamesList]
Expand Down Expand Up @@ -111,8 +110,8 @@ libraries = [ "ResourceList" ]

[features.OpponentsList]
features = [ "OpponentDetails" ]
services = [ "FeatureFlags", "RecentlyUsed" ]
libraries = [ "ModelsViews", "SortOrder" ]
services = [ "RecentlyUsed" ]
libraries = [ "FeatureFlags", "ModelsViews", "SortOrder" ]

[features.Onboarding]
repositories = [ "Bowlers" ]
Expand All @@ -126,8 +125,7 @@ services = [ "Products" ]
[features.SeriesEditor]
features = [ "Form" ]
repositories = [ "Alleys", "Series" ]
services = [ "FeatureFlags" ]
libraries = [ "DateTime", "ModelsViews", "PickableModels" ]
libraries = [ "DateTime", "FeatureFlags", "ModelsViews", "PickableModels" ]

[features.SeriesList]
features = [ "GamesList", "LeagueEditor" ]
Expand Down Expand Up @@ -206,8 +204,8 @@ repositories = [ "Frames", "Games" ]
[repositories.Series.interface]

[repositories.Statistics]
services = [ "Preference", "FeatureFlags" ]
libraries = [ "StatisticsModels" ]
services = [ "Preference" ]
libraries = [ "FeatureFlags", "StatisticsModels" ]
dependencies = [ "UserDefaultsPackageServiceInterface" ]
[repositories.Statistics.interface]
libraries = [ "StatisticsWidgets" ]
Expand Down Expand Up @@ -258,18 +256,14 @@ skip_tests = true

[services.Email]

[services.FeatureFlags]
dependencies = [ "UserDefaultsPackageServiceInterface" ]
[services.FeatureFlags.interface]
libraries = [ "FeatureFlags" ]

[services.ImportExport]
services = [ "Database" ]
libraries = [ "DateTime" ]
dependencies = [ "FileManagerPackageServiceInterface" ]

[services.Launch]
services = [ "Analytics", "FeatureFlags", "Preference", "Products" ]
services = [ "Analytics", "Preference", "Products" ]
libraries = [ "FeatureFlags" ]
dependencies = [ "AppInfoPackageServiceInterface", "StoreReviewPackageServiceInterface", "UserDefaultsPackageServiceInterface" ]

[services.Logging]
Expand Down Expand Up @@ -341,6 +335,8 @@ skip_tests = true
dependencies = [ "ComposableArchitecture" ]

[libraries.FeatureFlags]
skip_tests = true
dependencies = [ "FeatureFlagsPackageLibrary", "FeatureFlagsPackageServiceInterface" ]

[libraries.ListContent]
libraries = [ "Views" ]
Expand Down Expand Up @@ -536,6 +532,15 @@ sharedRef = "SwiftUtilities"
[dependencies.ExtensionsPackageLibrary]
sharedRef = "SwiftUtilities"

[dependencies.FeatureFlagsPackageLibrary]
sharedRef = "SwiftUtilities"

[dependencies.FeatureFlagsPackageService]
sharedRef = "SwiftUtilities"

[dependencies.FeatureFlagsPackageServiceInterface]
sharedRef = "SwiftUtilities"

[dependencies.FileManagerPackageService]
sharedRef = "SwiftUtilities"

Expand Down
7 changes: 3 additions & 4 deletions ios/Approach/Sources/AlleysListFeature/AlleysList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AssetsLibrary
import ComposableArchitecture
import ErrorsFeature
import FeatureActionLibrary
import FeatureFlagsServiceInterface
import FeatureFlagsLibrary
import ModelsLibrary
import ResourceListLibrary
import StringsLibrary
Expand Down Expand Up @@ -48,8 +48,8 @@ public struct AlleysList: Reducer {
)
)

@Dependency(FeatureFlagsService.self) var featureFlags
self.isAlleyAndGearAveragesEnabled = featureFlags.isEnabled(.alleyAndGearAverages)
@Dependency(\.featureFlags) var featureFlags
self.isAlleyAndGearAveragesEnabled = try featureFlags.isFlagEnabled(.alleyAndGearAverages)
}
}

Expand Down Expand Up @@ -89,7 +89,6 @@ public struct AlleysList: Reducer {
public init() {}

@Dependency(AlleysRepository.self) var alleys
@Dependency(FeatureFlagsService.self) var featureFlags
@Dependency(\.uuid) var uuid

public var body: some ReducerOf<Self> {
Expand Down
1 change: 1 addition & 0 deletions ios/Approach/Sources/AppFeature/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import StatisticsRepositoryInterface
import AnalyticsPackageService
import AppInfoPackageService
import BundlePackageService
import FeatureFlagsPackageService
import FileManagerPackageService
import PasteboardPackageService
import SentryErrorReportingPackageService
Expand Down
4 changes: 0 additions & 4 deletions ios/Approach/Sources/AppFeature/TabbedContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import AnalyticsServiceInterface
import BowlersListFeature
import ComposableArchitecture
import FeatureActionLibrary
import FeatureFlagsLibrary
import FeatureFlagsServiceInterface
import SettingsFeature
import StatisticsOverviewFeature

Expand Down Expand Up @@ -50,8 +48,6 @@ public struct TabbedContent: Reducer {

public init() {}

@Dependency(FeatureFlagsService.self) var featureFlags

public var body: some ReducerOf<Self> {
BindingReducer()

Expand Down
36 changes: 0 additions & 36 deletions ios/Approach/Sources/FeatureFlagsLibrary/FeatureFlag.swift

This file was deleted.

2 changes: 2 additions & 0 deletions ios/Approach/Sources/FeatureFlagsLibrary/FeatureFlags.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// swiftlint:disable line_length
@_exported import FeatureFlagsPackageLibrary
@_exported import FeatureFlagsPackageServiceInterface

extension FeatureFlag {
public static let developerOptions = Self(name: "developerOptions", introduced: "2022-11-10", stage: .development, isOverridable: false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import FeatureFlagsPackageLibrary
import FeatureFlagsPackageServiceInterface

extension FeatureFlagsService {
public func isFlagEnabled(_ flag: FeatureFlag) -> Bool {
(try? self.isEnabled(flag)) ?? false
}

public func allFlagsEnabled(_ flags: [FeatureFlag]) -> Bool {
(try? self.allEnabled(flags)) ?? false
}
}
Loading

0 comments on commit 813bdc9

Please sign in to comment.