So i am pretty new to Xcode, but i have been using Python and other language for some while. But I am quite new to the game of view and view control. So it may be that i have over complicated this a bit - and it may be that I have some wrong understanding of the dependencies and appcontroller (that i thought would be a good idea). So here we have a main file we call it app.swift, we have a startupmanager.swift, a appcoordinator and a dependeciescontainer. But it may be that this is either a overkill - or that I am doing it wrong.
So my thought was that i had a dependeciecontainer, a appcoordinator for the views and a startupmanager that controll the initialized fetching. I have controlled the memory when i run it - checking if it is higher, lower eg - but it was first when i did my 2 days profile i saw a lot of new errors, like this: Fikser(7291,0x204e516c0) malloc: xzm: failed to initialize deferred reclamation buffer (46). and i also get macro errors, probably from the @Query in my feedview.
So my thought was that a depencecie manager and a startupmanager was a good idea together with a app coordinator.
But maybe I am wrong - maybe this is not a good idea? Or maybe I am doing some things twice? I have added a lot of prints and debugs for checking. But it seems that it starts off to heavy?
import SwiftUI
import Combine
@MainActor
class AppCoordinator: ObservableObject {
@Published var isLoggedIn: Bool = false
private var authManager: AuthenticationManager = .shared
private var cancellables = Set<AnyCancellable>()
private let startupManager: StartupManager
private let container: DependencyContainer
@Published var path = NavigationPath()
enum Screen: Hashable, Identifiable {
case profile
case activeJobs
case offers
case message
var id: Self { self }
}
init(container: DependencyContainer) {
self.container = container
self.startupManager = container.makeStartupManager()
setupObserving()
startupManager.start()
print("AppCoordinator initialized!")
}
private func setupObserving() {
authManager.$isAuthenticated
.receive(on: RunLoop.main)
.sink { [weak self] isAuthenticated in
self?.isLoggedIn = isAuthenticated
}
.store(in: &cancellables)
}
func userDidLogout() {
authManager.logout()
path.removeLast(path.count)
}
func showProfile() {
path.append(Screen.profile)
}
func showActiveJobs() {
path.append(Screen.activeJobs)
}
func showOffers() {
path.append(Screen.offers)
}
func showMessage() {
path.append(Screen.message)
}
@ViewBuilder
func viewForDestination(_ destination: Screen) -> some View {
switch destination {
case .profile:
ProfileView()
case .activeJobs:
ActiveJobsView()
case .offers:
OffersView()
case .message:
ChatView()
}
}
@ViewBuilder
func viewForJob(_ job: Job) -> some View {
PostDetailView(
job: job,
jobUserDetailsRepository: container.makeJobUserDetailsRepository()
)
}
@ViewBuilder
func viewForProfileSubview(_ destination: ProfileView.ProfileSubviews) -> some View {
switch destination{
case .personalSettings:
PersonalSettingView()
case .historicData:
HistoricDataView()
case .transactions:
TransactionView()
case .helpCenter:
HelpcenterView()
case .helpContract:
HelpContractView()
}
}
enum HomeBarDestinations: Hashable, Identifiable {
case postJob
case jobPosting
var id: Self { self }
}
@ViewBuilder
func viewForHomeBar(_ destination: HomeBarView.HomeBarDestinations) -> some View {
switch destination {
case .postJob:
PostJobView()
}
}
}
import Apollo
import FikserAPI
import SwiftData
class DependencyContainer {
static var shared: DependencyContainer!
private let modelContainer: ModelContainer
static func initialize(with modelContainer: ModelContainer) {
shared = DependencyContainer(modelContainer: modelContainer)
}
private init(modelContainer: ModelContainer) {
self.modelContainer = modelContainer
print("DependencyContainer being initialized at ")
}
@MainActor
private lazy var userData: UserData = {
return UserData(apollo: Network.shared.apollo)
}()
@MainActor
private lazy var userDetailsRepository: UserDetailsRepository = {
return UserDetailsRepository(userData: makeUserData())
}()
@MainActor
private lazy var jobData: JobData = {
return JobData(apollo: Network.shared.apollo)
}()
@MainActor
private lazy var jobRepository: JobRepository = {
return JobRepository(jobData: makeJobData(), modelContainer: modelContainer)
}()
@MainActor
func makeUserData() -> UserData {
return userData
}
@MainActor
func makeUserDetailsRepository() -> UserDetailsRepository {
return userDetailsRepository
}
@MainActor
func makeStartupManager() -> StartupManager {
return StartupManager(
userDetailsRepository: makeUserDetailsRepository(),
jobRepository: makeJobRepository(),
authManager: AuthenticationManager.shared,
lastUpdateRepository: makeLastUpdateRepository()
)
}
@MainActor
func makeJobData() -> JobData {
return jobData
}
@MainActor
func makeJobRepository() -> any JobRepositoryProtocol {
return jobRepository
}
@MainActor
private lazy var jobUserData: JobUserData = {
return JobUserData(apollo: Network.shared.apollo)
}()
@MainActor
private lazy var jobUserDetailsRepository: JobUserDetailsRepository = {
return JobUserDetailsRepository(jobUserData: makeJobUserData())
}()
@MainActor
func makeJobUserData() -> JobUserData {
return jobUserData
}
@MainActor
func makeJobUserDetailsRepository() -> JobUserDetailsRepository {
return jobUserDetailsRepository
}
@MainActor
private lazy var lastUpdateData: LastUpdateData = {
return LastUpdateData(apollo: Network.shared.apollo)
}()
@MainActor
private lazy var lastUpdateRepository: LastUpdateRepository = {
return LastUpdateRepository(lastUpdateData: makeLastUpdateData())
}()
@MainActor
func makeLastUpdateData() -> LastUpdateData {
return lastUpdateData
}
@MainActor
func makeLastUpdateRepository() -> LastUpdateRepository {
return lastUpdateRepository
}
}```
Post
Replies
Boosts
Views
Activity
yesterday my Xcode app worked, I upgraded my Xcode and simulator today, but now i suddenly get:
error: the replacement path doesn't exist: "/var/folders/61/cs5w33tx7m92yq6t55h9w7k00000gn/T/swift-generated-sources/@__swiftmacro_6Fikser8FeedViewV4jobs33_842833018C1C855C625C2C0F4D027584LL5QueryfMa_.swift"
error: the replacement path doesn't exist: "/var/folders/61/cs5w33tx7m92yq6t55h9w7k00000gn/T/swift-generated-sources/@__swiftmacro_6Fikser8FeedViewV4jobs33_842833018C1C855C625C2C0F4D027584LL5QueryfMa_.swift"
error: the replacement path doesn't exist: "/var/folders/61/cs5w33tx7m92yq6t55h9w7k00000gn/T/swift-generated-sources/@__swiftmacro_6Fikser4UserC8username18_PersistedPropertyfMa_.swift"
error: the replacement path doesn't exist: "/var/folders/61/cs5w33tx7m92yq6t55h9w7k00000gn/T/swift-generated-sources/@__swiftmacro_6Fikser4UserC8username18_PersistedPropertyfMa_.swift"
error: the replacement path doesn't exist: "/var/folders/61/cs5w33tx7m92yq6t55h9w7k00000gn/T/swift-generated-sources/@__swiftmacro_6Fikser4UserC8username18_PersistedPropertyfMa_.swift"
and i also get this:
objc[11474]: Class AKBiometricRatchetUtility is implemented in both /Library/Developer/CoreSimulator/Volumes/iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKitUI.framework/AuthKitUI (0x12ff2d898) and /Library/Developer/CoreSimulator/Volumes/iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit (0x114a0b1f0). One of the two will be used. Which one is undefined.
``` can it be that they are some how relatet? Or what else can it be?
I have tried to delete derrieved data, clean folder eg.
I am developing an Xcode app with a job feed, with profile view, with chat eg. I fetch using federatet queries to my microservices thru Apollo Router. Infront of the Apollo Router i Have a Kong that adds a X user ID, that the microservices use for personalized feed and other user info. The info is stored with SwiftData. My thought is that i should add a better way of controlling when i need to fetch. I have a “lastupdateAPI” with different entities (profile, profile picture eg). So when nothing has changed we do not fetch. But rather then using a own API for this, isnt ETag better? Or is it any other recommendations with Xcode Swiftui. Good strategies for not fetching what i already have?
I am developing an Xcode app with a job feed, with profile view, with chat eg. I fetch using federatet queries to my microservices thru Apollo Router. Infront of the Apollo Router i Have a Kong that adds a X user ID, that the microservices use for personalized feed and other user info. The info is stored with SwiftData. My thought is that i should add a better way of controlling when i need to fetch. I have a “lastupdateAPI” with different entities (profile, profile picture eg). So when nothing has changed we do not fetch. But rather then using a own API for this, isnt ETag better? Or is it any other recommendations with Xcode Swiftui. Good strategies for not fetching what i already have?
I working on a app, both a wep-app, the prototype of the webapp is ready and i started don my IOS MVP for a couple of weeks ago. Since the SPA is written in ViteJs it was «easy» to think that RN was a good way of making the MVP. Since I just started its not so «hard» to change, and now I am wondering about doing that. After I upgraded from 0.75 to 0.76 problems is knocking on my door all the time, and my time is used for making Metro eg. run, rather then develop the app. I have a Oauth2 PKCE server running and over time other known Oauth2 providers will be implemented: google, apple eg. So since I am looking for other ways to develop it Swift came up. How is Oauth PKCE with Swift? Is it some libraries that is recommended to use is it any well known problems with Swift and PKCE?
KR