Post

Replies

Boosts

Views

Activity

Reply to ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS
Here is the code in question to provide more context class HomeViewModel { var pOffers = [Offer]() var forceFetchOffers: Bool = false @MainActor var offersTable: [String: Offer] = [:] var handledAnnouncementIds: Set<String> = [] func fetchOffersAndUpdateCards() { delegate?.setLoadingState(true) Task { await fetchCachedOffersIfNeeded() await refreshCardsFromCachedOffers() } } func fetchCachedOffersIfNeeded() async { guard shouldFetchOffers() else { return } pOffers = await personalization.getOffers() forceFetchOffers = false } func refreshCardsFromCachedOffers() async { let mappedCardsData = await mappedCardData(from: pOffers) await refreshOfferCards(with: mappedCardsData) } func mapToOffersCardData(offer: Offer) async -> OfferCardData? { switch offer.offerType { case .abc: return await hanldeAnnouncementCard(from: offer) case .xyz: return await addItemCardData(from: offer) default: return nil } } @MainActor func mappedCardData(from offers: [Offer]) async -> [OfferCardData] { offersTable.removeAll() handledAnnouncementIds = [] var index: Int = 0 return await offers .asyncCompactMap { guard var cardData = await self.mapToOffersCardData(offer: $0) else { return nil } cardData.cardIndex = index index += 1 offersTable[cardData.id] = $0 return cardData } } func hanldeAnnouncementCard(from offer: Offer) async -> OfferCardData? { if handledAnnouncementIds.contains(offer.itemID) { return nil } handledAnnouncementIds.insert(offer.itemID) return await announcementCardData(from: offer) } func announcementCardData(from offer: Offer) async -> OfferCardData? { guard let announcement = await fetchAnnouncement(for: offer.itemID) else { return nil } return ACardData( ...... ...... } } func showDefaultOfferCards() { Task { let offers = getDefaultOfferTypes() .map { Offer( offerType: $0, offerName: Constants.defaultCardOfferName ) } let defaultCardsData = await mappedCardData(from: offers) await refreshDefaultOfferCards(with: defaultCardsData) } } } public extension Sequence { func asyncCompactMap<T>(_ transform: (Element) async -> T?) async -> [T] { var values: [T] = [] for element in self { guard let transformedElement = await transform(element) else { continue } values.append(transformedElement) } return values } } struct Offer { let itemID: String let offerType: OfferType let offerName: String init( offerType: OfferType, offerName: String = "", itemID: String = "", ) { self.offerType = offerType self.offerName = offerName self.itemID = itemID } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to iOS 17.4 SwiftUI .toolbar(.hidden, for: .tabBar) not work
This is what I did for my tabs and no longer have the problem with system tabbar showing up unexpectedly. @State var activeTab: Screen = .home var body: some View { TabView(selection: $activeTab) { switch activeTab { case .home: HomeRoot() .tag(Screen.home) case .menu: MenuRoot() .tag(Screen.menu) case .rewards: RewardsRoot() .tag(Screen.rewards) case .scan: Scan() .tag(Screen.scan) default: EmptyView() } } .safeAreaInset(edge: .bottom) { TabBarView( activeTab: $activeTab ) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’24
Reply to How to remove space before SwiftUI List Sections?
struct ContentView: View { var body: some View { ScrollView { LazyVStack(alignment: .leading, spacing: 0, pinnedViews: [.sectionHeaders], content: { ForEach(0..<10) { section in Section { ForEach(0..<10) { item in VStack(alignment: .leading, spacing: 0) { Text("List Item \(item)") .frame(minHeight: 50) Divider() } .padding(.leading) } } header: { Text("Section \(section)") .bold() .frame(height: 50) .frame(maxWidth: .infinity) .background(Color(.systemGray6)) } } }) } .clipped() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’23
Reply to SwiftUI Button unintended animation during transition
Try this struct ButtonAnimationTest: View { @State var showButton: Bool = true var body: some View { VStack { if showButton { Button("makeTransition") { withAnimation { showButton.toggle() } } .buttonStyle(MyButtonStyle()) .padding() .background(Color.black) .transition(.slide) } } .animation(.easeIn(duration: 1), value: showButton) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS
Thank you for your help with this. We were able to locate the code that caused the function to be executed from multiple threads.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS
Crash Report
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to ELEMENT_TYPE_OF_SET_VIOLATES_HASHABLE_REQUIREMENTS
Here is the code in question to provide more context class HomeViewModel { var pOffers = [Offer]() var forceFetchOffers: Bool = false @MainActor var offersTable: [String: Offer] = [:] var handledAnnouncementIds: Set<String> = [] func fetchOffersAndUpdateCards() { delegate?.setLoadingState(true) Task { await fetchCachedOffersIfNeeded() await refreshCardsFromCachedOffers() } } func fetchCachedOffersIfNeeded() async { guard shouldFetchOffers() else { return } pOffers = await personalization.getOffers() forceFetchOffers = false } func refreshCardsFromCachedOffers() async { let mappedCardsData = await mappedCardData(from: pOffers) await refreshOfferCards(with: mappedCardsData) } func mapToOffersCardData(offer: Offer) async -> OfferCardData? { switch offer.offerType { case .abc: return await hanldeAnnouncementCard(from: offer) case .xyz: return await addItemCardData(from: offer) default: return nil } } @MainActor func mappedCardData(from offers: [Offer]) async -> [OfferCardData] { offersTable.removeAll() handledAnnouncementIds = [] var index: Int = 0 return await offers .asyncCompactMap { guard var cardData = await self.mapToOffersCardData(offer: $0) else { return nil } cardData.cardIndex = index index += 1 offersTable[cardData.id] = $0 return cardData } } func hanldeAnnouncementCard(from offer: Offer) async -> OfferCardData? { if handledAnnouncementIds.contains(offer.itemID) { return nil } handledAnnouncementIds.insert(offer.itemID) return await announcementCardData(from: offer) } func announcementCardData(from offer: Offer) async -> OfferCardData? { guard let announcement = await fetchAnnouncement(for: offer.itemID) else { return nil } return ACardData( ...... ...... } } func showDefaultOfferCards() { Task { let offers = getDefaultOfferTypes() .map { Offer( offerType: $0, offerName: Constants.defaultCardOfferName ) } let defaultCardsData = await mappedCardData(from: offers) await refreshDefaultOfferCards(with: defaultCardsData) } } } public extension Sequence { func asyncCompactMap<T>(_ transform: (Element) async -> T?) async -> [T] { var values: [T] = [] for element in self { guard let transformedElement = await transform(element) else { continue } values.append(transformedElement) } return values } } struct Offer { let itemID: String let offerType: OfferType let offerName: String init( offerType: OfferType, offerName: String = "", itemID: String = "", ) { self.offerType = offerType self.offerName = offerName self.itemID = itemID } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to In iOS 26, the tab bar never disappears when new controller is pushed
https://developer.apple.com/forums/thread/789148
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to ios18.4 can't debug
Use Xcode 16.3
Replies
Boosts
Views
Activity
Apr ’25
Reply to Error when trying to install application Via Test Flight
Here's the status
Replies
Boosts
Views
Activity
Jun ’24
Reply to iOS 17.4 SwiftUI .toolbar(.hidden, for: .tabBar) not work
This is what I did for my tabs and no longer have the problem with system tabbar showing up unexpectedly. @State var activeTab: Screen = .home var body: some View { TabView(selection: $activeTab) { switch activeTab { case .home: HomeRoot() .tag(Screen.home) case .menu: MenuRoot() .tag(Screen.menu) case .rewards: RewardsRoot() .tag(Screen.rewards) case .scan: Scan() .tag(Screen.scan) default: EmptyView() } } .safeAreaInset(edge: .bottom) { TabBarView( activeTab: $activeTab ) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’24
Reply to Cycle inside app - XCode 15
Move Crashlytics phase to the last step in your build phases
Replies
Boosts
Views
Activity
Oct ’23
Reply to Apple Developer Labs for visionOS closed?
https://developer.apple.com/events/view/upcoming-events?q=vision - Scroll down for more dates.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to shouldChangeCharactersIn called twice on simulator
Remove arm64 from excluded archs of your project build setting. Apple is no longer fixing x86_64 simulator issues.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to How to remove space before SwiftUI List Sections?
struct ContentView: View { var body: some View { ScrollView { LazyVStack(alignment: .leading, spacing: 0, pinnedViews: [.sectionHeaders], content: { ForEach(0..<10) { section in Section { ForEach(0..<10) { item in VStack(alignment: .leading, spacing: 0) { Text("List Item \(item)") .frame(minHeight: 50) Divider() } .padding(.leading) } } header: { Text("Section \(section)") .bold() .frame(height: 50) .frame(maxWidth: .infinity) .background(Color(.systemGray6)) } } }) } .clipped() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Apple requires old and new apps to be built with Xcode 14.1, iOS 16.1 SDK and mac OS 13 or later
Xcode 14.1 requires a Mac running macOS Monterey 12.5 or later. Are you able to update your MacBook Pro to Monterey?
Replies
Boosts
Views
Activity
Jun ’23
Reply to SwiftUI View creates huge gap at the top
Add a Spacer() after the 2 HStacks.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to confirmationDialog crashes with Button.init(action, @ViewBuilder label)
Check the help for confirmationDialog. It states On iOS, tvOS, and watchOS, confirmation dialogs only support controls with labels that are Text. Passing any other type of view results in the content being omitted.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to SwiftUI Button unintended animation during transition
Try this struct ButtonAnimationTest: View { @State var showButton: Bool = true var body: some View { VStack { if showButton { Button("makeTransition") { withAnimation { showButton.toggle() } } .buttonStyle(MyButtonStyle()) .padding() .background(Color.black) .transition(.slide) } } .animation(.easeIn(duration: 1), value: showButton) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23