Post

Replies

Boosts

Views

Activity

Using an @EnvironmentObject Breaks Xcode Previews
macOS 12.1, Xcode 13.2.1 I'm using an ObserveableObject to store all of my settings data for my macOS app. My issue is that while using an EnvironmentObject setup works great for easy access to my settings and view updating, Xcode fails to generate previews when they're in use. I've tested this with the following code which works just fine: @ObservedObject var settingsData: SettingsData = SettingsData() //@EnvironmentObject var settingsData: SettingsData and then this code, which doesn't generate a preview: //@ObservedObject var settingsData: SettingsData = SettingsData() @EnvironmentObject var settingsData: SettingsData The error Xcode provides is the following: MessageSendFailure: Message send failure for send previewInstances message to agent ================================== |  MessageError: Connection interrupted I can provide more of my code if needed but I wasn't sure if any of it had to do with this or if this is just an Xcode issue.
2
1
2.5k
Jan ’22
Previews do not load in Xcode 13
While trying to generate previews in Xcode 13, I am presented with the error MessageSendFailure: Message send failure for send previewInstances message to agent. I've tried a few projects and it seems to affect all of them. Body of the diagnostics window: ================================== | RemoteHumanReadableError | | LoadingError: failed to load library at path "/Users/campbell/Library/Containers/com.NCX-Programming.SwiftUI-Test/Data/ContentView.2.preview-thunk.dylib": Optional(dlopen(/Users/campbell/Library/Containers/com.NCX-Programming.SwiftUI-Test/Data/ContentView.2.preview-thunk.dylib, 2): no suitable image found. Did find: | /Users/campbell/Library/Containers/com.NCX-Programming.SwiftUI-Test/Data/ContentView.2.preview-thunk.dylib: code signature in (/Users/campbell/Library/Containers/com.NCX-Programming.SwiftUI-Test/Data/ContentView.2.preview-thunk.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)) I've tried cleaning the build folder to remove any old files it might be trying to use but I've had no luck. The program itself compiles and runs just fine. Any ideas?
1
1
3.4k
Sep ’21