I have a SwiftUI
struct in a common library that I ship to myself.
public struct NTextField: View {
public var body: some View {
Text("Hello, World!")
}
public init() {
}
}
struct NTextField_Previews: PreviewProvider {
static var previews: some View {
NTextField()
}
}
I click on the file and the WYSIWYG preview fails to load
When clicking 'Diagnostics' I see something like this:
Error Domain=com.apple.dt.UITestingAgent Code=-1 "failed to load library at path "/Users/<my_app_name>/Library/Developer/Xcode/DerivedData/<my_app_name>/Build/Intermediates.noindex/Previews/<my_app_name>/Products/Debug-iphonesimulator/<my_custom_pod>/<my_custom_pod>.framework/<my_custom_pod>": Library not loaded:
Any ideas? I deleted derived data, cleaned and built.
Also found this on the cocoapods git hub issue tracker.
You can also create new preview structures in an existing SwiftUI view file by choosing Editor > Create Preview. For the complete list of preview customizations, see Previews in Xcode.
There are two shortcuts that you should remember. Both of them will make your life easier during the development cycle of your SwiftUI views. Cmd + Option + Enter shows or hides previews. Cmd + Option + P runs the previews.
Display the SwiftUI Preview To show the preview, select a file that uses SwiftUI in the project navigator, and choose Editor > Canvas. Then click the Resume button in the upper-right corner of the canvas to start the preview. Xcode builds and runs the code, displaying the results directly in the canvas.
You could try adding this in your Podfile (as suggested by JamesHurst, cltnschlosser and andersio)
class Pod::Target::BuildSettings::AggregateTargetSettings
alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths
def ld_runpath_search_paths
return ld_runpath_search_paths_original unless configuration_name == "Debug"
return ld_runpath_search_paths_original + framework_search_paths
end
end
class Pod::Target::BuildSettings::PodTargetSettings
alias_method :ld_runpath_search_paths_original, :ld_runpath_search_paths
def ld_runpath_search_paths
return (ld_runpath_search_paths_original || []) + framework_search_paths
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With