From 1be56607c0d75360279bc747f34203bc5ff9d654 Mon Sep 17 00:00:00 2001
From: Omar Albeik
Date: Wed, 5 Jun 2019 11:50:32 +0300
Subject: [PATCH] Add test cases for failable initializers, update SPM code
---
Package.swift | 14 +++++++++++++-
README.md | 25 +++++++++++++++++++------
Tests/SingleStoreTests.swift | 5 +++++
Tests/StoreTests.swift | 5 +++++
UserDefaultsStore.podspec | 2 +-
5 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/Package.swift b/Package.swift
index 021ce67..bbc8caa 100644
--- a/Package.swift
+++ b/Package.swift
@@ -21,6 +21,18 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// swift-tools-version:5.0
+// The swift-tools-version declares the minimum version of Swift required to build this package.
+
import PackageDescription
-let package = Package(name: "UserDefaultsStore", dependencies: [], exclude: ["Tests"])
+let package = Package(
+ name: "UserDefaultsStore",
+ products: [
+ .library(name: "UserDefaultsStore", targets: ["UserDefaultsStore"])
+ ],
+ dependencies: [],
+ targets: [
+ .target(name: "UserDefaultsStore", dependencies: [])
+ ]
+)
\ No newline at end of file
diff --git a/README.md b/README.md
index f36f44f..3ecd452 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
-
+
@@ -42,14 +42,27 @@ You love Swift's `Codable` protocol and use it everywhere, who doesn't! Here is
Swift Package Manager
-The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but UserDefaultsStore does support its use on supported platforms.
-Once you have your Swift package set up, adding UserDefaultsStore as a dependency is as easy as adding it to the dependencies value of your Package.swift.
+You can use The Swift Package Manager to install UserDefaultsStore
by adding the proper description to your Package.swift
file:
import PackageDescription
-dependencies: [
- .package(url: "https://github.com/omaralbeik/UserDefaultsStore.git", from: "1.0.2")
-]
+
+let package = Package(
+ name: "YOUR_PROJECT_NAME",
+ targets: [],
+ dependencies: [
+ .package(url: "https://github.com/omaralbeik/UserDefaultsStore.git", from: "1.4.1")
+ ]
+)
+
+Next, add UserDefaultsStore
to your targets dependencies like so:
+.target(
+ name: "YOUR_TARGET_NAME",
+ dependencies: [
+ "UserDefaultsStore",
+ ]
+),
+Then run swift package update
.
diff --git a/Tests/SingleStoreTests.swift b/Tests/SingleStoreTests.swift
index dbef7f2..0a07dc3 100644
--- a/Tests/SingleStoreTests.swift
+++ b/Tests/SingleStoreTests.swift
@@ -31,6 +31,11 @@ final class SingleStoreTests: XCTestCase {
XCTAssertNotNil(store)
}
+ func testCreateInvalidStore() {
+ let invalidStore = SingleUserDefaultsStore(uniqueIdentifier: UserDefaults.globalDomain)
+ XCTAssertNil(invalidStore)
+ }
+
func testSaveObject() {
let store = createFreshUsersStore()!
diff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swift
index 4e269c3..9ce053f 100644
--- a/Tests/StoreTests.swift
+++ b/Tests/StoreTests.swift
@@ -31,6 +31,11 @@ final class StoreTests: XCTestCase {
XCTAssertNotNil(store)
}
+ func testCreateInvalidStore() {
+ let invalidStore = UserDefaultsStore(uniqueIdentifier: UserDefaults.globalDomain)
+ XCTAssertNil(invalidStore)
+ }
+
func testSaveObject() {
let store = createFreshUsersStore()!
diff --git a/UserDefaultsStore.podspec b/UserDefaultsStore.podspec
index 1005f6f..0c3e347 100644
--- a/UserDefaultsStore.podspec
+++ b/UserDefaultsStore.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "UserDefaultsStore"
- s.version = "1.4"
+ s.version = "1.4.1"
s.summary = "Why not use UserDefaults to store Codable objects 😉"
s.description = <<-DESC
You love Swift"s Codable protocol and use it everywhere, here is an easy and very light way to store - reasonable amount 😅 - of Codable objects, in a couple lines of code.