Installation and Setup
Swift
- iOS 8 or later, macOS 10.9 or later, all versions of tvOS and watchOS.
- Xcode 8.0 or later required. Realm Swift 2.3.0 was the last version to support Swift 2.x and Xcode 7.3.
-
- Dynamic Framework
- Download the latest release of Realm and extract the zip.
- Go to your Xcode project’s “General” settings. Drag
RealmSwift.framework
andRealm.framework
from the appropriate Swift-versioned directory for your project inios/, osx/, tvos/
orwatchos/
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. - In your unit test target’s “Build Settings”, add the parent path to
RealmSwift.framework
in the “Framework Search Paths” section. - 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
- Install CocoaPods 0.39.0 or later..
- Run
pod repo update
to make CocoaPods aware of the latest available Realm versions. - In your Podfile, add
use_frameworks!
andpod 'RealmSwift'
to your main and test targets. - 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
- From the command line, run
pod install
. - Use the
.xcworkspace
file generated by CocoaPods to work on your project!
- Carthage
- Install Carthage 0.17.0 or later.
- Add
github "realm/realm-cocoa"
to your Cartfile. - Run
carthage update
. - Drag
RealmSwift.framework
andRealm.framework
from the appropriate platform directory inCarthage/Build/
to the “Linked Frameworks and Libraries” section of your Xcode project’s “General” settings. - 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
- iOS 7 or later, macOS 10.9 or later, all versions of tvOS and watchOS.
- Xcode 7.3 or later required.
- Download the latest release of Realm files from here or from Github link and extract the zip.
- Navigate to ios/static/ directory
- Drag Realm.framework to the File Navigator of your Xcode project. Make sure Copy items if needed is selected and click Finish.
- 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.