Apologies if this comes off as a bit of a rant, and
TLDR: Compiler hangs or gives an unhelpful error with any level of complexity in SwiftUI - which makes me want to back to IB
Porting a project over to iPhone. Made great progress the first week.
However, lately I have been encountering compiler bugs where either the build never finishes, or the build take a really long time and ends with just the error :
The compiler is unable to type-check this expression in reasonable time
Sometimes I can get it to go away by playing divide and conquer and finding some small error, but other times with my nested scrollview it just seems unhappy with any level of complexity (and I don't think my views are all that complex compared to lots of other apps out there)
I've read several posts on these forums for things to try and do to fix it but the bottom line is its impacting my ability to produce a working solution in a reasonable amount of time. So considering going back to Interface Builder though it means starting over with some of the code.
If there was another independent way to syntax check my swiftUI code other than line by line myself I'd welcome something like that. The compiler going away and never coming back is very discouraging -- what if I have to make some kind of emergency fix in the future with limited time?
Open for any suggestions.
Xcode : 16.2
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a fairly simple view that consists of a tile and below it a horizontal scrollview. This display with a large gap between the title and the scrollview and I want the title sitting on top of the scrollview -- maybe 2 or 4 point gap. The current gap looks like 80 points or so.
Code:
let section: Section
let userLevel: Int
let stringsViewModel: StringsViewModel
let onItemSelected: (AudioItem) -> Void
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Text(section.title)
.font(.system(size: 18, weight: .medium))
.foregroundColor(.white)
.padding(.leading, 16)
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(section.items, id: \.titleKey) { item in
MeditationItemView(audioItem: item, userLevel: userLevel, stringsViewModel: stringsViewModel)
.onTapGesture {
onItemSelected(item)
}
}
}
.padding(.leading, 0)
.padding(.trailing, 16)
}
}
.padding(.leading, 16)
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI