Post

Replies

Boosts

Views

Activity

Reply to Failed to launch app in reasonable time Xcode 16
I've encountered the same issue and was able to track down the root cause. The problem occurs if: The project uses a library The library contains an Objective C extension on a UIKit class with a load method that calls some other method It doesn't seem to matter which method is called in load, anything seems to break previews. I've shared an minimal example of the issue here: https://www.icloud.com/iclouddrive/024UlszLOLDUPKFsKSllSK72g#FailedToLaunchApp Steps to reproduce: Open the PreviewLaunchExample.xcodeproj and try to show the Preview of the ContentView on any iOS 18 device. It will timeout with the error "Failed to launch app "PreviewLaunchExample.app" in reasonable time". The Preview does work when selecting a iOS 17.5 device, as others have reported in this thread. Next, open Test.m in MyLibrary and comment out the line [self description]. Then test the Preview again. The Preview should work as expected. Test setup: macOS 15.0, Xcode 16.0, OS 18 Simulator.
Oct ’24
Reply to How to align content of SwiftuUI ScrollView to top? (MacOS)
I have found a solution. The idea is to read the size of the scroll view and use it as the minimum size of the view inside. extension View { func readSize(onChange: @escaping (CGSize) -> Void) -> some View { background( GeometryReader { geometryProxy in Color.clear .preference(key: SizePreferenceKey.self, value: geometryProxy.size) } ) .onPreferenceChange(SizePreferenceKey.self, perform: onChange) } } struct ExampleView: View { @State var size: CGSize = .zero var body: some View { ScrollView([.horizontal, .vertical]) { Text("Hello World!") .frame(minWidth: size.width, minHeight: size.height, alignment: .topLeading) } .readSize(onChange: { size = $0 }) } } Somewhat ugly, but it works.
3w