Skip to content

Commit 63a6ee7

Browse files
authored
Update Podspecs to use resource_bundles (#76)
1 parent 5278ddc commit 63a6ee7

File tree

9 files changed

+92
-11
lines changed

9 files changed

+92
-11
lines changed

Sources/LCP/Toolkit/Bundle.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,28 @@
33
// Use of this source code is governed by the BSD-style license
44
// available in the top-level LICENSE file of the project.
55
//
6-
76
import Foundation
87

98
#if !SWIFT_PACKAGE
109
extension Bundle {
10+
11+
#if !COCOAPODS
1112
/// Returns ReadiumLCP's bundle by querying an arbitrary type.
1213
static let module = Bundle(for: LCPService.self)
14+
#else
15+
/// Returns ReadiumLCP's bundle by querying for the cocoapods bundle.
16+
static let module = Bundle.getCocoaPodsBundle()
17+
static func getCocoaPodsBundle() -> Bundle {
18+
let rootBundle = Bundle(for: LCPService.self)
19+
guard let resourceBundleUrl = rootBundle.url(forResource: "ReadiumLCP", withExtension: "bundle") else {
20+
fatalError("Unable to locate ReadiumLCP.bundle")
21+
}
22+
guard let bundle = Bundle(url: resourceBundleUrl) else {
23+
fatalError("Unable to load ReadiumLCP.bundle")
24+
}
25+
26+
return bundle
27+
}
28+
#endif
1329
}
1430
#endif

Sources/Navigator/Toolkit/Extensions/Bundle.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,24 @@ import Foundation
77

88
#if !SWIFT_PACKAGE
99
extension Bundle {
10+
11+
#if !COCOAPODS
1012
/// Returns R2Navigator's bundle by querying an arbitrary type.
1113
static let module = Bundle(for: EPUBNavigatorViewController.self)
14+
#else
15+
/// Returns R2Navigator's bundle by querying for the cocoapods bundle.
16+
static let module = Bundle.getCocoaPodsBundle()
17+
static func getCocoaPodsBundle() -> Bundle {
18+
let rootBundle = Bundle(for: EPUBNavigatorViewController.self)
19+
guard let resourceBundleUrl = rootBundle.url(forResource: "ReadiumNavigator", withExtension: "bundle") else {
20+
fatalError("Unable to locate ReadiumNavigator.bundle")
21+
}
22+
guard let bundle = Bundle(url: resourceBundleUrl) else {
23+
fatalError("Unable to load ReadiumNavigator.bundle")
24+
}
25+
26+
return bundle
27+
}
28+
#endif
1229
}
1330
#endif

Sources/Shared/Toolkit/Extensions/Bundle.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,28 @@
33
// Use of this source code is governed by the BSD-style license
44
// available in the top-level LICENSE file of the project.
55
//
6-
76
import Foundation
87

98
#if !SWIFT_PACKAGE
109
extension Bundle {
10+
11+
#if !COCOAPODS
1112
/// Returns R2Shared's bundle by querying an arbitrary type.
1213
static let module = Bundle(for: Publication.self)
14+
#else
15+
/// Returns R2Shared's bundle by querying for the cocoapods bundle.
16+
static let module = Bundle.getCocoaPodsBundle()
17+
static func getCocoaPodsBundle() -> Bundle {
18+
let rootBundle = Bundle(for: Publication.self)
19+
guard let resourceBundleUrl = rootBundle.url(forResource: "ReadiumShared", withExtension: "bundle") else {
20+
fatalError("Unable to locate ReadiumShared.bundle")
21+
}
22+
guard let bundle = Bundle(url: resourceBundleUrl) else {
23+
fatalError("Unable to load ReadiumShared.bundle")
24+
}
25+
26+
return bundle
27+
}
28+
#endif
1329
}
1430
#endif

Sources/Streamer/Toolkit/Extensions/Bundle.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,28 @@
33
// Use of this source code is governed by the BSD-style license
44
// available in the top-level LICENSE file of the project.
55
//
6-
76
import Foundation
87

98
#if !SWIFT_PACKAGE
109
extension Bundle {
10+
11+
#if !COCOAPODS
1112
/// Returns R2Streamer's bundle by querying an arbitrary type.
1213
static let module = Bundle(for: Streamer.self)
14+
#else
15+
/// Returns R2Streamer's bundle by querying for the cocoapods bundle.
16+
static let module = Bundle.getCocoaPodsBundle()
17+
static func getCocoaPodsBundle() -> Bundle {
18+
let rootBundle = Bundle(for: Streamer.self)
19+
guard let resourceBundleUrl = rootBundle.url(forResource: "ReadiumStreamer", withExtension: "bundle") else {
20+
fatalError("Unable to locate ReadiumStreamer.bundle")
21+
}
22+
guard let bundle = Bundle(url: resourceBundleUrl) else {
23+
fatalError("Unable to load ReadiumStreamer.bundle")
24+
}
25+
26+
return bundle
27+
}
28+
#endif
1329
}
1430
#endif

Support/CocoaPods/ReadiumLCP.podspec

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ Pod::Spec.new do |s|
88
s.author = { "Readium" => "contact@readium.org" }
99
s.source = { :git => "https://github.com/readium/swift-toolkit.git", :branch => "develop" }
1010
s.requires_arc = true
11-
s.resources = [
12-
'Sources/LCP/Resources/**',
13-
'Sources/LCP/**/*.xib'
14-
]
11+
s.resource_bundles = {
12+
'ReadiumLCP' => [
13+
'Sources/LCP/Resources/**',
14+
'Sources/LCP/**/*.xib',
15+
],
16+
}
1517
s.source_files = "Sources/LCP/**/*.{m,h,swift}"
1618
s.platform = :ios
1719
s.ios.deployment_target = "10.0"

Support/CocoaPods/ReadiumNavigator.podspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Pod::Spec.new do |s|
88
s.author = { "Readium" => "contact@readium.org" }
99
s.source = { :git => "https://github.com/readium/swift-toolkit.git", :branch => "develop" }
1010
s.requires_arc = true
11-
s.resources = ['Sources/Navigator/Resources/**', 'Sources/Navigator/EPUB/Assets']
11+
s.resource_bundles = {
12+
'ReadiumNavigator' => [
13+
'Sources/Navigator/Resources/**',
14+
'Sources/Navigator/EPUB/Assets',
15+
],
16+
}
1217
s.source_files = "Sources/Navigator/**/*.{m,h,swift}"
1318
s.platform = :ios
1419
s.ios.deployment_target = "10.0"

Support/CocoaPods/ReadiumOPDS.podspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Pod::Spec.new do |s|
88
s.author = { "Readium" => "contact@readium.org" }
99
s.source = { :git => "https://github.com/readium/swift-toolkit.git", :branch => "develop" }
1010
s.requires_arc = true
11-
s.resources = ['Sources/OPDS/Resources/**']
11+
s.resource_bundles = {
12+
'ReadiumOPDS' => ['Sources/OPDS/Resources/**'],
13+
}
1214
s.source_files = "Sources/OPDS/**/*.{m,h,swift}"
1315
s.platform = :ios
1416
s.ios.deployment_target = "10.0"

Support/CocoaPods/ReadiumShared.podspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Pod::Spec.new do |s|
99
s.source = { :git => 'https://github.com/readium/swift-toolkit.git', :branch => "develop" }
1010
s.exclude_files = ["Sources/Shared/Toolkit/Archive/ZIPFoundation.swift"]
1111
s.requires_arc = true
12-
s.resources = ['Sources/Shared/Resources/**']
12+
s.resource_bundles = {
13+
'ReadiumShared' => ['Sources/Shared/Resources/**'],
14+
}
1315
s.source_files = "Sources/Shared/**/*.{m,h,swift}"
1416
s.platform = :ios
1517
s.ios.deployment_target = "10.0"

Support/CocoaPods/ReadiumStreamer.podspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ Pod::Spec.new do |s|
88
s.author = { "Readium" => "contact@readium.org" }
99
s.source = { :git => "https://github.com/readium/swift-toolkit.git", :branch => "develop" }
1010
s.requires_arc = true
11-
s.resources = ['Sources/Streamer/Resources/**', 'Sources/Streamer/Assets']
11+
s.resource_bundles = {
12+
'ReadiumStreamer' => [
13+
'Sources/Streamer/Resources/**',
14+
'Sources/Streamer/Assets',
15+
],
16+
}
1217
s.source_files = "Sources/Streamer/**/*.{m,h,swift}"
1318
s.platform = :ios
1419
s.ios.deployment_target = "10.0"

0 commit comments

Comments
 (0)