Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
48 views

The top level of my app looks like: struct MyApp: App { var body: some Scene { DocumentGroup(newDocument: MyDocument()) { file in MyContentView(document: file.$document) ...
microtherion's user avatar
  • 4,098
1 vote
1 answer
89 views

In the following code, the Xcode Preview crashes when the array is more than 9 elements but does not crash with 9 or less elements. CompileDylibError: Failed to build ContentView.swift Compiling ...
Jay's user avatar
  • 35.8k
0 votes
1 answer
94 views

I'm building a modular iOS app with SwiftUI views in a framework target (MyFrameworkTarget). I added a new .xcassets catalog to this target and defined some named colors like "durationBackground&...
Sidharth J Dev's user avatar
0 votes
2 answers
103 views

I have created an app that lists recipes on startup. The app fetches data from a URL and downloads static data. When I scroll down the list, it downloads and caches the images using CacheManager. Once ...
alvaro76's user avatar
-3 votes
1 answer
481 views

Xcode Errors: "Build failed because DotLottie.swiftmodule is not built for arm64. Would you like to show all run destinations instead?" "Ensure all targets are configured to build for ...
Tomas's user avatar
  • 179
2 votes
3 answers
842 views

My SwiftUI app consists of different views with their own view models which handle data fetching etc. This works fine in the simulator, but I'd really like to be able to use previews and have each ...
ADB's user avatar
  • 729
10 votes
2 answers
1k views

Up until Xcode 16, it was possible to check in build scripts of your Xcode project via the ENABLE_PREVIEWS environment variable whether a build for a SwiftUI preview is being executed. This made it ...
ITGuy's user avatar
  • 865
1 vote
0 answers
202 views

I am trying to modularize my iOS project and extract a feature as a module using SPM. This module contains some SwiftUI code that I want to test with Xcode Previews on a real device. The preview works ...
Alex Fox's user avatar
1 vote
1 answer
553 views

I would like to use SwiftUI previews for my view, which is built as a container that contains other Views. For example, public struct ContainerView<Content: View>: View { private let title: ...
invalidArgument's user avatar
1 vote
0 answers
307 views

Working with SwiftData and it seems when I try to access an array within the model Previews crash. There is no error message, just a black preview and the "Preview Crashed" message (opposed ...
markb's user avatar
  • 1,381
2 votes
0 answers
516 views

EDIT: I solved this issue a while ago by just updating xcode lol. Thought I would update this answer in case anybody comes across it I am using Xcode version 14.3.1 and my canvas has randomly stopped ...
Nate's user avatar
  • 41
1 vote
2 answers
887 views

Is there any way to detect if the build was triggered by the SwiftUI Preview from inside Build Phases - Run Script? I'm using swiftlint with --fix --format, the problem is when I have the Preview open ...
fer0n's user avatar
  • 1,313
1 vote
1 answer
600 views

Problem It appears that fonts, added to a swift package, somehow breaks my Previews/Canvas. It should be noted that I'm working with an acircular dependency graph, meaning almost everything is ...
xTwisteDx's user avatar
  • 2,520
0 votes
1 answer
480 views

Xcode version 14.3.1 Minimum Deployments 16.4 The problem started when I moved the Xcode to Applications(previously it was in somewhere else).
Parth Dasawant's user avatar
4 votes
0 answers
190 views

I am looking for how to do the equivalent of this: #Preview("light") { BillView(bill: prevBill) } #Preview("dark") { BillView(bill: prevBill) .preferredColorScheme(...
Jeff's user avatar
  • 4,289
0 votes
1 answer
217 views

I'm trying to get previews in Xcode 15 however it always fails to load, showing the following issue: I'm getting the following error in my AppDelegate: could not find module 'Amplify' for target '...
SamuraiMelon's user avatar
3 votes
0 answers
687 views

I have the following code in SwiftUI preview macro. #Preview { @StateObject static var store = Store() ... } And it fails with the error: Static properties may only be declared on a ...
Deepak Sharma's user avatar
2 votes
1 answer
1k views

I'm just trying to get #Preview to work with a UIKit ViewController. See screenshot for details. Nothing special, IMHO instantiating the VC in the #Preview should just work. But all of the graphical ...
brainray's user avatar
  • 12.9k
0 votes
1 answer
1k views

I am trying to use SwiftUI in my project where I was using UIKit only, until now. The problem is that Preview in Xcode is not working even for very simple View with Text("Hello World"). Code ...
Libor Zapletal's user avatar
-2 votes
2 answers
262 views

I have this overlay view and when a button is pressed it's supposed to refresh the view by calling a function in the view model. The code does work on the app itself but doesn't work within the ...
Yoast's user avatar
  • 51
4 votes
1 answer
3k views

Xcode Version 15.0 (15A240d) IOS 17 Workstation - MacBook Pro 14 inch 2021 with M1 Pro CPU Summary: I have been using the Observable Object protocol with no issues, including previews. But now with ...
Isaac Carrington's user avatar
0 votes
0 answers
68 views

Here is my PostListView. struct PostListView: View { @StateObject private var viewModel = PostViewModel(service: PostService()) var body: some View { NavigationView { VStack { ...
Shourob Datta's user avatar
0 votes
1 answer
2k views

My app is made up of two Views. When I run it on the emulator, it looks like the following (minus the red bar - I added that to the image to make explaining this a bit easier): All of the controls ...
raddevus's user avatar
  • 9,296
0 votes
2 answers
2k views

I have a SwiftUI view with a view model associated to it. struct BookmarksView: View { @StateObject private var viewModel = BookmarksViewModel() var body: some View { switch ...
Lorenzo B's user avatar
  • 33.4k
4 votes
0 answers
260 views

Is there any way to preview the toolbar for a macOS SwiftUI app? I can't figure out how to structure my preview to get it to display the toolbar items in a view. It does the right thing when actually ...
Rick's user avatar
  • 3,967
5 votes
0 answers
1k views

We have an MLPackage file in our SwiftUI project. Whenever we try to load Previews on a View file, Xcode gets stuck in an infinite loop of "Build for Previews". The builds succeed, but ...
Nate Lowry's user avatar
0 votes
1 answer
278 views

I'm not sure if this is a bug or not, but from what I can tell, @StateObject seems to behave like @ObservedObject when used with static properties. Expected behaviour: A single instance is made, that'...
Alexander's user avatar
  • 63.9k
7 votes
0 answers
672 views

I have a Mac App that's mostly written in AppKit. Over time, I'm adding new views in SwiftUI, and all the while I've been using SwiftUI previews to preview both my new SwiftUI views, and my old AppKit ...
Alexander's user avatar
  • 63.9k
6 votes
2 answers
5k views

I know how to print in a SwiftUI view. I would like to do the same within a SwiftUI preview so that I don't need to run the app in the simulator to see the logs. For example here I'm trying to print a ...
Senseful's user avatar
  • 92.6k
4 votes
0 answers
1k views

Is There a way to optimize SwiftUI preview builds so it can be done faster ? I have a very big project and each time I need to do a View preview it would take forever building the entire project For ...
Marchal's user avatar
  • 466
5 votes
0 answers
149 views

According to the documentation, we should be able to set the locale on previews and the following code should work: import SwiftUI struct TestView: View { var timeFormatter: DateFormatter { ...
adauguet's user avatar
  • 1,008
0 votes
1 answer
133 views

I'm currently using UIKit for making views and now I want to preview it just like SwiftUI. But my canvas preview looks like a device rather than the size of view itself. What have I done wrong? import ...
MrGarlic's user avatar
0 votes
1 answer
383 views

Everytime I attempt to use SwiftUI previews I am greeted with this error. I am running Xcode 14.1 on Ventura 13.0.
nail181's user avatar
  • 11
30 votes
2 answers
10k views

I want my preview to only have the size of the view and not show the whole iPhone. I have already tried it with this code: struct TimerCardView: View { var body: some View { Text(&...
SwiftUI_Max's user avatar
2 votes
0 answers
636 views

I am trying to optimize my SwiftUI preview build times. In my project I have two schemes, one for dev and one for prod, with different configurations. When I kick off a SwiftUI preview build, both ...
cgaisl's user avatar
  • 41
7 votes
2 answers
2k views

Having an issue running the preview for SwiftUI views inside my framework. Here is a project structure. Preview for SwiftUI views that are in the main target ( ContentView, GradientView) work as ...
Eugene P's user avatar
  • 572
1 vote
2 answers
203 views

I know this isn't totally SwiftUI related but please bear with me. Using this excellent video by Karin Prater https://www.youtube.com/watch?v=ZHK5TwKwcE4 I have built an app using the spaceX API here :...
jat's user avatar
  • 397
4 votes
1 answer
953 views

I am using a SPM package and added one simple DashboardView inside the package as below: import SwiftUI struct DashboardView: View { var body: some View { Text("Hello World") ...
Enes F.'s user avatar
  • 535
8 votes
0 answers
1k views

I'm getting this error because of a Swift package I have added to my project. HumanReadableSwiftError SettingsError: noExecutablePath(<IDESwiftPackageStaticLibraryProductBuildable:ObjectIdentifier(...
Berry Blue's user avatar
  • 16.9k
3 votes
2 answers
4k views

while exploring the swiftUI and creating my first swiftUI app in Xcode, it is throwing an error for the preview saying - Cannot preview in this file, Cannot connect to [Device Name]. While it's ...
Mohit G.'s user avatar
  • 1,225
2 votes
1 answer
3k views

One of the big strengths of SwiftUI is modularity: I don't need to build one large view (controller), I can easily compose my main view from many smaller view components. But developing these view ...
Mischa's user avatar
  • 17.5k
2 votes
0 answers
650 views

I am making a TODO app on Xcode (ver 13.4) on mac. When TodoEditor's "Add" button is tapped, the preview screen should show a ContentView and the ContentView should show updated Todo ...
peridotite's user avatar
2 votes
1 answer
666 views

Since Swift has no real first-class namespace support, enums are often used as a replacement. When doing so, SwiftUI previews don't build anymore: import SwiftUI enum Namespace { } extension ...
Gereon's user avatar
  • 18k
3 votes
1 answer
669 views

.previewLayout(.fixed(width: 480, height: 320)) has no effect in Xcode 13.4 and Xcode 14 beta 3 The preview is shown in portrait vs expected landscape
Anton Tropashko's user avatar
0 votes
0 answers
390 views

SwiftUI Previews are great and quickly allow us to preview views. I know its possible to create a wrapper to preview UIKit views, however I’m having trouble getting a CollectionViewCell preview to ...
Richard Witherspoon's user avatar
0 votes
2 answers
370 views

After updating Xcode to 13.4 my core data persistence stack started to fail for SwiftUI previews and Xcode Unit tests. Error message: Unresolved error Error Domain=NSCocoaErrorDomain Code=134081 "...
Ramis's user avatar
  • 17.1k
1 vote
1 answer
1k views

SwiftUI state properties should be declared as private. This is good for encapsulating their values from containing views, but prevents a preview from setting a non-default state using the default ...
Edward Brey's user avatar
  • 42.1k
1 vote
1 answer
943 views

I am running into a problem trying to use an in memory realm configuration with previews. When the preview executes it returns an error. The diagnostics gives the following error: MessageError: ...
Cosmtar's user avatar
  • 525
4 votes
1 answer
4k views

I am running a pre-build script using scheme. My script has enabled option to provide build settings from target that is being built. This script also gets executed when project is built for SwiftUI ...
Piotr Tobolski's user avatar
4 votes
0 answers
256 views

I have a large mixed language (obj-c, swift & c++) project, it builds and runs fine on all platforms "Build for previews" also seems to complete fine. Opening preview of a particular ...
Nick Hingston's user avatar