realm

Installation and Setup

Swift

  1. iOS 8 or later, macOS 10.9 or later, all versions of tvOS and watchOS.
  2. Xcode 8.0 or later required. Realm Swift 2.3.0 was the last version to support Swift 2.x and Xcode 7.3.
  • Installation

    • Dynamic Framework
    1. Download the latest release of Realm and extract the zip.
    2. Go to your Xcode project’s “General” settings. Drag RealmSwift.framework and Realm.framework from the appropriate Swift-versioned directory for your project in ios/, osx/, tvos/ or watchos/ directory to the “Embedded Binaries” section. Make sure Copy items if needed is selected (except if using Realm on multiple platforms in your project) and click Finish.
    3. In your unit test target’s “Build Settings”, add the parent path to RealmSwift.framework in the “Framework Search Paths” section.
    4. If using Realm in an iOS, tvOS or watchOS project, create a new “Run Script Phase” in your app’s target’s “Build Phases” and paste the following snippet in the script text field:
      bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework/strip-frameworks.sh"

    This step is required to work around an App Store submission bug when archiving universal binaries.

    • CocoaPods
    1. Install CocoaPods 0.39.0 or later..
    2. Run pod repo update to make CocoaPods aware of the latest available Realm versions.
    3. In your Podfile, add use_frameworks! and pod 'RealmSwift' to your main and test targets.
    4. 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'] = '3.0'
          end
        end
      end
    1. From the command line, run pod install.
    2. Use the .xcworkspace file generated by CocoaPods to work on your project!
    • Carthage
    1. Install Carthage 0.17.0 or later.
    2. Add github "realm/realm-cocoa" to your Cartfile.
    3. Run carthage update.
    4. Drag RealmSwift.framework and Realm.framework from the appropriate platform directory in Carthage/Build/ to the “Linked Frameworks and Libraries” section of your Xcode project’s “General” settings.
    5. iOS/tvOS/watchOS: On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:
    /usr/local/bin/carthage copy-frameworks

    and add the paths to the frameworks you want to use under “Input Files”, e.g.:

    $(SRCROOT)/Carthage/Build/iOS/Realm.framework
    $(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework

    This script works around an App Store submission bug triggered by universal binaries.

React-Native

Xamarin

Objective C

  1. iOS 7 or later, macOS 10.9 or later, all versions of tvOS and watchOS.
  2. Xcode 7.3 or later required.
  1. Download the latest release of Realm files from here or from Github link and extract the zip.
  2. Navigate to ios/static/ directory
  3. Drag Realm.framework to the File Navigator of your Xcode project. Make sure Copy items if needed is selected and click Finish.
  4. Click on your project in the Xcode File Navigator. Select your app’s target and go to the Build Phases tab. Under Link Binary with Libraries click + and add libc++.tbd.

Java


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow