Skip to content

Commit

Permalink
fix(cocoapods) handle assets for cocoapods from sources folder
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainPetit1 committed Aug 4, 2022
1 parent f616ca3 commit 6b31b2b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ApiVideoPlayer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '11.0'
s.swift_version = '5.0'

s.source_files = 'Sources/**/*'
s.resources = 'Sources/*.xcassets/*'
s.source_files = 'Sources/**/*.{swift, plist}'
s.resources = 'Sources/**/*.{storyboard,xib,xcassets,json,png}'

s.dependency "ApiVideoPlayerAnalytics", "1.0.4"
end
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apivideo/api.video-ios-player-analytics.git",
"state" : {
"revision" : "f8b5eb5ff6c6899b03f7049e88274caea5d67857",
"version" : "1.0.3"
"revision" : "c34d58405161c8055ee14b33af7a06ff4e55d00a",
"version" : "1.0.4"
}
}
],
Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "ApiVideoPlayer",
dependencies: [.product(name: "ApiVideoPlayerAnalytics", package: "api.video-ios-player-analytics")]
dependencies: [.product(name: "ApiVideoPlayerAnalytics", package: "api.video-ios-player-analytics")],
resources: [.process("Resources")]
),
.testTarget(
name: "ApiVideoPlayerTests",
Expand Down
25 changes: 25 additions & 0 deletions Sources/ApiVideoPlayer/ApiVideoPlayerResources.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

public final class ApiVideoPlayerResources {
public static let resourceBundle: Bundle = {
let candidates = [
// Bundle should be present here when the package is linked into an App.
Bundle.main.resourceURL,

// Bundle should be present here when the package is linked into a framework.
Bundle(for: ApiVideoPlayerResources.self).resourceURL,
]

let bundleName = "ApiVideoPlayer_ApiVideoPlayer"

for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}

// Return whatever bundle this code is in as a last resort.
return Bundle(for: ApiVideoPlayerResources.self)
}()
}
2 changes: 1 addition & 1 deletion Sources/ApiVideoPlayer/View/VodControlsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@

private func setPlayBtnIcon(iconName: String) {
if #available(tvOS 13.0, *) {
playPauseButton.setImage(UIImage(named: iconName, in: Bundle.module, compatibleWith: nil), for: .normal)
playPauseButton.setImage(UIImage(named: iconName, in: ApiVideoPlayerResources.resourceBundle, compatibleWith: nil), for: .normal)
} else {
// Fallback on earlier versions
}
Expand Down

0 comments on commit 6b31b2b

Please sign in to comment.