ios - 无法在 Swift 2.0 中通过 CocoaPods 安装 Realm 库

标签 ios swift2 realm cocoapods

我正在使用 Swift2.0 制作 iOS 应用。

我尝试通过 CocoaPod 安装 Realm 库。

当我在命令行中执行'pod install'时没问题。

但是在 Xcode 项目中,我无法构建我的 iOS 应用。

出现错误,停止构建。

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)

这是我的 Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'RealmSwift'

我应该如何安装 Realm?

谢谢!

最佳答案

您可能会看到此错误,因为在混合的 Objective-C/Swift 应用程序中不支持使用 RealmSwift pod。尝试使用 Objective-C Realm pod:

pod 'Realm'

你仍然可以在你的 Swift 文件中使用 Realm,你只需要将 Objective-C 语法转换为 Swift,当然,RealmSwift 中的 Swift 独有的东西赢了有空。

关于ios - 无法在 Swift 2.0 中通过 CocoaPods 安装 Realm 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33029312/

相关文章:

swift - 如何(优雅地)将 Swift 枚举与关联值持久化——或者我应该避免它们?

ios - NSPhotoLibraryUsageDescription 在 info.plist 中提供,但苹果仍然要求提供一个

ios - UILabel sizeToFit 不适用于自动布局 ios6

ios - 应用程序 "Alarmy"能够从后台状态播放 iTunes 歌曲...如何?

android - 未调用 RealmResults 的 Realm 更改监听器

javascript - React Native 中应用被杀死后存储数据的数据库

ios - NSMutableURLRequest 的响应不包含信息

ios - 自定义对象数组 - Swift

swift - NSView 的 mouseMoved 永远不会被调用

ios - 如何在 Swift Playground 中使用 STDIN