Skip to content

Commit

Permalink
Merge pull request #2 from SchwarzIT/fix-cocoa-pods-resources
Browse files Browse the repository at this point in the history
Fixed cocoa pods
  • Loading branch information
Asmeili authored Apr 27, 2023
2 parents f58ff28 + ce604aa commit 8183b2a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
5 changes: 4 additions & 1 deletion NetworkDebugger.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "14.0"
s.swift_version = "5.0"

s.source_files = "Sources/NetworkDebugger/**/*"
s.source_files = "Sources/NetworkDebugger/**/*.{swift}"
s.resource_bundles = {
'NetworkDebugger' => ['Sources/NetworkDebugger/Resources/**/*']
}
end
25 changes: 23 additions & 2 deletions Sources/NetworkDebugger/Extensions/Bundle+NetworkDebugger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import Foundation

extension Bundle {
static let networkDebugger: Bundle = {
private static let spmBundle: Bundle? = {
let bundleName = "NetworkDebugger_NetworkDebugger"

let overrides: [URL]
Expand Down Expand Up @@ -52,6 +52,27 @@ extension Bundle {
return bundle
}
}
fatalError("unable to find bundle named NetworkDebugger_NetworkDebugger")
return nil
}()

private static let podsBundle: Bundle? = {
guard let bundleUrl = Bundle(for: NetworkDebugger.self).url(
forResource: "NetworkDebugger",
withExtension: "bundle"
),
let bundle = Bundle(url: bundleUrl)
else { return nil }
debugPrint("Debug: \(bundleUrl.absoluteString)")
return bundle
}()

static let ndBundle: Bundle = {
if let spmBundle {
return spmBundle
}
if let podsBundle {
return podsBundle
}
fatalError("Unable to find bundle for NetworkDebugger.")
}()
}
2 changes: 1 addition & 1 deletion Sources/NetworkDebugger/UI/Views/Models/DataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct DataView: View {
}

private func getFileContents(forResource: String, ofType: String) -> String {
let fileURL = Bundle.networkDebugger.path(forResource: forResource, ofType: ofType)!
let fileURL = Bundle.ndBundle.path(forResource: forResource, ofType: ofType)!
let fileManager = FileManager.default
let data = fileManager.contents(atPath: fileURL)!
let fileContents = String(data: data, encoding: .utf8)
Expand Down

0 comments on commit 8183b2a

Please sign in to comment.