Skip to content

Commit 839a8b7

Browse files
author
Bell App Lab
committed
- Bump to 2.2.1
- Support for Swift 5.3 and Realm 5.3.3 - Added iOS Example code
1 parent 541f694 commit 839a8b7

10 files changed

Lines changed: 365 additions & 130 deletions

File tree

BackgroundRealm.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "BackgroundRealm"
4-
s.version = "2.2.0"
4+
s.version = "2.2.1"
55
s.summary = "A collection of handy classes and extensions that make it easier to work with `RealmSwift` in the background."
66
s.screenshot = "https://github.com/BellAppLab/BackgroundRealm/raw/master/Images/background_realm.png"
77

@@ -22,7 +22,7 @@ For the Objective-C counterpart, see [BLBackgroundRealm](https://github.com/Bell
2222
s.author = { "Bell App Lab" => "apps@bellapplab.com" }
2323
s.social_media_url = "https://twitter.com/BellAppLab"
2424

25-
s.swift_version = '5.0', '5.1', '5.2'
25+
s.swift_version = '5.0', '5.1', '5.2', '5.3'
2626

2727
s.ios.deployment_target = "9.0"
2828
s.osx.deployment_target = "10.11"

CONTRIBUTING.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
1. Fork and clone the repo
66
2. Download Realm into some folder in your machine (it's large and we don't want it in the repo)
77
- [Earliest supported version](https://static.realm.io/downloads/swift/realm-swift-3.0.0.zip) - v3.0.0
8-
- [Latest supported version](https://static.realm.io/downloads/swift/realm-swift-4.1.1.zip) - v3.11.1
8+
- [Latest supported version](https://static.realm.io/downloads/swift/realm-swift-5.3.3.zip) - v5.3.3
9+
3. Rename the unzipped folder from `realm-swift-<version>` to `realm-swift-latest`
910
3. Navigate to your clone's folder and create a symbolic link to the Realm libraries
1011
- `ln -s <path/to/realm> ./Realm`
12+
4. Add `Realm.framework` and `RealmSwift.framework` to the **iOS Example**, **tvOS Example** and **macOS Example** targets
13+
- Change the frameworks' embed strategy to **Embed & Sign**
1114

1215
## Changing Versions
1316

14-
* To change the **Swift** version:
15-
- Go to *Project Navigator* > **Example** > **Example** > **Build Settings** > **Swift Version**
16-
- _Note 1_: This will automatically change the appropriate Realm version too
17-
- _Note_2_: Realm v3.0.0 only supports Swift v4.0
18-
19-
* To change the **Realm** version:
20-
- Go to *Project Navigator* > **Example** > **Example** > **Build Settings** > **REALM_VERSION**
17+
* To change the **Xcode** version:
18+
- Go to *Project Navigator* > **Example** > **Example** > **Build Settings** > **XCODE_VERSION**
2119
- _Note 1_: This will automatically change the appropriate Realm version too

Example/Aux/DummyObject.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// DummyObject.swift
3+
// Example
4+
//
5+
// Created by André Campana on 05/08/2020.
6+
// Copyright © 2020 Bell App Lab. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import RealmSwift
11+
12+
13+
@objcMembers
14+
final class DummyObject: Object
15+
{
16+
override class func primaryKey() -> String? {
17+
return "id"
18+
}
19+
20+
dynamic var id: String = UUID().uuidString
21+
dynamic var text: String = ""
22+
}

Example/Example.xcodeproj/project.pbxproj

Lines changed: 163 additions & 105 deletions
Large diffs are not rendered by default.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1160"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "65982B5520DFFD5A0018F790"
18+
BuildableName = "macOS Example.app"
19+
BlueprintName = "macOS Example"
20+
ReferencedContainer = "container:Example.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "65DB01D820E0009200F514EC"
36+
BuildableName = "macOS Tests.xctest"
37+
BlueprintName = "macOS Tests"
38+
ReferencedContainer = "container:Example.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
</TestAction>
43+
<LaunchAction
44+
buildConfiguration = "Debug"
45+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
46+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47+
launchStyle = "0"
48+
useCustomWorkingDirectory = "NO"
49+
ignoresPersistentStateOnLaunch = "NO"
50+
debugDocumentVersioning = "YES"
51+
debugServiceExtension = "internal"
52+
allowLocationSimulation = "YES">
53+
<BuildableProductRunnable
54+
runnableDebuggingMode = "0">
55+
<BuildableReference
56+
BuildableIdentifier = "primary"
57+
BlueprintIdentifier = "65982B5520DFFD5A0018F790"
58+
BuildableName = "macOS Example.app"
59+
BlueprintName = "macOS Example"
60+
ReferencedContainer = "container:Example.xcodeproj">
61+
</BuildableReference>
62+
</BuildableProductRunnable>
63+
</LaunchAction>
64+
<ProfileAction
65+
buildConfiguration = "Release"
66+
shouldUseLaunchSchemeArgsEnv = "YES"
67+
savedToolIdentifier = ""
68+
useCustomWorkingDirectory = "NO"
69+
debugDocumentVersioning = "YES">
70+
<BuildableProductRunnable
71+
runnableDebuggingMode = "0">
72+
<BuildableReference
73+
BuildableIdentifier = "primary"
74+
BlueprintIdentifier = "65982B5520DFFD5A0018F790"
75+
BuildableName = "macOS Example.app"
76+
BlueprintName = "macOS Example"
77+
ReferencedContainer = "container:Example.xcodeproj">
78+
</BuildableReference>
79+
</BuildableProductRunnable>
80+
</ProfileAction>
81+
<AnalyzeAction
82+
buildConfiguration = "Debug">
83+
</AnalyzeAction>
84+
<ArchiveAction
85+
buildConfiguration = "Release"
86+
revealArchiveInOrganizer = "YES">
87+
</ArchiveAction>
88+
</Scheme>

Example/Example.xcodeproj/xcuserdata/andre.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<key>iOS Example.xcscheme_^#shared#^_</key>
4040
<dict>
4141
<key>orderHint</key>
42-
<integer>4</integer>
42+
<integer>6</integer>
4343
</dict>
4444
<key>macOS Example.xcscheme</key>
4545
<dict>
@@ -49,7 +49,7 @@
4949
<key>macOS Example.xcscheme_^#shared#^_</key>
5050
<dict>
5151
<key>orderHint</key>
52-
<integer>6</integer>
52+
<integer>4</integer>
5353
</dict>
5454
<key>tvOS Example.xcscheme</key>
5555
<dict>
Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,52 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
98
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
109
</dependencies>
1110
<scenes>
1211
<!--View Controller-->
1312
<scene sceneID="tne-QT-ifu">
1413
<objects>
1514
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="iOS_Example" customModuleProvider="target" sceneMemberID="viewController">
16-
<layoutGuides>
17-
<viewControllerLayoutGuide type="top" id="JK2-wK-Quz"/>
18-
<viewControllerLayoutGuide type="bottom" id="bLz-Zx-fgg"/>
19-
</layoutGuides>
2015
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
2116
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2217
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18+
<subviews>
19+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Check the console for more info" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7rT-nu-v9K">
20+
<rect key="frame" x="90.5" y="627" width="194" height="16"/>
21+
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
22+
<nil key="textColor"/>
23+
<nil key="highlightedColor"/>
24+
</label>
25+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aqW-6b-YYQ">
26+
<rect key="frame" x="24" y="320.5" width="327" height="26.5"/>
27+
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle2"/>
28+
<nil key="textColor"/>
29+
<nil key="highlightedColor"/>
30+
</label>
31+
</subviews>
2332
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
33+
<constraints>
34+
<constraint firstItem="7rT-nu-v9K" firstAttribute="centerX" secondItem="EPT-EE-gsq" secondAttribute="centerX" id="64i-f4-dbz"/>
35+
<constraint firstItem="aqW-6b-YYQ" firstAttribute="centerX" secondItem="EPT-EE-gsq" secondAttribute="centerX" id="8hg-2v-usV"/>
36+
<constraint firstItem="EPT-EE-gsq" firstAttribute="bottom" secondItem="7rT-nu-v9K" secondAttribute="bottom" constant="24" id="JLz-QW-Wj9"/>
37+
<constraint firstItem="EPT-EE-gsq" firstAttribute="trailing" secondItem="aqW-6b-YYQ" secondAttribute="trailing" constant="24" id="SbQ-mN-Ig7"/>
38+
<constraint firstItem="aqW-6b-YYQ" firstAttribute="centerY" secondItem="EPT-EE-gsq" secondAttribute="centerY" id="Sdw-RC-4rl"/>
39+
<constraint firstItem="aqW-6b-YYQ" firstAttribute="leading" secondItem="EPT-EE-gsq" secondAttribute="leading" constant="24" id="vJZ-Du-Azu"/>
40+
</constraints>
41+
<viewLayoutGuide key="safeArea" id="EPT-EE-gsq"/>
2442
</view>
43+
<connections>
44+
<outlet property="mainLabel" destination="aqW-6b-YYQ" id="LjU-A9-mcv"/>
45+
</connections>
2546
</viewController>
2647
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2748
</objects>
49+
<point key="canvasLocation" x="-46" y="150"/>
2850
</scene>
2951
</scenes>
3052
</document>
Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,55 @@
11
import UIKit
2+
import RealmSwift
3+
import BackgroundRealm
24

35

46
class ViewController: UIViewController
57
{
6-
8+
private let realm = try! Realm()
9+
private var token: NotificationToken?
10+
11+
private func bindUI(_ object: DummyObject?) {
12+
guard let text = object?.text, text.isEmpty == false else {
13+
mainLabel.text = "No objects in the database"
14+
return
15+
}
16+
mainLabel.text = text
17+
}
18+
19+
@IBOutlet weak var mainLabel: UILabel!
20+
21+
override func viewDidLoad() {
22+
super.viewDidLoad()
23+
24+
token = realm.objects(DummyObject.self).observe { [weak self] (change) in
25+
switch change {
26+
case let .error(error): print("\(error)")
27+
case let .initial(results), let .update(results, _, _, _):
28+
self?.bindUI(results.first)
29+
print("UI UPDATED; isMainThread: \(Thread.current == Thread.main)")
30+
}
31+
}
32+
}
33+
34+
override func viewDidAppear(_ animated: Bool) {
35+
super.viewDidAppear(animated)
36+
37+
print("NO OBJECTS IN THE REALM YET; isMainThread: \(Thread.current == Thread.main)")
38+
39+
let realm = self.realm
40+
print("ADDING AN OBJECT TO THE REALM; isMainThread: \(Thread.current == Thread.main)")
41+
42+
realm.writeInBackground { (result) in
43+
switch result {
44+
case let .failure(error): print("\(error)")
45+
case let .success(backgroundRealm):
46+
47+
let obj = DummyObject()
48+
obj.text = "This text was created in a background thread"
49+
backgroundRealm.add(obj)
50+
print("OBJECT ADDED TO THE REALM; isMainThread: \(Thread.current == Thread.main)")
51+
}
52+
}
53+
}
754
}
855

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Background Realm [![Version](https://img.shields.io/badge/Version-2.2.0-black.svg?style=flat)](#installation) [![License](https://img.shields.io/cocoapods/l/BackgroundRealm.svg?style=flat)](#license)
1+
# Background Realm [![Version](https://img.shields.io/badge/Version-2.2.1-black.svg?style=flat)](#installation) [![License](https://img.shields.io/cocoapods/l/BackgroundRealm.svg?style=flat)](#license)
22

33
[![Platforms](https://img.shields.io/badge/Platforms-iOS|tvOS|macOS|watchOS-brightgreen.svg?style=flat)](#installation)
4-
[![Swift support](https://img.shields.io/badge/Swift-5.0%20%7C%205.2-red.svg?style=flat)](#swift-versions-support)
4+
[![Swift support](https://img.shields.io/badge/Swift-5.0%20%7C%205.3-red.svg?style=flat)](#swift-versions-support)
55
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/BackgroundRealm.svg?style=flat&label=CocoaPods)](https://cocoapods.org/pods/BackgroundRealm)
66
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
77
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-red.svg?style=flat)](https://github.com/apple/swift-package-manager)
@@ -149,7 +149,7 @@ Then `import BackgroundRealm` where needed.
149149
### Swift Package Manager
150150

151151
```swift
152-
.package(url: "https://github.com/BellAppLab/BackgroundRealm.git", from: "2.2.0")
152+
.package(url: "https://github.com/BellAppLab/BackgroundRealm.git", from: "2.2.1")
153153
```
154154

155155
### Git Submodules

0 commit comments

Comments
 (0)