在Swift应用程序中安装Realm [英] Install Realm in a Swift App

查看:194
本文介绍了在Swift应用程序中安装Realm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Realm添加到我用swift编写的应用程序中。我已经按照教程,似乎无法让它工作。最大的问题是,当我尝试导入Realm时,我得到没有这样的模块'Realm'我不知道还有什么可以尝试。你可以在下面看到我的努力。



你可以在这里看到说明:



版本0.86现已用完,这不再是问题。


I am trying to add Realm to my app written in swift. I have followed the tutorial and I can't seem to get it to work. The biggest problem is that when I try to import Realm I get No such module 'Realm' I don't know what else to try. You can see my efforts below.

You can see the instructions here: http://realm.io/docs/cocoa/0.85.0/#swft

I have also copied the instructions below:

Due to the current lack of proper infrastructure for Swift dependency management, using Realm in your project requires the following steps:

  1. Add Realm as a submodule by opening the Terminal, cd-ing into your top-level project directory, and entering the command git submodule add git@github.com:realm/realm-cocoa.git
  2. Open the realm-cocoa folder, and drag Realm.xcodeproj into the file navigator of your Xcode project.
  3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" section in the sidebar.
  4. In the tab bar at the top of that window, open the "Build Phases" panel.
  5. Expand the "Target Dependencies" gorup, and add Realm’s iOS framework.
  6. Expand the "Link Binary with Libraries" group, and add Realm’s iOS framework as well as libc++.dylib.
  7. Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add Realm.framework.
  8. Drag the file at realm-cocoa/Realm/Swift/RLMSupport.swift into the file navigator of your Xcode project, unchecking the "Copy items if needed" checkbox.

Below is what it looks like in my project:

解决方案

I have been talking with the guys at Realm, and it turns out that the latest instructions don't work with Realm <= 0.85 They changed they way the build the framework and it won't work anymore. They said they will release 0.86 later today that should fix the problems anyone is having with Swift. In the meantime I have a test project that anyone can take the latest framework from. https://github.com/smitt04/testRealm

Version 0.86 is now out and this is no longer an issue.

这篇关于在Swift应用程序中安装Realm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