I wrote an extension for SwiftUI Font which introduces a couple of custom fonts.
extension Font {
static let solDisplay: Font = .custom("Gilroy", size: 36)
static let solHeadline: Font = .custom("Gilroy", size: 24)
}
Now for some reason there is the following error appears during the build process: Cannot infer contextual base in reference to member 'heavy'.
Interestingly this error was found by someone else while doing a Pull Request - I did not notice any of these errors locally, but it appears to happen to only some. Currently 2 out of 4 people in our team have the errors where the other ones don't.
struct AssetsDemoPage: View {
let fonts: [(String, Font)] = [
("Display - Heavy", .solDisplay.weight(.heavy)), // Error Happening here
("Display - Light", .solDisplay), // No error here!
("Headline - Heavy", .solHeadline.weight(.heavy)), // Error Happening here
("Headline - Light", .solHeadline), // No error here!
]
var body: some View {
NavigationView {
List {
Section(header: Text("Fonts")) {
ForEach(fonts, id: \.0) { name, font in
Text(name)
.font(font)
}
}
}
.navigationBarTitle(Text("Assets"), displayMode: .inline)
}
}
}