Skip to content

Commit

Permalink
feat/Swift package manager support
Browse files Browse the repository at this point in the history
  • Loading branch information
wassil committed Jan 14, 2021
1 parent 1749a8c commit 6c281b4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ExponeaSDK.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ExponeaSDK/ExponeaSDK/Classes/Database/DatabaseManager.swift
Expand Up @@ -16,7 +16,12 @@ class DatabaseManager {
private let context: NSManagedObjectContext

internal init(persistentStoreDescriptions: [NSPersistentStoreDescription]? = nil) throws {
#if SWIFT_PACKAGE
let bundle = Bundle.module
#else
let bundle = Bundle(for: DatabaseManager.self)
#endif

guard let container = NSPersistentContainer(name: "DatabaseModel", bundle: bundle) else {
throw DatabaseManagerError.unableToCreatePersistentContainer
}
Expand Down
44 changes: 44 additions & 0 deletions Package.swift
@@ -0,0 +1,44 @@
// swift-tools-version:5.3

import PackageDescription

let package = Package(
name: "ExponeaSDK",
platforms: [
.iOS(.v10)
],
products: [
.library(
name: "ExponeaSDK",
targets: ["ExponeaSDK"]),
.library(
name: "ExponeaSDK-Notifications",
targets: ["ExponeaSDK-Notifications"]
)
],
dependencies: [
],
targets: [
// Main library
.target(
name: "ExponeaSDK",
dependencies: ["ExponeaSDKShared", "ExponeaSDKObjC"],
path: "ExponeaSDK/ExponeaSDK"),
// Notification extension library
.target(
name: "ExponeaSDK-Notifications",
dependencies: ["ExponeaSDKShared"],
path: "ExponeaSDK/ExponeaSDK-Notifications"),
// Code shared between ExponeaSDK and ExponeaSDK-Notifications
.target(
name: "ExponeaSDKShared",
dependencies: [],
path: "ExponeaSDK/ExponeaSDKShared"),
// ObjC code required by main library
.target(
name: "ExponeaSDKObjC",
dependencies: [],
path: "ExponeaSDK/ExponeaSDKObjC",
publicHeadersPath: ".")
]
)

0 comments on commit 6c281b4

Please sign in to comment.