Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
-scheme "$SCHEME" \
-configuration Debug \
-skipMacroValidation \
-destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.4" \
-destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=26.2" \
clean build
4 changes: 1 addition & 3 deletions Alarm/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ let package = Package(
)
],
dependencies: [
.package(name: "DI", path: "../DI"),
.package(name: "Common", path: "../Common"),
.package(name: "Infrastructure", path: "../Infrastructure"),
],
Expand All @@ -48,8 +47,7 @@ let package = Package(
.target(config: .domain),
.target(config: .data),
.target(config: .presentation),
.product(name: "DI", package: "DI"),
.product(name: "AppDI", package: "DI"),
.product(name: "DIKit", package: "Common"),
.product(name: "NetworkInterface", package: "Infrastructure"),
],
),
Expand Down
1 change: 0 additions & 1 deletion Alarm/Sources/DI/AlarmDIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation
import DIKit
import AppDI
import NetworkInterface
import AlarmDomain
import AlarmData
Expand Down
File renamed without changes.
98 changes: 98 additions & 0 deletions AppCore/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

enum Config: String, CaseIterable {
static let name: String = "AppCore"

case di = "DI"

var name: String {
return "\(Config.name)\(rawValue)"
}

var path: String {
"Sources/\(rawValue)"
}
}

let package = Package(
name: Config.name,
platforms: [.iOS(.v17)],
products: [
.library(
name: "AppCore",
targets: Config.allCases.map(\.name)
),
],
dependencies: [
.package(name: "Intro", path: "../Intro"),
.package(name: "Login", path: "../Login"),
.package(name: "Home", path: "../Home"),
.package(name: "Community", path: "../Community"),
.package(name: "MyPage", path: "../MyPage"),
.package(name: "Alarm", path: "../Alarm"),

.package(name: "3rdParty", path: "../3rdParty"),
.package(name: "Common", path: "../Common"),
.package(name: "Infrastructure", path: "../Infrastructure"),
],
targets: [
.target(
config: .di,
dependencies: [
.product(name: "DataSources", package: "Common"),
.product(name: "Managers", package: "Common"),
.product(name: "NetworkInterface", package: "Infrastructure"),
.product(name: "NetworkImpl", package: "Infrastructure"),
.product(name: "FCMService", package: "3rdParty"),

.product(name: "IntroDI", package: "Intro"),
.product(name: "LoginDI", package: "Login"),
.product(name: "HomeDI", package: "Home"),
.product(name: "CommunityDI", package: "Community"),
.product(name: "MyPageDI", package: "MyPage"),
.product(name: "AlarmDI", package: "Alarm"),
]
)
]
)

extension Target {
static func target(
config: Config,
dependencies: [Dependency] = [],
exclude: [String] = [],
sources: [String]? = nil,
resources: [Resource]? = nil,
publicHeadersPath: String? = nil,
packageAccess: Bool = false,
cSettings: [CSetting]? = nil,
cxxSettings: [CXXSetting]? = nil,
swiftSettings: [SwiftSetting]? = nil,
linkerSettings: [LinkerSetting]? = nil,
plugins: [PluginUsage]? = nil,
) -> Target {
return .target(
name: config.name,
dependencies: dependencies,
path: config.path,
exclude: exclude,
sources: sources,
resources: resources,
publicHeadersPath: publicHeadersPath,
packageAccess: packageAccess,
cSettings: cSettings,
cxxSettings: cxxSettings,
swiftSettings: swiftSettings,
linkerSettings: linkerSettings,
plugins: plugins)
}
}

