Skip to content

Commit

Permalink
Add Inject framework for hot reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
mplorentz committed Dec 27, 2024
1 parent bd30f9b commit 0dd8f24
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Nos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
C987F85429BA951E00B44E7A /* ClarityCity-Thin.otf in Resources */ = {isa = PBXBuildFile; fileRef = C987F83129BA951E00B44E7A /* ClarityCity-Thin.otf */; };
C987F85529BA951E00B44E7A /* ClarityCity-Thin.otf in Resources */ = {isa = PBXBuildFile; fileRef = C987F83129BA951E00B44E7A /* ClarityCity-Thin.otf */; };
C987F85B29BA9ED800B44E7A /* Font+Clarity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C987F85729BA981800B44E7A /* Font+Clarity.swift */; };
C98905A22CD3B8CF00C17EE0 /* Inject in Frameworks */ = {isa = PBXBuildFile; productRef = C98905A12CD3B8CF00C17EE0 /* Inject */; };
C98A32272A05795E00E3FA13 /* Task+Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98A32262A05795E00E3FA13 /* Task+Timeout.swift */; };
C98A32282A05795E00E3FA13 /* Task+Timeout.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98A32262A05795E00E3FA13 /* Task+Timeout.swift */; };
C98B8B4029FBF83B009789C8 /* NotificationCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98B8B3F29FBF83B009789C8 /* NotificationCard.swift */; };
Expand Down Expand Up @@ -2101,6 +2102,7 @@
C9FD35122BCED5A6008F8D95 /* NostrSDK */,
03C49ABF2C938A9C00502321 /* SwiftSoup */,
039389222CA4985C00698978 /* SDWebImageWebPCoder */,
C98905A12CD3B8CF00C17EE0 /* Inject */,
);
productName = Nos;
productReference = C9DEBFCE298941000078B43A /* Nos.app */;
Expand Down Expand Up @@ -2197,6 +2199,7 @@
C9FD35112BCED5A6008F8D95 /* XCRemoteSwiftPackageReference "nostr-sdk-ios" */,
03C49ABE2C938A9C00502321 /* XCRemoteSwiftPackageReference "SwiftSoup" */,
039389212CA4985C00698978 /* XCRemoteSwiftPackageReference "SDWebImageWebPCoder" */,
C98905A02CD3B8CF00C17EE0 /* XCRemoteSwiftPackageReference "Inject" */,
);
productRefGroup = C9DEBFCF298941000078B43A /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -3661,6 +3664,14 @@
minimumVersion = 1.0.0;
};
};
C98905A02CD3B8CF00C17EE0 /* XCRemoteSwiftPackageReference "Inject" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/krzysztofzablocki/Inject.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.5.2;
};
};
C99DBF7C2A9E81CF00F7068F /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI";
Expand Down Expand Up @@ -3812,6 +3823,11 @@
package = C96CB98A2A6040C500498C4E /* XCRemoteSwiftPackageReference "swift-collections" */;
productName = DequeModule;
};
C98905A12CD3B8CF00C17EE0 /* Inject */ = {
isa = XCSwiftPackageProductDependency;
package = C98905A02CD3B8CF00C17EE0 /* XCRemoteSwiftPackageReference "Inject" */;
productName = Inject;
};
C99DBF7D2A9E81CF00F7068F /* SDWebImageSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
package = C99DBF7C2A9E81CF00F7068F /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "f8bae06dbeb84f5992ca8659ee3a2a75550fe8b31994d37a658183a21f1c8131",
"originHash" : "62d037ae150ed2e6e150f06b42119c5158134318243e742971b3ccfa3a3a5323",
"pins" : [
{
"identity" : "bech32",
Expand Down Expand Up @@ -37,6 +37,15 @@
"version" : "1.8.2"
}
},
{
"identity" : "inject",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzysztofzablocki/Inject.git",
"state" : {
"revision" : "728c56639ecb3df441d51d5bc6747329afabcfc9",
"version" : "1.5.2"
}
},
{
"identity" : "libwebp-xcode",
"kind" : "remoteSourceControl",
Expand Down
7 changes: 7 additions & 0 deletions Nos/NosApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SwiftUI
import Logger
import Dependencies
import TipKit
import Inject

@main
struct NosApp: App {
Expand All @@ -15,6 +16,7 @@ struct NosApp: App {
private let appController = AppController()
@Environment(\.scenePhase) private var scenePhase
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@ObserveInjection var inject

init() {
_ = crashReporting // force crash reporting init as early as possible
Expand All @@ -24,6 +26,11 @@ struct NosApp: App {
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .systemBlue
persistenceController.scheduleBackgroundCleanupTask()
try? Tips.configure()

#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
InjectConfiguration.animation = .interactiveSpring()
#endif
}

var body: some Scene {
Expand Down
3 changes: 3 additions & 0 deletions Nos/Views/AppView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SwiftUI
import Dependencies
import Inject

struct AppView: View {

Expand All @@ -14,6 +15,7 @@ struct AppView: View {
@Dependency(\.userDefaults) private var userDefaults
@Environment(CurrentUser.self) var currentUser
@Environment(RelayService.self) private var relayService
@ObserveInjection var inject

@State private var lastSelectedTab = AppDestination.home
@State private var showNIP05Wizard = false
Expand Down Expand Up @@ -47,6 +49,7 @@ struct AppView: View {
}
.task { await presentNIP05SheetIfNeeded() }
.tint(.primaryTxt)
.enableInjection()
}

private var tabView: some View {
Expand Down
3 changes: 3 additions & 0 deletions Nos/Views/Home/HomeFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import CoreData
import Combine
import Dependencies
import TipKit
import Inject

struct HomeFeedView: View {

@Environment(\.managedObjectContext) private var viewContext
@EnvironmentObject private var router: Router
@ObservationIgnored @Dependency(\.analytics) private var analytics
@ObserveInjection var inject

@State private var refreshController = RefreshController(lastRefreshDate: Date.now + Self.staticLoadTime)
@State private var isVisible = false
Expand Down Expand Up @@ -164,6 +166,7 @@ struct HomeFeedView: View {
GoToFeedTip.viewedFeed.sendDonation()
}
}
.enableInjection()
}
}

Expand Down
3 changes: 3 additions & 0 deletions Nos/Views/Home/HomeTab.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import SwiftUI
import Dependencies
import Inject

struct HomeTab: View {

@ObservedObject var user: Author

@EnvironmentObject private var router: Router
@ObserveInjection var inject

var body: some View {
NosNavigationStack(path: $router.homeFeedPath) {
HomeFeedView(user: user)
}
.enableInjection()
}
}

Expand Down
3 changes: 3 additions & 0 deletions Nos/Views/SideMenu/SideMenuContent.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import SwiftUI
import MessageUI
import Dependencies
import Inject

struct SideMenuContent: View {

@EnvironmentObject private var router: Router
@Environment(CurrentUser.self) private var currentUser
@Dependency(\.analytics) private var analytics
@ObserveInjection var inject

@State private var isShowingReportABugMailView = false
@State private var shareNosPressed = false
Expand Down Expand Up @@ -118,6 +120,7 @@ struct SideMenuContent: View {
ProfileEditView(author: destination.profile)
}
}
.enableInjection()
}
}

Expand Down

0 comments on commit 0dd8f24

Please sign in to comment.