【发布时间】:2016-11-28 20:15:33
【问题描述】:
我很难将 Realm 集成到我的项目中。 实际上,我正在遵循官方文档中的指导方针,尽管这对我没有帮助。
当我尝试导入 RealmSwift 时,我得到“没有这样的模块”。
import RealmSwift
在框架中Realm.framework是红色的。
这是我的 Podfile
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'RealmTest' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for RealmTest
pod 'RealmSwift'
target 'RealmTestTests' do
inherit! :search_paths
# Pods for testing
end
target 'RealmTestUITests' do
inherit! :search_paths
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3' # or '3.0'
# Pods for testing
end
end
end
end
【问题讨论】:
-
您可以尝试将 Podfile 的
post_install部分移出target 'RealmTest' do部分,然后再次从终端运行pod install吗? -
@AustinZ 也没有帮助
-
你能构建和运行你的项目吗?这可能会解决问题。第一次编译项目时,即使安装正确,也会出现此错误。
-
@Orlando 这并没有帮助,但已找出主要错误。这很崩溃,因为用 Swift 2.3 编译的模块无法在 Swift 3 中导入。
-
@DanielChepenko 为什么在 XCode 8.1 中使用 Swift 2.3?它不会起作用。