Posts

Post marked as solved
3 Replies
Great ideas! Currently there is not a way to automatically save out an image / screencapture of a preview, but we know this is an often requested feature :) Out of curiosity, how would you use the screenshot you export?
Post not yet marked as solved
1 Replies
Hi, Sorry to hear you are having problems getting previews working. Does build and running in the simulator work? The best next step will be to file a feedback with diagnostics so we can take a look. We will need the diagnostics Xcode Previews generates in order to make sure we understand the error the previews system is encountering.
Post not yet marked as solved
4 Replies
Hi, Sorry to hear you are having problems getting previews working. This error can often indicate a crash in your application when it launches, or a problem with the simulator. If you look into the folder ~/Library/Logs/DiagnosticReports, do you see any crash reports for your app? If not, the best next step will be to file a feedback with diagnostics so we can take a look. We will need the diagnostics Xcode Previews generates in order to make sure we understand the error the previews system is encountering. If you are having issues with macOS, catalyst or on-device iOS previews then download and install the logging profile for your device. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift Attach the sysdiagnose to the bug report as well as the diagnostics using the instructions below. Then when you get an error in Xcode Previews, an error banner appears in the canvas Click the “Diagnostics” button in that banner (or if the banner is missing you can use the menu: Editor > Canvas > Diagnostics) In the sheet that appears, click “Generate Report” in the bottom left of the sheet Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)
Post marked as solved
1 Replies
Yes this can be expected. It can also happen in scenarios for normal app flows on-device, so this isn't specific to previews. Instead of using UIScreen.main.bounds, you should use a GeometryReader on your view to measure the space you are actually being allocated, or to use size classes to detect the semantic "size" of the space your view is ultimately allocated.
Post marked as solved
1 Replies
Yes this is a known issue. Currently previews are not supported inside of static libraries. As a workaround you could create a dynamic library or framework target in addition to the static library and put the file in both targets. Then, make sure your scheme is building the framework/dynamic library target even if it's not being included into any of your shipping apps, etc.
Post not yet marked as solved
2 Replies
Yes. Any types unused by your actual application code are removed by the compiler, which includes PreviewProvider types. You can validate this by running nm on your Release binary and grep'ing for your preview provider type, which you should see is not included in any of the known symbols in the binary. You can also guarantee that your shipping code doesn't accidentally reference your preview provider types by either: Putting them in a file that is included in your "Development Assets" (a project setting in the "General" tab that lets you specify paths to files/folders omitted from the archive build) Wrapping them in #if DEBUG compiler directives However, both of those should be unnecessary as the compiler will dead code strip away those unused types for release.
Post marked as solved
2 Replies
This is a known issue. You could try adding a typealias View = SwiftUI.View to the top of the file: does that fix the problem?
Post marked as solved
1 Replies
This is driven by the "Optimization Level" setting in the build settings for the target that contains the file you're editing. One of two things is happening… That value accidentally got set to something other than Onone for your debug build The scheme you're using has a configuration set that isn't your debug one. By default, projects come with a "Debug" and "Release" config. The "Debug" config is configured to build Onone, which means without optimizations. And the "Release" config is configured to build with optimizations. You just need to double check the build configuration selected for your scheme is your debug (usually "Debug") one.