swift - 没有这样的模块 RealmSwift
问题描述
这不是一个重复的问题。我已经使用领域很长时间了。最近我收到“没有这样的模块 RealmSwift”的错误。但这仅在发布目标方案中发生,而不在构建目标方案中发生。是否有任何特殊原因说明它为什么不能仅在发布时工作?我在很多地方都看到过这个问题,但这些解决方案都不适合我。
我的 podfile 看起来与此类似:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
#use_modular_headers!
inhibit_all_warnings!
def shared_pods
pod 'RealmSwift'
end
target ‘************’ do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ************
shared_pods
target '************Tests' do
inherit! :search_paths
# Pods for testing
end
end
target '************UITests' do
inherit! :search_paths
# Pods for testing
# shared_pods
end
解决方案
由于我重复了您的问题,因此这更像是一个故障排除步骤而不是直接答案。
您已经使用 Realm 一段时间了,所以您知道这一点,但对于未来的读者,请确保您使用 RealmSwift 的任何文件都包含
import RealmSwift
我刚刚在一个新项目上尝试了您的 podfile,并且也出现了奇怪的行为。我用以下 5 行替换了您的 podfile,它可以正常工作。
project 'Realm Test.xcodeproj'
target 'Realm Test' do
use_frameworks!
platform :osx, '10.13'
pod 'RealmSwift'
end
那是一个 macOS 项目,但它同样适用于 iOS 项目。在那个项目中,我取消了 #platform :ios, '12.0' 的注释
我认为这是问题
inherit! :search_paths
这让目标知道搜索路径但不链接它们。我建议将其更改为
inherit! :complete
这似乎在我的项目中工作。
哦-为了完整起见,我也遇到过一次,解决方案是
将 RealmSwift.framework 的父路径(即包含目录)添加到您的框架搜索路径中。
推荐阅读
- quill - 羽毛笔工具栏多个图像选择
- java - KAFKA:60000 毫秒后无法更新元数据
- javascript - PHP显示结果而不刷新
- java - Java - url.openConnection() 和 httpsUrlConnection.connect() 首次调用时运行缓慢
- django - 单个查询中的两个注释
- javascript - 将 Apache Stanbol 与 Node.js 一起使用
- php - 如何根据 Laravel 中发布的电子邮件从数据库中获取用户名
- python-3.x - Python对类实例的困惑
- python - 使用 Tkinter Menubutton 从数据库添加 Checkbutton 选项
- c# - 如何在 Azure Functions V2 中处理 EF 数据库连接?