Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SPM support #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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")
]
)
]
)
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:
Expand Down
6 changes: 5 additions & 1 deletion Source/Internal/BTConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down