Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realm support for Swift 3.0

I was wondering whether it is already possible to use Realm with the beta of Swift 3.0.

Although I see a RealmSwift-swift3.0 directory in in the Realm repo, I do not succeed to use it correctly. How should I install it from source?

like image 508
Taco Avatar asked Jun 16 '16 14:06

Taco


People also ask

Does Realm work with SwiftUI?

Realm objects have bindings to SwiftUI controls and, much like toggling the bought property, they already start a realm transaction to write the changes in the database whenever you change those values.

What is Realm for Swift?

Realm Swift is an easy to use alternative to SQLite and Core Data that makes persisting, querying, and syncing data as simple as working directly with native Swift objects. Deploy a sample appView documentation.

Should I use Core Data or Realm?

If your project requires encryption or speed, then Realm is an obvious choice. If your project has a complex data model that changes frequently, then Core Data might be a better choice.


2 Answers

You can use Realm with Swift 3.0, but take into account that the current version is still absolutely experimental.

You can clone the master branch of the realm-cocoa repo from GitHub.

Or you can use Carthage:

github "realm/realm-cocoa.git" "master"

Or if you prefer CocoaPods:

pod 'RealmSwift', :git => 'https://github.com/realm/realm-cocoa.git', :branch => 'master'

If you use Carthage, remember that you must add Realm and RealmSwift frameworks manually (ignore the IBAnimatable framework):

Project configuration image

In fact, I have one of my projects with Xcode 8, Swift 3 and Realm, and it works perfectly :)

like image 82
Jose L Molina Avatar answered Sep 25 '22 01:09

Jose L Molina


Starting from version 1.1.0 Realm is officially compatible with Swift 3.0/Xcode 8.0. See here.

This release brings official support for Xcode 8, Swift 2.3 and Swift 3.0. Prebuilt frameworks are now built with Xcode 7.3.1 and Xcode 8.0.

Here's an extract from the install docs :

If using Xcode 8, paste the following at the bottom of your Podfile, updating the Swift version if necessary:

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'
    end
  end
end
like image 43
Bogdan Farca Avatar answered Sep 23 '22 01:09

Bogdan Farca