[英]Can't install Realm library via CocoaPods in Swift 2.0
I am making iOS app in Swift2.0. 我在Swift2.0中制作iOS应用程序。
I tried to install Realm library via CocoaPod. 我试图通过CocoaPod安装Realm库。
It is fine when I execute 'pod install' in command line. 在命令行中执行'pod install'时很好。
But in Xcode project, I can't build my iOS app. 但在Xcode项目中,我无法构建我的iOS应用程序。
There is an error and stop to build. 有一个错误并停止构建。
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: /Users/satoutakeshi/Library/Developer/Xcode/DerivedData/AlermMA-hczduhcpoaudvlgzjrzioeecipfh/Build/Products/Debug-iphonesimulator/AlermMA.app/Frameworks/Realm.framework/Realm (No such file or directory)
It's my Podfile 这是我的Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'RealmSwift'
What should I do to install Realm? 我该怎么做才能安装Realm?
Thanks! 谢谢!
You might be seeing this error because using the RealmSwift
pod is not supported in mixed Objective-C/Swift Apps. 您可能会看到此错误,因为混合的Objective-C / Swift应用程序不支持使用
RealmSwift
pod。 Try using the Objective-C Realm pod: 尝试使用Objective-C Realm pod:
pod 'Realm'
You'll still be able to use Realm in your Swift files, you'll just have to convert the Objective-C syntax to Swift and, of course, the Swift only stuff in RealmSwift
won't be available. 你仍然可以在你的Swift文件中使用Realm,你只需要将Objective-C语法转换为Swift,当然,只有Swift的
RealmSwift
东西才可用。
If your project was in Swift you you would have to install RealmSwift
to use the full swift features: 如果您的项目是在Swift中,则必须安装
RealmSwift
才能使用完整的快速功能:
pod 'RealmSwift'
In your code you have to import both Realm and RealmSwift to use all features: 在您的代码中,您必须导入Realm和RealmSwift才能使用所有功能:
import Realm
import RealmSwift
EDIT: 编辑:
I updated this answer. 我更新了这个答案。 Thanks to Donamite for pointing out that you only need to have `RealmSwift' in the podfile.
感谢Donamite指出你只需要在podfile中拥有`RealmSwift'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.