From 40e7e5a5004ec6b9ecdec1033c0cfdb579c99c8d Mon Sep 17 00:00:00 2001 From: Mihail Preis Date: Wed, 18 Aug 2021 15:13:03 +0500 Subject: [PATCH] Add SPM supprt --- Package.swift | 26 ++++++++++++++++++++++++++ README.md | 9 +++++++++ Source/Internal/BTConfiguration.swift | 6 +++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..e17c83d4 --- /dev/null +++ b/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "BTNavigationDropdownMenu", + platforms: [ + .iOS(.v9) + ], + products: [ + .library( + name: "BTNavigationDropdownMenu", + targets: ["BTNavigationDropdownMenu"] + ) + ], + targets: [ + .target( + name: "BTNavigationDropdownMenu", + path: "Source", + resources: [ + .copy("BTNavigationDropdownMenu.bundle") + ] + ) + ] +) diff --git a/README.md b/README.md index c6e156b7..0e4af093 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,15 @@ github "PhamBaTho/BTNavigationDropdownMenu" ~> 0.7 Run `carthage update` to build the framework and drag the built `BTNavigationDropdownMenu.framework` into your Xcode project. +### Swift Package Manager +Once you have your Swift package set up, adding BTNavigationDropdownMenu as a dependency is as easy as adding it to the dependencies value of your Package.swift. + +```swift +dependencies: [ + .package(url: "https://github.com/PhamBaTho/BTNavigationDropdownMenu.git", .upToNextMajor(from: "1.0")) +] +``` + ## Usage ### Instantiate Start by creating an Array that contains strings as **elements of a dropdown list**: diff --git a/Source/Internal/BTConfiguration.swift b/Source/Internal/BTConfiguration.swift index 1d28bd68..f61b0d3a 100644 --- a/Source/Internal/BTConfiguration.swift +++ b/Source/Internal/BTConfiguration.swift @@ -46,7 +46,11 @@ final class BTConfiguration { init() { // Path for image - let bundle = Bundle(for: BTConfiguration.self) + var bundle = Bundle(for: BTConfiguration.self) + // Get own resources bundle for SPM case + if let packageBundle = bundle.url(forResource: "BTNavigationDropdownMenu_BTNavigationDropdownMenu", withExtension: "bundle").flatMap({ Bundle(url: $0) }) { + bundle = packageBundle + } let url = bundle.url(forResource: "BTNavigationDropdownMenu", withExtension: "bundle") let imageBundle = Bundle(url: url!) let checkMarkImagePath = imageBundle?.path(forResource: "checkmark_icon", ofType: "png")