Fix File Not Found libarclite_iphonesimulator.a in Xcode 14.3
Posts for: #Swift
How to create multiple screen previews in SwiftUI
Today I learned that you can actually create multiple Xcode screen previews in SwiftUI.
Assuming you have a SwiftUI View named ContentView. In the PreviewProvider, create a Group and init multiple ContentView() children inside of it. For example:
struct ContentView_Previews: PreviewProvider { static var previews: some View { Group { ContentView() .previewDevice(PreviewDevice(rawValue: "iPhone 11")) .previewDisplayName("iPhone 11") // Optional ContentView() .previewDevice(PreviewDevice(rawValue: "iPhone 8")) .previewDisplayName("iPhone 8 Dark") .environment(\.colorScheme, .dark) .environment(\.sizeCategory, .accessibilityLarge) ContentView() .
How to use SwiftUI in a UIKit project
Did you know that SwiftUI can be use in UIKit project? To use SwiftUI in UIKit project, you have to make use of UIHostingViewController. It is a UIViewController that basically “host” a SwiftUI view.
Assuming you have a SwiftUI View named SwiftUIView like so:
let swiftUIView = SwiftUIView() Initializing it programmatically To initialize it programmatically, set the SwiftUI View as the rootView of the UIHostingController.
let vc = UIHostingController(rootView: swiftUIView) self.