Skip to content

Commit 97cc6be

Browse files
authored
SPM support (#7)
* Add SPM support * downgrade swift-tools-version to 5.3 * remove whitespace after swift tools specifier * fix loading `player.html` for SPM
1 parent 38347c4 commit 97cc6be

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

BeyondWordsPlayer/BeyondWordsPlayer/PlayerView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ public class PlayerView: UIView {
3434
webView.isInspectable = true
3535
#endif
3636
}
37+
#if SWIFT_PACKAGE
38+
guard let playerHTMLPath = Bundle.module.path(forResource: "player", ofType: "html") else {
39+
fatalError("player.html not found!")
40+
}
41+
#else
3742
guard let playerHTMLPath = Bundle(for: PlayerView.self).path(forResource: "player", ofType: "html") else {
3843
fatalError("player.html not found!")
3944
}
45+
#endif
4046
guard let playerHTMLPage = try? String(contentsOfFile: playerHTMLPath) else {
4147
fatalError("player.html could not be loaded!")
4248
}

Package.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// swift-tools-version:5.3
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "BeyondWordsPlayer",
7+
platforms: [
8+
.iOS(.v13)
9+
],
10+
products: [
11+
.library(
12+
name: "BeyondWordsPlayer",
13+
targets: ["BeyondWordsPlayer"]
14+
)
15+
],
16+
targets: [
17+
.target(
18+
name: "BeyondWordsPlayer",
19+
path: "BeyondWordsPlayer/BeyondWordsPlayer",
20+
resources: [
21+
.process("player.html")
22+
]
23+
)
24+
]
25+
)

0 commit comments

Comments
 (0)