Skip to content

Commit

Permalink
FLEX support for spm/framework project (#1735)
Browse files Browse the repository at this point in the history
Implements support for FLEX in DEBUG for spm/framworks
  • Loading branch information
rinat-enikeev authored Nov 26, 2023
1 parent 9241d74 commit 55c881a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 22 deletions.
7 changes: 7 additions & 0 deletions project_frameworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ packages:
GRDB:
url: https://github.com/groue/GRDB.swift
from: 4.14.0
FLEX:
url: https://github.com/FLEXTool/FLEX.git
from: 5.22.10

include:
- Packages/RuuviAnalytics/target.yml
Expand Down Expand Up @@ -216,6 +219,7 @@ targets:
- package: Realm
- package: Realm
product: RealmSwift
- package: FLEX
- target: RuuviAnalytics
- target: RuuviCloud
- target: RuuviContext
Expand Down Expand Up @@ -277,6 +281,9 @@ targets:
TARGETED_DEVICE_FAMILY: 1,2
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: true
CODE_SIGN_ENTITLEMENTS: station/station.entitlements
configs:
Release:
EXCLUDED_SOURCE_FILE_NAMES: "FLEX*"
preBuildScripts:
- path: scripts/build/generate_l10n.sh
name: Generate L10N
Expand Down
7 changes: 7 additions & 0 deletions project_spm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ packages:
NordicDFU:
url: https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library
from: 4.10.3
FLEX:
url: https://github.com/FLEXTool/FLEX.git
from: 5.22.10
RuuviAnalytics:
path: Packages/RuuviAnalytics
RuuviCloud:
Expand Down Expand Up @@ -141,6 +144,7 @@ targets:
- package: Realm
product: RealmSwift
- package: NordicDFU
- package: FLEX
- package: RuuviAnalytics
- package: RuuviAnalytics
product: RuuviAnalyticsImpl
Expand Down Expand Up @@ -272,6 +276,9 @@ targets:
TARGETED_DEVICE_FAMILY: 1,2
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: true
CODE_SIGN_ENTITLEMENTS: station/station.entitlements
configs:
Release:
EXCLUDED_SOURCE_FILE_NAMES: "FLEX*"
preBuildScripts:
- path: scripts/build/generate_l10n.sh
name: Generate L10N
Expand Down
20 changes: 10 additions & 10 deletions station.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@
0EC50F5422CCBBE800172EEB /* NSObject+Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC50F5322CCBBE800172EEB /* NSObject+Observable.swift */; };
0EC50F5622CCE46D00172EEB /* Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC50F5522CCE46D00172EEB /* Optional.swift */; };
0EC50F5922CF621000172EEB /* PhotoPickerPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC50F5822CF621000172EEB /* PhotoPickerPresenter.swift */; };
0ECA196A2B138C3A00BEE4DB /* FeatureTogglesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ECA19692B138C3A00BEE4DB /* FeatureTogglesViewController.swift */; };
0ECA196B2B138C3A00BEE4DB /* FeatureTogglesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ECA19692B138C3A00BEE4DB /* FeatureTogglesViewController.swift */; };
0ECDF1B52313D65500A09ACA /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0ECDF1B42313D65500A09ACA /* GoogleService-Info.plist */; };
0EE36E3F26957E010021B746 /* DFUInteractorInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE36E3E26957E000021B746 /* DFUInteractorInput.swift */; };
0EE36E4026957E010021B746 /* DFUInteractorInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE36E3E26957E000021B746 /* DFUInteractorInput.swift */; };
Expand All @@ -361,8 +363,6 @@
0EE36EB1269DC71B0021B746 /* Algorithms in Frameworks */ = {isa = PBXBuildFile; productRef = 0EE36EB0269DC71B0021B746 /* Algorithms */; };
0EE36EB4269DC7D90021B746 /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 0EE36EB3269DC7D90021B746 /* Charts */; };
0EE36EB6269DC7E40021B746 /* Charts in Frameworks */ = {isa = PBXBuildFile; productRef = 0EE36EB5269DC7E40021B746 /* Charts */; };
0EE98A7926493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE98A7826493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift */; };
0EE98A7A26493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE98A7826493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift */; };
0EEB20C622B7915C0015F9E0 /* CardsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EEB20C522B7915C0015F9E0 /* CardsViewModel.swift */; };
0EEB20C722B7A7200015F9E0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0EEB20C922B7A7200015F9E0 /* Localizable.strings */; };
0EEB20CB22B7B37C0015F9E0 /* MenuTableEmbededViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EEB20CA22B7B37C0015F9E0 /* MenuTableEmbededViewController.swift */; };
Expand Down Expand Up @@ -1363,13 +1363,13 @@
0EC50F5322CCBBE800172EEB /* NSObject+Observable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSObject+Observable.swift"; sourceTree = "<group>"; };
0EC50F5522CCE46D00172EEB /* Optional.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Optional.swift; sourceTree = "<group>"; };
0EC50F5822CF621000172EEB /* PhotoPickerPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPickerPresenter.swift; sourceTree = "<group>"; };
0ECA19692B138C3A00BEE4DB /* FeatureTogglesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeatureTogglesViewController.swift; sourceTree = "<group>"; };
0ECDF1B42313D65500A09ACA /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
0ECDF1B62313D7DA00A09ACA /* station.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = station.entitlements; sourceTree = "<group>"; };
0EE36E3E26957E000021B746 /* DFUInteractorInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DFUInteractorInput.swift; sourceTree = "<group>"; };
0EE36E4126957E200021B746 /* LatestRelease.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LatestRelease.swift; sourceTree = "<group>"; };
0EE49BB123B8C40D003012C2 /* MacInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = MacInfo.plist; sourceTree = "<group>"; };
0EE49BB223B8C40D003012C2 /* DevInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = DevInfo.plist; sourceTree = "<group>"; };
0EE98A7826493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FLEXFeatureTogglesViewController.swift; sourceTree = "<group>"; };
0EEB20C522B7915C0015F9E0 /* CardsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardsViewModel.swift; sourceTree = "<group>"; };
0EEB20C822B7A7200015F9E0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
0EEB20CA22B7B37C0015F9E0 /* MenuTableEmbededViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuTableEmbededViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2860,7 +2860,7 @@
0EE98A772649386000AAB3ED /* FLEX */ = {
isa = PBXGroup;
children = (
0EE98A7826493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift */,
0ECA19692B138C3A00BEE4DB /* FeatureTogglesViewController.swift */,
);
path = FLEX;
sourceTree = "<group>";
Expand Down Expand Up @@ -4895,7 +4895,7 @@
mainGroup = 64333D1C20B0C45900CDF4B6;
packageReferences = (
0EE36EAD269DC70E0021B746 /* XCRemoteSwiftPackageReference "swift-algorithms" */,
0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts.git" */,
0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts" */,
);
productRefGroup = 64333D2620B0C45900CDF4B6 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -5396,7 +5396,6 @@
0E8BD2DA238566AB008B31EF /* MenuModuleOutput.swift in Sources */,
E1198A3629BA76CB002245CF /* ASSelectionViewInput.swift in Sources */,
0E3CA70D267365B1000D9B25 /* Debouncer.swift in Sources */,
0EE98A7A26493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift in Sources */,
E116707A29634363002DF7BF /* BackgroundSelectionViewOutput.swift in Sources */,
66BC449C2657AED400A03253 /* OffsetCorrectionConfigurator.swift in Sources */,
E10E18BB297D67FC002C78C3 /* RuuviCloudViewOutput.swift in Sources */,
Expand Down Expand Up @@ -5756,6 +5755,7 @@
0E197C7A23C5CCBC0074015B /* InfoProviderImpl.swift in Sources */,
0E8BD3CA238566AB008B31EF /* CardsRouter.swift in Sources */,
E10E18BE297D68EB002C78C3 /* RuuviCloudModuleInput.swift in Sources */,
0ECA196B2B138C3A00BEE4DB /* FeatureTogglesViewController.swift in Sources */,
E10E18C2297DD0CA002C78C3 /* RuuviCloudTableViewCell.swift in Sources */,
E1198A2D29BA769A002245CF /* ASSelectionTableViewController.swift in Sources */,
A9646488247BAE6B0001D55D /* ChartSettingsRouterInput.swift in Sources */,
Expand Down Expand Up @@ -5874,6 +5874,7 @@
A92A66BD2450C640002918E7 /* UITableViewCell+ReusableView.swift in Sources */,
A93CDCDE25659BF600018C6C /* AlertPresenterImpl.swift in Sources */,
E1B57FEE29859CC900B441FB /* DevicesModuleInput.swift in Sources */,
0ECA196A2B138C3A00BEE4DB /* FeatureTogglesViewController.swift in Sources */,
0E1C1E0F22B4049F0032F6CA /* MenuTablePresentationController.swift in Sources */,
340BE39B27B54FEC006D6C34 /* String+Email.swift in Sources */,
E116707929634363002DF7BF /* BackgroundSelectionViewOutput.swift in Sources */,
Expand Down Expand Up @@ -6185,7 +6186,6 @@
0EE36E4226957E200021B746 /* LatestRelease.swift in Sources */,
0E02ABCB2379483A00ED4629 /* Double+Temperature.swift in Sources */,
0EB48D8B2619D5AC008E0D2D /* FeatureToggleService.swift in Sources */,
0EE98A7926493C5000AAB3ED /* FLEXFeatureTogglesViewController.swift in Sources */,
E1198A3229BA76C1002245CF /* ASSelectionViewOutput.swift in Sources */,
E19691882A06E03300DC360E /* PushAlertSoundSelectionViewOutput.swift in Sources */,
0E5C302822D0B1C600B52E39 /* AppStateServiceImpl.swift in Sources */,
Expand Down Expand Up @@ -7130,7 +7130,7 @@
minimumVersion = 1.0.0;
};
};
0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts.git" */ = {
0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/danielgindi/Charts.git";
requirement = {
Expand All @@ -7153,12 +7153,12 @@
};
0EE36EB3269DC7D90021B746 /* Charts */ = {
isa = XCSwiftPackageProductDependency;
package = 0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts.git" */;
package = 0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts" */;
productName = Charts;
};
0EE36EB5269DC7E40021B746 /* Charts */ = {
isa = XCSwiftPackageProductDependency;
package = 0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts.git" */;
package = 0EE36EB2269DC7D90021B746 /* XCRemoteSwiftPackageReference "Charts" */;
productName = Charts;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
6 changes: 3 additions & 3 deletions station/Classes/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import FirebaseCore
import FirebaseMessaging
#if canImport(FLEX)
#if DEBUG && canImport(FLEX)
import FLEX
#endif
import UserNotifications
Expand Down Expand Up @@ -62,10 +62,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

cloudNotificationService = r.resolve(RuuviServiceCloudNotification.self)

#if canImport(FLEX)
#if DEBUG && canImport(FLEX)
FLEXManager.shared.registerGlobalEntry(
withName: "Feature Toggles",
viewControllerFutureBlock: { r.resolve(FLEXFeatureTogglesViewController.self) ?? UIViewController()
viewControllerFutureBlock: { r.resolve(FeatureTogglesViewController.self) ?? UIViewController()
}
)
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PresentationAssembly: Assembly {
return presenter
}

container.register(FLEXFeatureTogglesViewController.self) { r in
let controller = FLEXFeatureTogglesViewController()
container.register(FeatureTogglesViewController.self) { r in
let controller = FeatureTogglesViewController()
controller.featureToggleService = r.resolve(FeatureToggleService.self)
return controller
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit

final class FLEXFeatureTogglesViewController: UITableViewController {
final class FeatureTogglesViewController: UITableViewController {
var featureToggleService: FeatureToggleService!

init() {
Expand Down Expand Up @@ -78,7 +78,7 @@ final class FLEXFeatureTogglesViewController: UITableViewController {
}

// MARK: - UITableViewDelegate
extension FLEXFeatureTogglesViewController {
extension FeatureTogglesViewController {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard self.sourceSwitch.isOn else { return }
Expand All @@ -93,7 +93,7 @@ extension FLEXFeatureTogglesViewController {
}

// MARK: - UITableViewDataSource
extension FLEXFeatureTogglesViewController {
extension FeatureTogglesViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.features.count
}
Expand All @@ -116,7 +116,7 @@ extension FLEXFeatureTogglesViewController {
}

// MARK: - Helpers
extension FLEXFeatureTogglesViewController {
extension FeatureTogglesViewController {
private static func title(for feature: Feature) -> String {
switch feature {
case .legacyFirmwareUpdatePopup:
Expand All @@ -126,7 +126,7 @@ extension FLEXFeatureTogglesViewController {
}

// MARK: - Factory
extension FLEXFeatureTogglesViewController {
extension FeatureTogglesViewController {
private static func makeSourceLabel() -> UILabel {
let label = UILabel()
label.text = "Use local feature toggles"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SettingsRouter: SettingsRouterInput {

func openFeatureToggles() {
let r = AppAssembly.shared.assembler.resolver
if let viewController = r.resolve(FLEXFeatureTogglesViewController.self) {
if let viewController = r.resolve(FeatureTogglesViewController.self) {
transitionHandler.navigationController?.pushViewController(
viewController,
animated: true
Expand Down
2 changes: 1 addition & 1 deletion station/Extensions/UIWindow+Shake.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
#if canImport(FLEX)
#if DEBUG && canImport(FLEX)
import FLEX

extension UIWindow {
Expand Down

0 comments on commit 55c881a

Please sign in to comment.