Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Xcode Previews

RSS for tag

Create an app UI and configure almost everything your users see using Xcode Previews.

Posts under Xcode Previews tag

121 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

CommandLineTools SDK error: conflicting types for 'MPG_PAYLOAD
building gcc14-libgcc14 using Macports + Apple clang returns following error In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/message.h:78, from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/arm/thread_status.h:40, from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/machine/thread_status.h:35, from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach-o/loader.h:52, from /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach-o/dyld.h:30, from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc14/libgcc14/work/gcc-14.2.0/libgcc/config/darwin-crt-tm.c:29: /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:510:1: error: conflicting types for 'MPG_PAYLOAD'; have 'uint64_t(uint8_t, uint32_t, uint32_t)' {aka 'long long unsigned int(unsigned char, unsigned int, unsigned int)'} 510 | MPG_PAYLOAD(uint8_t flag, uint32_t a, uint32_t b) | ^~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:498:1: note: previous definition of 'MPG_PAYLOAD' with type 'uint64_t(uint8_t, uint32_t)' {aka 'long long unsigned int(unsigned char, unsigned int)'} 498 | MPG_PAYLOAD(uint8_t flag, uint32_t a) | ^~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:523:1: error: conflicting types for 'MPG_PAYLOAD'; have 'uint64_t(uint8_t, uint32_t, uint16_t, uint16_t)' {aka 'long long unsigned int(unsigned char, unsigned int, short unsigned int, short unsigned int)'} 523 | MPG_PAYLOAD(uint8_t flag, uint32_t a, uint16_t b, uint16_t c) | ^~~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk/usr/include/mach/port.h:498:1: note: previous definition of 'MPG_PAYLOAD' with type 'uint64_t(uint8_t, uint32_t)' {aka 'long long unsigned int(unsigned char, unsigned int)'} 498 | MPG_PAYLOAD(uint8_t flag, uint32_t a) libgcxx compiles fine if forcing compile using clang20/clang19 there is no error.
0
0
2
2h
Widget Previews in visionOS 26 Beta (Xcode 26 Beta)
Hello, I'm currently developing for visionOS using Xcode's latest beta version. I have a question regarding Widget Previews for visionOS 26: When I create a new Widget Extension target directly from a visionOS project, the generated code does not include the #Preview macro. Following the documentation, I manually added the #Preview macro to a Widget created within a visionOS project, but Xcode then displays an error stating that "This platform does not support previewing widgets." My interpretation is that Widget Previews are currently not supported for Widgets created specifically for visionOS in this beta version. Is this understanding correct? Or am I missing a specific way to implement previews for visionOS Widgets, or is there a particular project setting I might have overlooked? Any clarification or guidance on this matter would be greatly appreciated. Thank you.
1
0
36
13h
Xcode #Playground fails
I'm watching the session video "What's new in Xcode 26" and when I try out the new #Playground macro (in the context of a local package in my project) I see only this activity indicator for about 10-15 minutes: Eventually I do see this error: Despite the error, my local package does not import SwiftUI and has no dependencies other than Foundation. I checked the Xcode 26 release notes and I don't see this issue mentioned. A clean build of my project takes 55 seconds. Is it expected behavior that #Playground would require 10+ minutes to spin up? Is there anything I can to do make the new #Playground macro work correctly? Thank you.
2
0
42
14h
Could not find library with name ”/usr/lib/swift/libswiftWebKit.dylib“
Canvas Previews (targeting macOS) in both Xcode 16.4 & Xcode 26 fail to load, when the project imports a Swift package that imports and uses WebKit. I'm on macOS 15.5. Tried also to bring minimum targets of both the project and the package to 15.0. I see that there are some work-arounds for iOS simulator but nothing for the Mac. Anyone facing the same problem?
5
0
61
1d
Why is Xcode so slow and bad?
I just want to rant why is Xcode such a bad ide and I wish Apple can do a better job on Xcode. Here's why: The preview is so slow. Most of the times it's just faster for me to test on a real device. It is so slow, and many times I need to force quite after it's being unresponsive for sometimes. When I'm working on larger projects, the loading time becomes extremely slow especially when there's other clients that might be reading the same files like a Git client or simply iCloud. The breakpoint is so slow. I don't know why, is it an iOS thing? But when I'm on ASP.Net the breakpoints are super fast. For Xcode it takes a long time to pause and show data. It's so big I don't know why it is so hard for Apple to make their ide better. The community has been unsatisfied with Xcode for a long time. There's many tricks on the internet that you can find to help you resolve some issues with your project that's actually related to Xcode. Instead of using these tricks, Apple should just fix these issues. Learn from Intellij!
1
2
143
2w
Xcode Resets the Canvas (Preview) Window
Hello, In the recent update i installed of Mac and Xcode. After working out the initial problem of Simulator runtimes not found, I created a new project with new problem where When i switch to a different file, or Hide and Show Canvas again it just resets to its size (approx. 50%) of Editor. The current solution is to Pin it and it stays there with right size (No matter which file - with any extension - to switch from or to then). I tried deleting Derived Data folder, Rebooting Mac, Reintsalled Xcode (When Simulator Runtime not found problem) but the problem is there. I also tried trait property but fixedLayout do not work with iOS.
1
0
71
3w
Canvas keeps resizing to 50/50 width in Xcode
Hello, Xcode seems to reset the canvas preview every time I open a file that does not have a preview. This is extremely annoying when working with two editor tabs. The resize happened before only after restarting Xcode since a few weeks it happens always when opening another file. The preview phone does not even take advantage of the resize. Is there a way to fix this? When I work with the file: After opening a file without preview and going back:
1
0
78
3w
Previews globally fail with CouldNotLoadInputObjectFile error
Whenever I try to use SwiftUI previews, the preview fails with a CouldNotLoadInputObjectFile error like this: == PREVIEW UPDATE ERROR: FailedToLaunchAppError: Failed to launch com.my-company.Test | ================================== | | [Remote] CouldNotLoadInputObjectFile: Could not load object file during preview: /Users/me/Library/Developer/Xcode/DerivedData/Test-dzmdthicvcbuwkawncuacsomcdcd/Build/Intermediates.noindex/Test.build/Debug-iphonesimulator/Test.build/Objects-normal/arm64/TestApp.o | | | | path: /Users/me/Library/Developer/Xcode/DerivedData/Test-dzmdthicvcbuwkawncuacsomcdcd/Build/Intermediates.noindex/Test.build/Debug-iphonesimulator/Test.build/Objects-normal/arm64/TestApp.o | | | | ================================== | | | [Remote] XOJITError | | | | | | XOJITError: '/Users/me/Library/Developer/Xcode/DerivedData/Test-dzmdthicvcbuwkawncuacsomcdcd/Build/Intermediates.noindex/Test.build/Debug-iphonesimulator/Test.build/Objects-normal/arm64/TestApp.o': No such file or directory It appears that the preview process cannot find the compiled .o files. However, when I check in Finder, the files do exist and normally running the app works fine. It is noteworthy that this is independent of the XCode project or view I try to preview. It is a global issue on my system. Previews not even work when I create a blank new SwiftUI project in XCode. I tried deleting all caches, derived data, preview caches etc. But without any effect. I have this in XCode 16.3 as well as in 16.4 RC. On macOS Sequoia 15.4.1 on a MacBook Air M4. Does anybody have an idea what might be causing this?
2
1
71
May ’25
SwitUI preview loads indefinitely
Hi! I develop an iOS library and I met an issue with SwiftUI previews in iOS app project with my library integrated. After I open preview, build for preview finishes successfully, but preview itself never appears. I failed to find any error messages or any other indicators of what went wrong or how to fix it. Switching to legacy preview execution seems to fix problem, but I think that is not ideal. Could you help fixing this? Xcode 16.2, Simulator iPhone 16, iOS 18.2 Project to reproduce - https://drive.google.com/file/d/1cU6JKwshK_wQfe9YIqcMg3UGWq45OYlx/view?usp=sharing Preview diagnostics - https://drive.google.com/file/d/1kPcgVSSqreiepGuqhdIoCW2rLSicgsWr/view?usp=sharing
7
0
130
May ’25
Xcode Simulator Can't Boot
I am facing a recurring issue with Xcode iOS simulator. I want to preview a SwiftUI for iOS in Xcode, but the Simulator app fails to boot up. I receive the follow error in Xcode: Cannot Preview in this file. Simulator was shutdown during an update. I have tried the following: Deleting Xcode cache Reinstalling iOS Simulator runtimes Completely uninstalling Xcode and deleting all developer data, then reinstalling None of the above steps fix the problem. The only fix I have found is to completely reinstall MacOS 15.4.1. THIS IS TERRIBLE! I have already reinstalled MacOS 15.4.1 once to fix the issue, and I don't want to do it again. If there is another solution, please help me find it! Thank you!!
10
2
156
May ’25
Setting UserDefaults in Preview
Hello, I've got a View that loads data from UserDefaults. I want to set the value of the UserDefault in the preview so i can see how it looks while developing. However when i am trying to set it in preview, i get the following error when i try set it in preview. 'buildExpression' is unavailable: this expression does not conform to 'View' What is the correct way to set the user defaults in preview? import Foundation class PreferencesViewModel: ObservableObject { @Published var maximumDistance: Double = UserDefaults.standard.value(for: .maximumDistance) as? Double ?? PreferencesViewModel.maximumDistanceOptions[0] { didSet { UserDefaults.standard.set(maximumDistance, for: .maximumDistance) } } #Preview { let preferencesViewModel = PreferencesViewModel() preferencesViewModel.maximumDistance = 5.0 PreferencesView() .environmentObject(PreferencesViewModel()) }
2
0
50
Apr ’25
Previews stopped working in Xcode 16.3 with baffling error message
Upgrading to Xcode 16.3, all previews across my AppKit project stopped working. The error message I'm getting is especially baffling. It says the project could not be built with incremental compilation because SWIFT_COMPILATION_MODE is set to "incremental": I tried clearing DerivedData with no effect. When I click the diagnostics button the information given is not very revealing, at least not to me. If I open the project in Xcode 16.2 everything works perfectly again. I switched over to Previews for all new code but this error situation is quite demotivating. Does anyone have any suggestions?
1
2
153
Apr ’25
Crash in Preview (but not in Simulator) when using fileprivate on a protocol in Swift
Consider this stripped-down example of a view with a view model: import Observation import SwiftUI struct MainView: View { @State private var viewModel = ViewModel() private let items = [0, 1, 2] var body: some View { List { GroupedItemsView( viewModel : viewModel.groupState, groupedItems : [(0, items)] ) } } } fileprivate struct GroupedItemsView<ViewModel: GroupsExpandable>: View { let viewModel : ViewModel let groupedItems : [(ViewModel.GroupTag, [Int])] var body: some View { ForEach(groupedItems, id: \.0) { groupTag, items in Text("nothing") } } } fileprivate protocol GroupsExpandable: AnyObject { // HERE associatedtype GroupTag: Hashable } fileprivate final class GroupState<GroupTag: Hashable>: GroupsExpandable {} @Observable fileprivate final class ViewModel { var groupState = GroupState<Int>() } #Preview { MainView() } This compiles and runs fine in the Simulator, but it crashes in the Preview. However, when I remove the fileprivate modifier before GroupsExpandable (see HERE), it also runs in the Preview. What is the reason for this? Bug in Preview? Error on my side somewhere? Thanks. System is Xcode Version 16.3 (16E140) on a MacBook Pro 2018 (Intel) running Sequoia 15.3.2 Devices are iPhone 16 Pro Max with iOS 18.3.1, compiler is set to Swift 6.
1
0
54
Apr ’25
Latest version of Xcode has weird Preview issues
So I believe my machine JUST updated to Xcode 16.3 (16E140). But it definitely just installed the latest iOS simulator 18.4. However, now my preview will sometimes give me the error Failed to launch app ”Picker.app” in reasonable time. If I add a space in my code, or hit refresh on the Preview, then it will run on the second or third attempt. Sometimes in between the refreshes, the preview will crash, and then it will work again. Anyone else experiencing this? Any ideas? Thanks
1
1
107
Apr ’25
Xcode 16.3 Doesn't Remember Preview Pane Width
It seems like, by default, the preview pane tries to align to 50% of the editor pane's width. I prefer to shrink the preview pane to around ~30% of the screen so I have more space for code. This used to work fine—at least until I restarted Xcode. I never understood why the setting wouldn’t persist across sessions, but fine, that was a tradeoff I was willing to live with. However, with Xcode 16.3, it seems like Xcode forgets the manually adjusted preview pane width as soon as I switch to a different file. This has definitely impacted my productivity, as I now find myself readjusting the pane size dozens of times in a single session. Am I holding it wrong? Is anyone else experiencing this? And while we’re at it—why not make this a persistent setting so everyone can tweak the width to their liking?
10
8
252
Apr ’25
XCODE Preview: XOJITError: Could not create code file directory for session: Permission denied
I keep running into the following issue when trying to run preview for my application in Xcode. FailedToLaunchAppError: Failed to launch app.a /Users/me/Library/Developer/Xcode/DerivedData/a-aloudjuytoewlldqjfxshbjydjeh/Build/Products/Debug/a.app ================================== | [Remote] JITError | | ================================== | | | [Remote] XOJITError | | | | XOJITError: Could not create code file directory for session: Permission denied`
3
0
64
Apr ’25
SortDescriptor from a generic method crashes Xcode Previews but not Simulator.
I attempted to create a SortDescriptor using a method in enum to sort various different models in SwiftUI lists. But it causes crashes in Xcodes previews but not in the simulator, and I don't know why. Maybe someone could suggest changes. extension Item:ListSorting {} //List sorting is a protocol given to various Models enum ListSortingStyle<T>:String,CaseIterable where T:ListSorting { case alphabetical = "A…Z" case alphabeticalReverse = "Z…A" case createDate = "Newest" case createDateReverse = "Oldest" case editDate = "Latest Edit" case editDateReverse = "Oldest Edit" /// Returns a SortDescriptor matching the enumeration func sortDescriptor() -> SortDescriptor<T> { switch self { case .alphabetical: SortDescriptor<T>(\.name, comparator: .localized, order: .forward) case .alphabeticalReverse: SortDescriptor<T>(\.name, comparator: .localized, order: .reverse) case .createDate: SortDescriptor<T>(\.creationDate, order: .forward) case .createDateReverse: SortDescriptor<T>(\.creationDate, order: .reverse) case .editDate: SortDescriptor<T>(\.editDate, order: .forward) case .editDateReverse: SortDescriptor<T>(\.editDate, order: .reverse) } } } Which is used in struct ItemsList: View { @Environment(\.modelContext) private var modelContext @Query private var items:[Item] = [] init(sortStyle:ListSortingStyle<Item> = .alphabetical) { let sortDescriptor = SortDescriptor<Item>(\.name, comparator: .localized, order: .forward) //(1) This works in preview & simulator //OR let sortDescriptor2 = sortStyle.sortDescriptor() //(2) This crashes in a preview when used in a fetch not in the iOS simulator print(sortDescriptor,sortDescriptor2) let descriptor = FetchDescriptor<Item>(sortBy:[sortDescriptor2]) self._items = Query(descriptor) } var body: some View { ... } } As far as I can see both methods create a SortDiscriptor. If I print the sortDescriptor variable in they look almost identical: //1 SortDescriptor<Item>( order: Foundation.SortOrder.forward, keyString: nil, comparison: Foundation.SortDescriptor<MyApp.Item>.AllowedComparison.comparableString( (extension in Foundation):Swift.String.StandardComparator(options: __C.NSStringCompareOptions(rawValue: 0), isLocalized: true, order: Foundation.SortOrder.forward), \Item. <computed 0x0000000340213b18 (String)>) ) //2 SortDescriptor<Item>( order: Foundation.SortOrder.forward, keyString: nil, comparison: Foundation.SortDescriptor<MyApp.Item>.AllowedComparison.comparableString( (extension in Foundation):Swift.String.StandardComparator(options: __C.NSStringCompareOptions(rawValue: 0), isLocalized: true, order: Foundation.SortOrder.forward), \Item.<computed 0x0000000340022174 (String)>) ) But the one created with the generic method on the enum crashes with the error message: CrashReportError: Fatal Error in DataUtilities.swift MyApp crashed due to fatalError in DataUtilities.swift at line 64. Couldn't find \Item.<computed 0x0000000340022174 (String)> on Item with fields [SwiftData.Schema.PropertyMetadata ...
3
0
58
Apr ’25