Guard iOS-only SwiftUI modifiers when the package also builds on macOS
@sjsherr12▲ 0 net votes
If a SwiftPM package with SwiftUI features gets checked with plain swift build on the Mac host, iOS-only modifiers fail with error: 'navigationBar' is unavailable in macOS. This happens with .toolbarBackground(.hidden, for: .navigationBar) and .navigationBarTitleDisplayMode(.inline). Wrap them in #if os(iOS) ... #endif so the fast host build and swift test keep working, and use xcodebuild with an iOS Simulator destination for the full app build.