extension Target.Dependency {
static func target(config: Config) -> Self {
return .target(name: config.name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import NetworkInterface
import NetworkImpl
import FCMService

import IntroDI
import LoginDI
import HomeDI
import CommunityDI
import MyPageDI
import AlarmDI

// MARK: - App Assembly
struct AppAssembly: Assembly {
func assemble(container: GenericDIContainer) {
Expand Down Expand Up @@ -71,6 +78,37 @@ struct AppAssembly: Assembly {
udManager: resolver.resolve(UserDefaultsManager.self)
)
}

// MARK: - IntroDIContainer
container.register(IntroDIContainer.self, scope: .singleton) { r in
IntroDIContainer(appContainer: container)
}

// MARK: - LoginDIContainer
container.register(LoginDIContainer.self, scope: .singleton) { r in
LoginDIContainer(appContainer: container)
}

// MARK: - HomeDIContainer
container.register(HomeDIContainer.self, scope: .singleton) { r in
HomeDIContainer(appContainer: container)
}

// MARK: - CommunityDIContainer
container.register(CommunityDIContainer.self, scope: .singleton) { r in
CommunityDIContainer(appContainer: container)
}

// MARK: - MyPageDIContainer
container.register(MyPageDIContainer.self, scope: .singleton) { r in
MyPageDIContainer(appContainer: container)
}

// MARK: - AlarmDIContainer
container.register(AlarmDIContainer.self, scope: .singleton) { r in
AlarmDIContainer(appContainer: container)
}

}
}

Expand All @@ -96,6 +134,26 @@ public final class AppDIContainer: @unchecked Sendable {
return container
}

public var introDIContainer: IntroDIContainer {
return container.resolve(IntroDIContainer.self)
}

public var loginDIContainer: LoginDIContainer {
return container.resolve(LoginDIContainer.self)
}

public var homeDIContainer: HomeDIContainer {
return container.resolve(HomeDIContainer.self)
}

public var communityDIContainer: CommunityDIContainer {
return container.resolve(CommunityDIContainer.self)
}

public var mypageDIContainer: MyPageDIContainer {
return container.resolve(MyPageDIContainer.self)
}

/// Direct access to AppStateManager for app initialization
public func makeAppStateManager() -> AppStateManager {
return container.resolve(AppStateManager.self)
Expand Down
5 changes: 5 additions & 0 deletions Common/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ let package = Package(
name: "DataSources",
targets: ["DataSources"]
),
.library(
name: "DIKit",
targets: ["DIKit"]
),
.library(
name: "LocalizedString",
targets: ["LocalizedString"]
Expand Down Expand Up @@ -48,6 +52,7 @@ let package = Package(
]
),
.target(name: "DataSources"),
.target(name: "DIKit"),
.target(name: "LocalizedString"),
.target(name: "Util"),
.target(
Expand Down
8 changes: 5 additions & 3 deletions Common/Sources/Managers/AppStateManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public final class AppStateManager {
}

public func completeSplash() {
if isOnboardingCompleted {
state = isLoginCompleted ? .main : .login
if isLoginCompleted {
state = .main
} else if isOnboardingCompleted {
state = .main
} else {
state = .onboarding
}
Expand All @@ -59,7 +61,7 @@ public final class AppStateManager {
// 온보딩 완료
public func completeOnboarding() {
udManager.isOnboardingCompleted = true
state = isLoginCompleted ? .main : .login
state = .login
}

// 로그인 완료
Expand Down
16 changes: 11 additions & 5 deletions Community/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@ let package = Package(
targets: Config.allCases.map(\.name)
),
.library(
name: "CommunityDomain",
targets: ["CommunityDomain"]
name: Config.di.name,
targets: [Config.di.name]
),
.library(
name: Config.domain.name,
targets: [Config.domain.name]
),
.library(
name: Config.presentation.name,
targets: [Config.presentation.name]
),
],
dependencies: [
.package(name: "DI", path: "../DI"),
.package(name: "Common", path: "../Common"),
.package(name: "Infrastructure", path: "../Infrastructure"),
.package(name: "Alarm", path: "../Alarm"),
Expand All @@ -46,8 +53,7 @@ let package = Package(
.target(config: .domain),
.target(config: .data),
.target(config: .presentation),
.product(name: "DI", package: "DI"),
.product(name: "AppDI", package: "DI"),
.product(name: "DIKit", package: "Common"),
.product(name: "NetworkInterface", package: "Infrastructure"),
.product(name: "NetworkImpl", package: "Infrastructure"),
],
Expand Down
45 changes: 25 additions & 20 deletions Community/Sources/DI/CommunityDIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

import Foundation
import DIKit
import AppDI
import NetworkInterface
import NetworkImpl
import CommunityDomain
import CommunityData
import CommunityPresentation
import Managers

import AlarmDI
import AlarmPresentation

struct CommunityWriteAssembly: Assembly {
func assemble(container: GenericDIContainer) {
container.register(CreateBoardUseCase.self) { resolver in
Expand Down Expand Up @@ -100,42 +102,45 @@ public final class CommunityDIContainer {
private let container: GenericDIContainer

// MARK: - Initialization
public init(appContainer: AppDIContainer = .shared) {
self.container = GenericDIContainer(parent: appContainer.baseContainer)
public init(appContainer: GenericDIContainer) {
self.container = appContainer
CommunityAssembly().assemble(container: container)
CommunityWriteAssembly().assemble(container: container)
}
}


extension CommunityDIContainer: CommunityDependency {
public var alarmListComponent: any AlarmPresentation.AlarmListDependecy {
container.resolve(AlarmDIContainer.self)
}

public var component: any CommunityPresentation.CommunityDetailDependency {
self
}

// MARK: - Factory Methods
@MainActor
public func makeCommunityViewModel() -> CommunityViewModel {
return container.resolve(CommunityViewModel.self)
}
}

extension CommunityDIContainer: CommunityWriteFactory {
public func makeWriteViewModel() -> any CommunityWriteViewModelProtocol {

public func makeWriteViewModel() -> any CommunityPresentation.CommunityWriteViewModelProtocol {
container.resolve(CommunityWriteViewModel.self)
}
}

extension CommunityDIContainer: CommunityDetailFactory {
@MainActor
public func makeDetailViewModel() -> CommunityDetailViewModel {
return container.resolve(CommunityDetailViewModel.self)
extension CommunityDIContainer: CommunityDetailDependency {
public func makeDetailViewModel() -> CommunityPresentation.CommunityDetailViewModel {
container.resolve(CommunityDetailViewModel.self)
}
}

extension CommunityDIContainer: UpdateBoardFactory {
public func makeViewModel(boardId: Int) -> CommunityWriteViewModelProtocol {
return UpdateBoardViewModel(

public func makeViewModel(boardId: Int) -> any CommunityPresentation.CommunityWriteViewModelProtocol {
UpdateBoardViewModel(
boardId: boardId,
updateBoardUseCase: container.resolve(UpdateBoardUseCase.self)
)
}
}

extension CommunityDIContainer: ReportBoardFactory {

public func makeViewModel(req: ReportRequest) -> CommunityReportViewModel {
return CommunityReportViewModel(
usecase: container.resolve(ReportContentUseCase.self),
Expand Down
Loading