use @main in Xcode 12

Following @the.blaggy answer, here is how I managed to run my project on iOS 13: Create a SceneDelegate if you do not have one SceneDelegate.swift class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { let contentView = ContentView() // Use a UIHostingController as window root … Read more

Problems after upgrading to Xcode 12:ld: building for iOS Simulator, but linking in dylib built for iOS, architecture arm64

I resolved this error. The root reason is that Xcode 12 does not allow build arm64 architecture for Simulator. We should set x86_64 for Simulator building. Set “Build Active Architecture Only” to “YES” in target Build Settings tab; Set x86_64 for Simulator: For more answers: Xcode 12, building for iOS Simulator, but linking in object … Read more

Get the current scroll position of a SwiftUI ScrollView

It was possible to read it and before. Here is a solution based on view preferences. struct DemoScrollViewOffsetView: View { @State private var offset = CGFloat.zero var body: some View { ScrollView { VStack { ForEach(0..<100) { i in Text(“Item \(i)”).padding() } }.background(GeometryReader { Color.clear.preference(key: ViewOffsetKey.self, value: -$0.frame(in: .named(“scroll”)).origin.y) }) .onPreferenceChange(ViewOffsetKey.self) { print(“offset >> \($0)”) … Read more