[英]Can not render SwiftUI preview from Cocoapods
I have a SwiftUI
struct in a common library that I ship to myself.我在自己发送的公共库中有一个
SwiftUI
结构。
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 .还在cocoapods git hub issue tracker 上找到了这个。
You could try adding this in your Podfile (as suggested by JamesHurst , cltnschlosser and andersio )您可以尝试将其添加到您的 Podfile 中(如JamesHurst 、 cltnschlosser和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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.