Skip to content

Commit

Permalink
Merge pull request #1789 from ruuvi/dev
Browse files Browse the repository at this point in the history
Remove Realm dependency (#1788)
  • Loading branch information
rinat-enikeev authored Dec 15, 2023
2 parents ca79e2a + b34937c commit 06e6999
Show file tree
Hide file tree
Showing 58 changed files with 76 additions and 2,290 deletions.
4 changes: 0 additions & 4 deletions Apps/RuuviStation/Intents/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ targets:
PROVISIONING_PROFILE_SPECIFIER: "match AdHoc com.ruuvi.station.intents"
Debug:
CODE_SIGN_STYLE: Automatic
OTHER_LDFLAGS: -Xlinker -no_warn_duplicate_libraries
Release:
EXCLUDED_SOURCE_FILE_NAMES: "FLEX*"
CODE_SIGN_IDENTITY: "iPhone Distribution"
Expand All @@ -50,10 +49,7 @@ targets:
- package: Future
- package: GRDB
- package: Humidity
- package: Realm
- package: KeychainAccess
- package: Realm
product: RealmSwift
- target: RuuviUser
embed: true
- target: RuuviCloud
Expand Down
4 changes: 3 additions & 1 deletion Apps/RuuviStation/NotificationService/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ targets:
Alpha:
CODE_SIGN_IDENTITY: "iPhone Distribution"
PROVISIONING_PROFILE_SPECIFIER: "match AdHoc com.ruuvi.station.pnservice"
# OTHER_LDFLAGS: -ld_classic
Debug:
CODE_SIGN_STYLE: Automatic
OTHER_LDFLAGS: -Xlinker -no_warn_duplicate_libraries
# OTHER_LDFLAGS: -ld_classic
Release:
EXCLUDED_SOURCE_FILE_NAMES: "FLEX*"
CODE_SIGN_IDENTITY: "iPhone Distribution"
PROVISIONING_PROFILE_SPECIFIER: "match AdHoc com.ruuvi.station.pnservice"
# OTHER_LDFLAGS: -ld_classic
sources:
- path: Sources
name: NotificationService
Expand Down
36 changes: 2 additions & 34 deletions Apps/RuuviStation/Sources/Classes/Application/AppAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,16 @@ private final class DfuAssembly: Assembly {

private final class MigrationAssembly: Assembly {
func assemble(container: Container) {
container.register(RuuviMigration.self, name: "realm") { r in
let localImages = r.resolve(RuuviLocalImages.self)!
let settings = r.resolve(RuuviLocalSettings.self)!
return MigrationManagerToVIPER(localImages: localImages, settings: settings)
}

container.register(RuuviMigrationFactory.self) { r in
let settings = r.resolve(RuuviLocalSettings.self)!
let idPersistence = r.resolve(RuuviLocalIDs.self)!
let realmContext = r.resolve(RealmContext.self)!
let ruuviPool = r.resolve(RuuviPool.self)!
let ruuviStorage = r.resolve(RuuviStorage.self)!
let ruuviAlertService = r.resolve(RuuviServiceAlert.self)!
let ruuviOffsetCalibrationService = r.resolve(RuuviServiceOffsetCalibration.self)!
return RuuviMigrationFactoryImpl(
settings: settings,
idPersistence: idPersistence,
realmContext: realmContext,
ruuviPool: ruuviPool,
ruuviStorage: ruuviStorage,
ruuviAlertService: ruuviAlertService,
Expand All @@ -84,16 +76,6 @@ private final class MigrationAssembly: Assembly {
private final class PersistenceAssembly: Assembly {
// swiftlint:disable:next function_body_length
func assemble(container: Container) {
container.register(RealmContextFactory.self) { _ in
let factory = RealmContextFactoryImpl()
return factory
}.inObjectScope(.container)

container.register(RealmContext.self) { r in
let factory = r.resolve(RealmContextFactory.self)!
return factory.create()
}.inObjectScope(.container)

container.register(RuuviLocalConnections.self) { r in
let factory = r.resolve(RuuviLocalFactory.self)!
return factory.createLocalConnections()
Expand All @@ -115,14 +97,12 @@ private final class PersistenceAssembly: Assembly {

container.register(RuuviPool.self) { r in
let factory = r.resolve(RuuviPoolFactory.self)!
let realm = r.resolve(RuuviPersistence.self, name: "realm")!
let sqlite = r.resolve(RuuviPersistence.self, name: "sqlite")!
let localIDs = r.resolve(RuuviLocalIDs.self)!
let localSettings = r.resolve(RuuviLocalSettings.self)!
let localConnections = r.resolve(RuuviLocalConnections.self)!
return factory.create(
sqlite: sqlite,
realm: realm,
idPersistence: localIDs,
settings: localSettings,
connectionPersistence: localConnections
Expand All @@ -136,14 +116,10 @@ private final class PersistenceAssembly: Assembly {
container.register(RuuviReactor.self) { r in
let factory = r.resolve(RuuviReactorFactory.self)!
let sqliteContext = r.resolve(SQLiteContext.self)!
let realmContext = r.resolve(RealmContext.self)!
let sqltePersistence = r.resolve(RuuviPersistence.self, name: "sqlite")!
let realmPersistence = r.resolve(RuuviPersistence.self, name: "realm")!
return factory.create(
sqliteContext: sqliteContext,
realmContext: realmContext,
sqlitePersistence: sqltePersistence,
realmPersistence: realmPersistence
sqlitePersistence: sqltePersistence
)
}.inObjectScope(.container)

Expand All @@ -152,11 +128,6 @@ private final class PersistenceAssembly: Assembly {
return factory
}

container.register(RuuviPersistence.self, name: "realm") { r in
let context = r.resolve(RealmContext.self)!
return RuuviPersistenceRealm(context: context)
}.inObjectScope(.container)

container.register(RuuviPersistence.self, name: "sqlite") { r in
let context = r.resolve(SQLiteContext.self)!
return RuuviPersistenceSQLite(context: context)
Expand All @@ -165,8 +136,7 @@ private final class PersistenceAssembly: Assembly {
container.register(RuuviStorage.self) { r in
let factory = r.resolve(RuuviStorageFactory.self)!
let sqlite = r.resolve(RuuviPersistence.self, name: "sqlite")!
let realm = r.resolve(RuuviPersistence.self, name: "realm")!
return factory.create(realm: realm, sqlite: sqlite)
return factory.create(sqlite: sqlite)
}.inObjectScope(.container)

container.register(RuuviLocalFactory.self) { _ in
Expand Down Expand Up @@ -294,14 +264,12 @@ private final class DaemonAssembly: Assembly {
let ruuviPool = r.resolve(RuuviPool.self)!
let foreground = r.resolve(BTForeground.self)!
let idPersistence = r.resolve(RuuviLocalIDs.self)!
let realmPersistence = r.resolve(RuuviPersistence.self, name: "realm")!
let sqiltePersistence = r.resolve(RuuviPersistence.self, name: "sqlite")!
let daemon = RuuviTagPropertiesDaemonBTKit(
ruuviPool: ruuviPool,
ruuviReactor: ruuviReactor,
foreground: foreground,
idPersistence: idPersistence,
realmPersistence: realmPersistence,
sqiltePersistence: sqiltePersistence
)
return daemon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
featureToggleService.fetchFeatureToggles()

// the order is important
r.resolve(RuuviMigration.self, name: "realm")?
.migrateIfNeeded()
r.resolve(SQLiteContext.self)?
.database
.migrateIfNeeded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class AboutConfigurator {
presenter.view = view
presenter.router = router
presenter.ruuviStorage = r.resolve(RuuviStorage.self)
presenter.realmContext = r.resolve(RealmContext.self)
presenter.sqliteContext = r.resolve(SQLiteContext.self)
view.output = presenter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ final class AboutPresenter: AboutModuleInput {
weak var view: AboutViewInput!
var router: AboutRouterInput!
var ruuviStorage: RuuviStorage!
var realmContext: RealmContext!
var sqliteContext: SQLiteContext!

private var viewModel: AboutViewModel {
Expand Down Expand Up @@ -102,21 +101,12 @@ extension AboutPresenter {
}

private func obtainDatabaseSize() {
let realmSize = getRealmFileSize()
let sqliteSize = getSQLiteFileSize()
let dbSize = ByteCountFormatter().string(fromByteCount: realmSize + sqliteSize)
let dbSize = ByteCountFormatter().string(fromByteCount: sqliteSize)
let dbSizeString = RuuviLocalization.About.DatabaseSize.text(dbSize)
viewModel.databaseSize.value = dbSizeString
}

func getRealmFileSize() -> Int64 {
guard let realmPath = realmContext.main.configuration.fileURL?.relativePath
else {
return 0
}
return fileSize(at: realmPath)
}

func getSQLiteFileSize() -> Int64 {
fileSize(at: sqliteContext.database.dbPath)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ final class DashboardModuleFactoryImpl: DashboardModuleFactory {
let presenter = DashboardPresenter()
presenter.router = router
presenter.view = view
presenter.realmContext = r.resolve(RealmContext.self)
presenter.errorPresenter = r.resolve(ErrorPresenter.self)
presenter.settings = r.resolve(RuuviLocalSettings.self)
presenter.foreground = r.resolve(BTForeground.self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class DashboardPresenter: DashboardModuleInput {
weak var view: DashboardViewInput?
var router: DashboardRouterInput!
var interactor: DashboardInteractorInput!
var realmContext: RealmContext!
var errorPresenter: ErrorPresenter!
var settings: RuuviLocalSettings!
var foreground: BTForeground!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class SettingsTableConfigurator {
presenter.ruuviReactor = r.resolve(RuuviReactor.self)
presenter.errorPresenter = r.resolve(ErrorPresenter.self)
presenter.alertService = r.resolve(RuuviServiceAlert.self)
presenter.realmContext = r.resolve(RealmContext.self)
presenter.featureToggleService = r.resolve(FeatureToggleService.self)
presenter.ruuviAppSettingsService = r.resolve(RuuviServiceAppSettings.self)
presenter.ruuviUser = r.resolve(RuuviUser.self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class SettingsPresenter: SettingsModuleInput {
var errorPresenter: ErrorPresenter!
var ruuviReactor: RuuviReactor!
var alertService: RuuviServiceAlert!
var realmContext: RealmContext!
var featureToggleService: FeatureToggleService!
var ruuviAppSettingsService: RuuviServiceAppSettings!
var ruuviUser: RuuviUser!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class DFUModuleFactoryImpl: DFUModuleFactory {
interactor.background = r.resolve(BTBackground.self)
let foreground = r.resolve(BTForeground.self)!
let idPersistence = r.resolve(RuuviLocalIDs.self)!
let realmPersistence = r.resolve(RuuviPersistence.self, name: "realm")!
let sqiltePersistence = r.resolve(RuuviPersistence.self, name: "sqlite")!
let ruuviPool = r.resolve(RuuviPool.self)!
let ruuviStorage = r.resolve(RuuviStorage.self)!
Expand All @@ -33,7 +32,6 @@ final class DFUModuleFactoryImpl: DFUModuleFactory {
ruuviTag: ruuviTag,
foreground: foreground,
idPersistence: idPersistence,
realmPersistence: realmPersistence,
sqiltePersistence: sqiltePersistence,
ruuviPool: ruuviPool,
ruuviStorage: ruuviStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ final class DFUPresenter: DFUModuleInput {
private let interactor: DFUInteractorInput
private let foreground: BTForeground!
private let idPersistence: RuuviLocalIDs
private let realmPersistence: RuuviPersistence
private let sqiltePersistence: RuuviPersistence
private let ruuviTag: RuuviTagSensor
private let ruuviPool: RuuviPool
Expand All @@ -40,7 +39,6 @@ final class DFUPresenter: DFUModuleInput {
ruuviTag: RuuviTagSensor,
foreground: BTForeground,
idPersistence: RuuviLocalIDs,
realmPersistence: RuuviPersistence,
sqiltePersistence: RuuviPersistence,
ruuviPool: RuuviPool,
ruuviStorage: RuuviStorage,
Expand All @@ -51,7 +49,6 @@ final class DFUPresenter: DFUModuleInput {
self.interactor = interactor
self.foreground = foreground
self.idPersistence = idPersistence
self.realmPersistence = realmPersistence
self.sqiltePersistence = sqiltePersistence
self.ruuviTag = ruuviTag
self.ruuviPool = ruuviPool
Expand All @@ -63,7 +60,6 @@ final class DFUPresenter: DFUModuleInput {
interactor: interactor,
foreground: foreground,
idPersistence: idPersistence,
realmPersistence: realmPersistence,
sqiltePersistence: sqiltePersistence,
ruuviTag: ruuviTag,
ruuviPool: ruuviPool,
Expand Down
Loading

0 comments on commit 06e6999

Please sign in to comment.