Skip to content

Commit

Permalink
Upgrade to SwiftPM tools 5.3 and add localization resource to the tar…
Browse files Browse the repository at this point in the history
…get.
  • Loading branch information
maniramezan committed Oct 5, 2020
1 parent 7f61fb6 commit 7e67b02
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
25 changes: 20 additions & 5 deletions DateToolsSwift/DateTools/Date+Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@
import Foundation

public extension Bundle {

class func dateToolsBundle() -> Bundle {
let assetPath = Bundle(for: Constants.self).resourcePath!
return Bundle(path: NSString(string: assetPath).appendingPathComponent("DateTools.bundle"))!
}

class func dateToolsBundle() -> Bundle {
let containerBundle: Bundle

#if SWIFT_PACKAGE
containerBundle = Bundle.module
#else
containerBundle = Bundle.main
#endif

guard
let dateToolsBundleURL = containerBundle.url(forResource: "DateTools", withExtension: "bundle"),
let dateToolsBundle = Bundle(url: dateToolsBundleURL)
else {
assertionFailure("Make sure you have included DateTools.bundle in your app.")
return containerBundle
}

return dateToolsBundle
}
}

15 changes: 12 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// swift-tools-version:5.1
// swift-tools-version:5.3

import PackageDescription

let package = Package(
name: "DateToolsSwift",
platforms: [
.macOS(.v10_10), .iOS(.v8)
.macOS(.v10_10), .iOS(.v8), .tvOS(.v9), .watchOS(.v2)
],
products: [
.library(
Expand All @@ -19,12 +19,21 @@ let package = Package(
exclude: [
"Examples",
"DateToolsSwift/Examples"
],
resources: [
.copy("DateTools.bundle")
]
),
.testTarget(
name: "DateToolsSwiftTests",
dependencies: ["DateToolsSwift"],
path: "DateToolsSwift/Tests/DateToolsTests/DateToolsTestsTests"
path: "DateToolsSwift/Tests/DateToolsTests/DateToolsTestsTests",
exclude: [
"Info.plist"
],
resources: [
.copy("DateTools.bundle")
]
)
]
)

0 comments on commit 7e67b02

Please sign in to comment.