Skip to content

Reduce dependencies #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ Sample iOS app written the way I write iOS apps because I cannot share the app I

- [RxSwift](https://github.com/ReactiveX/RxSwift) - Reactive Programming in Swift
- [RxSwiftExt](https://github.com/RxSwiftCommunity/RxSwiftExt) - A collection of Rx operators & tools not found in the core RxSwift distribution
- [Swinject](https://github.com/Swinject/Swinject) - Dependency injection framework for Swift
- [Reusable](https://github.com/AliSoftware/Reusable) - A Swift mixin for reusing views easily and in a type-safe way
- [Nuke](https://github.com/kean/Nuke) - A powerful image loading and caching system
- [FeedKit](https://github.com/nmdias/FeedKit) - An RSS, Atom and JSON Feed parser written in Swift
- [NotificationBanner](https://github.com/Daltron/NotificationBanner) - The easiest way to display highly customizable in app notification banners in iOS
- [SwiftLint](https://github.com/realm/SwiftLint) - A tool to enforce Swift style and conventions

## Author
Expand Down
192 changes: 26 additions & 166 deletions Sources/iOSSampleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1630"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
5 changes: 2 additions & 3 deletions Sources/iOSSampleApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
// Copyright © 2017 Igor Kulman. All rights reserved.
//

import Swinject
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
internal let container = Container()
private var container: Container!

private var appCoordinator: AppCoordinator!

func application(_: UIApplication, willFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
setupDependencies()
container = Container()

return true
}
Expand Down
72 changes: 72 additions & 0 deletions Sources/iOSSampleApp/Container.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// AppContainer.swift
// iOSSampleApp
//
// Created by Igor Kulman on 27.05.2025.
// Copyright © 2025 Igor Kulman. All rights reserved.
//

import Foundation
import OSLog

final class Container {

init() {
Logger.appFlow.debug("Registering dependencies")
#if DEBUG
if ProcessInfo().arguments.contains("testMode") {
Logger.appFlow.debug("Running in UI tests, deleting selected source to start clean")
settingsService.selectedSource = nil
}
#endif
}

// MARK: - Services

lazy var dataService: DataService = RssDataService()
lazy var settingsService: SettingsService = UserDefaultsSettingsService()

// MARK: - ViewModels

func makeSourceSelectionViewModell() -> SourceSelectionViewModel {
SourceSelectionViewModel(settingsService: settingsService)
}

func makeCustomSourceViewModel() -> CustomSourceViewModel {
CustomSourceViewModel()
}

func makeFeedViewModel() -> FeedViewModel {
FeedViewModel(dataService: dataService, settingsService: settingsService)
}

func makeLibrariesViewModel() -> LibrariesViewModel {
LibrariesViewModel()
}

func makeAboutViewModel() -> AboutViewModel {
AboutViewModel()
}

// MARK: - ViewControllers

func makeSourceSelectionViewController() -> SourceSelectionViewController {
SourceSelectionViewController(viewModel: makeSourceSelectionViewModell())
}

func makeCustomSourceViewController() -> CustomSourceViewController {
CustomSourceViewController(viewModel: makeCustomSourceViewModel())
}

func makeFeedViewController() -> FeedViewController {
FeedViewController(viewModel: makeFeedViewModel())
}

func makeLibrariesViewController() -> LibrariesViewController {
LibrariesViewController(viewModel: makeLibrariesViewModel())
}

func makeAboutViewController() -> AboutViewController {
AboutViewController(viewModel: makeAboutViewModel())
}
}
153 changes: 6 additions & 147 deletions Sources/iOSSampleApp/Data/Licenses.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>license</key>
<string>MIT License</string>
<key>text</key>
<string>The MIT License (MIT)

Copyright (c) 2016 AliSoftware

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>title</key>
<string>Reusable</string>
</dict>
<dict>
<key>license</key>
<string>MIT License</string>
<key>text</key>
<string>Copyright (c) 2017-2023 Daltron &lt;daltonhint4@gmail.com&gt;

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>title</key>
<string>NotificationBanner</string>
</dict>
<dict>
<key>license</key>
<string>MIT License</string>
Expand All @@ -66,11 +10,11 @@ THE SOFTWARE.
**Copyright © 2015 Krunoslav Zaher, Shai Mishali**
**All rights reserved.**

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</string>
<key>title</key>
<string>RxSwift</string>
Expand All @@ -82,7 +26,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<string>Copyright (c) 2016-latest RxSwiftCommunity https://github.com/RxSwiftCommunity

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
Expand All @@ -91,7 +35,7 @@ furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Expand All @@ -108,95 +52,10 @@ THE SOFTWARE.
<key>text</key>
<string>The MIT License (MIT)

Copyright (c) 2015 Swinject Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>title</key>
<string>Swinject</string>
</dict>
<dict>
<key>license</key>
<string>MIT License</string>
<key>text</key>
<string>Copyright (c) 2016 Swinject Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>title</key>
<string>SwinjectAutoregistration</string>
</dict>
<dict>
<key>license</key>
<string>MIT License</string>
<key>text</key>
<string>The MIT License (MIT)

Copyright (c) 2015-2024 Alexander Grebenyuk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>title</key>
<string>Nuke</string>
</dict>
<dict>
<key>license</key>
<string>MIT License</string>
<key>text</key>
<string>The MIT License (MIT)

Copyright (c) 2016 - 2018 Nuno Manuel Dias

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
Expand All @@ -205,7 +64,7 @@ furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Expand Down
1 change: 0 additions & 1 deletion Sources/iOSSampleApp/Scenarios/About/Cells/AboutCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Foundation
import Reusable
import UIKit

final class AboutCell: UITableViewCell, Reusable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Foundation
import Reusable
import UIKit

final class LibraryCell: UITableViewCell, Reusable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation
import SafariServices
import Swinject
import UIKit

protocol AboutCoordinatorDelegate: AnyObject {
Expand All @@ -23,7 +22,7 @@ final class AboutCoordinator: NavigationCoordinator {
// MARK: - Properties

let navigationController: UINavigationController
let container: Container
private let container: Container
weak var delegate: AboutCoordinatorDelegate?

init(container: Container, navigationController: UINavigationController) {
Expand All @@ -37,7 +36,7 @@ final class AboutCoordinator: NavigationCoordinator {
Starts the Abotu flow by showing the basic info and additional menu items
*/
func start() {
let aboutViewController = container.resolve(AboutViewController.self)! &> {
let aboutViewController = container.makeAboutViewController() &> {
$0.delegate = self
}
navigationController.setBackButton()
Expand All @@ -48,7 +47,7 @@ final class AboutCoordinator: NavigationCoordinator {
Shows the list of open source libraries used by the app
*/
private func showLibraries() {
let librariesViewController = container.resolve(LibrariesViewController.self)!
let librariesViewController = container.makeLibrariesViewController()
navigationController.pushViewController(librariesViewController, animated: true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation
import OSLog
import Swinject
import UIKit

enum AppChildCoordinator {
Expand All @@ -24,7 +23,7 @@ final class AppCoordinator: Coordinator {
// MARK: - Properties

private let window: UIWindow
let container: Container
private let container: Container
private var childCoordinators = [AppChildCoordinator: Coordinator]()
private let settingsService: SettingsService
private let navigationController: UINavigationController
Expand All @@ -46,7 +45,7 @@ final class AppCoordinator: Coordinator {
$0.navigationBar.scrollEdgeAppearance = $0.navigationBar.standardAppearance
}

settingsService = self.container.resolve(SettingsService.self)!
settingsService = container.settingsService

self.window.rootViewController = navigationController
}
Expand Down
Loading