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 b5f0129
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 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
}
}

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

import PackageDescription

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 b5f0129

Please sign in to comment.