我在一个自带的公用库中有一个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()
}
}
我单击文件后,所见即所得预览无法加载
点击“诊断”时,我会看到类似这样的内容:
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:
有什么想法吗?我删除了衍生数据,进行了清理和构建。
答案 0 :(得分:1)
您可以尝试将其添加到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