From c00b48ded93c06b2b5d9bedc8cb903f04ea1800a Mon Sep 17 00:00:00 2001 From: Mehdi Mirzaie Date: Tue, 12 Jul 2022 00:53:53 +0430 Subject: [PATCH] Fix pod dependency (#20) * Fix pod dependency Co-authored-by: Mehdi Mirzaei --- NetShears.podspec | 7 +++++- .../Extension/Bundle+Extension.swift | 25 +++++++++++++++++++ .../NetShears/Extension/Date+Extension.swift | 13 ---------- .../Extension/UIStoryBoard+Extension.swift | 2 +- .../UI/RequestDetailViewController.swift | 6 ++--- .../UI/RequestListViewController.swift | 2 +- Sources/NetShears/Utils/NSHelper.swift | 2 +- 7 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 Sources/NetShears/Extension/Bundle+Extension.swift diff --git a/NetShears.podspec b/NetShears.podspec index bcb65b9..55c52de 100644 --- a/NetShears.podspec +++ b/NetShears.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "NetShears" - s.version = "1.0.0" + s.version = "3.2.1" s.summary = "iOS Network interceptor framework written in Swift" s.description = <<-DESC @@ -22,4 +22,9 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/divar-ir/NetShears.git", :tag => s.version } s.source_files = ["Sources/**/*.swift"] + s.resource_bundles = { + 'NetShears' => ['Sources/**/*.storyboard', 'Sources/**/*.xib'] + } + s.frameworks = "Foundation" + end diff --git a/Sources/NetShears/Extension/Bundle+Extension.swift b/Sources/NetShears/Extension/Bundle+Extension.swift new file mode 100644 index 0000000..70e8ed1 --- /dev/null +++ b/Sources/NetShears/Extension/Bundle+Extension.swift @@ -0,0 +1,25 @@ +// +// Bundle+Extension.swift +// NetShears +// +// Created by Mehdi Mirzaie on 7/12/22. +// + +import Foundation + +extension Bundle { + static var NetShearsBundle: Bundle { + #if SWIFT_PACKAGE + let resourceBundle = Bundle.module + return resourceBundle + #endif + let podBundle = Bundle(for: NetShears.classForCoder()) + if let bundleURL = podBundle.url(forResource: "NetShears", withExtension: "bundle"){ + if let bundle = Bundle(url: bundleURL) { + return bundle + } + } + + return Bundle(for: NetShears.classForCoder()) + } +} diff --git a/Sources/NetShears/Extension/Date+Extension.swift b/Sources/NetShears/Extension/Date+Extension.swift index 01ea233..64bb9ae 100644 --- a/Sources/NetShears/Extension/Date+Extension.swift +++ b/Sources/NetShears/Extension/Date+Extension.swift @@ -18,16 +18,3 @@ extension Date{ } } - -extension Bundle { - static var NetShearsBundle: Bundle { - let podBundle = Bundle(for: NetShears.classForCoder()) - if let bundleURL = podBundle.url(forResource: "NetShears", withExtension: "bundle"){ - if let bundle = Bundle(url: bundleURL) { - return bundle - } - } - - return Bundle(for: NetShears.classForCoder()) - } -} diff --git a/Sources/NetShears/Extension/UIStoryBoard+Extension.swift b/Sources/NetShears/Extension/UIStoryBoard+Extension.swift index 17e7c65..b2d29d1 100644 --- a/Sources/NetShears/Extension/UIStoryBoard+Extension.swift +++ b/Sources/NetShears/Extension/UIStoryBoard+Extension.swift @@ -9,6 +9,6 @@ import UIKit extension UIStoryboard { static var NetShearsStoryBoard: UIStoryboard { - return UIStoryboard(name: "Flow", bundle: Bundle.module) + return UIStoryboard(name: "Flow", bundle: Bundle.NetShearsBundle) } } diff --git a/Sources/NetShears/UI/RequestDetailViewController.swift b/Sources/NetShears/UI/RequestDetailViewController.swift index 83cb0bd..aebc5b8 100644 --- a/Sources/NetShears/UI/RequestDetailViewController.swift +++ b/Sources/NetShears/UI/RequestDetailViewController.swift @@ -42,9 +42,9 @@ final class RequestDetailViewController: UIViewController, ShowLoaderProtocol { tableView.estimatedRowHeight = 100.0 tableView.rowHeight = UITableView.automaticDimension - tableView.register(UINib(nibName: "TextTableViewCell", bundle: Bundle.module), forCellReuseIdentifier: "TextTableViewCell") - tableView.register(UINib(nibName: "ActionableTableViewCell", bundle: Bundle.module), forCellReuseIdentifier: "ActionableTableViewCell") - tableView.register(UINib(nibName: "RequestTitleSectionView", bundle: Bundle.module), forHeaderFooterViewReuseIdentifier: "RequestTitleSectionView") + tableView.register(UINib(nibName: "TextTableViewCell", bundle: Bundle.NetShearsBundle), forCellReuseIdentifier: "TextTableViewCell") + tableView.register(UINib(nibName: "ActionableTableViewCell", bundle: Bundle.NetShearsBundle), forCellReuseIdentifier: "ActionableTableViewCell") + tableView.register(UINib(nibName: "RequestTitleSectionView", bundle: Bundle.NetShearsBundle), forHeaderFooterViewReuseIdentifier: "RequestTitleSectionView") } override func didReceiveMemoryWarning() { diff --git a/Sources/NetShears/UI/RequestListViewController.swift b/Sources/NetShears/UI/RequestListViewController.swift index 2cab3f0..2b7c873 100644 --- a/Sources/NetShears/UI/RequestListViewController.swift +++ b/Sources/NetShears/UI/RequestListViewController.swift @@ -39,7 +39,7 @@ class RequestsViewController: UIViewController, ShowLoaderProtocol { } private func registerNibs() { - collectionView?.register(UINib(nibName: String(describing: RequestCell.self), bundle: Bundle.module), forCellWithReuseIdentifier: requestCellIdentifier) + collectionView?.register(UINib(nibName: String(describing: RequestCell.self), bundle: Bundle.NetShearsBundle), forCellWithReuseIdentifier: requestCellIdentifier) } // MARK: - Search diff --git a/Sources/NetShears/Utils/NSHelper.swift b/Sources/NetShears/Utils/NSHelper.swift index 012f67c..f8a8db5 100644 --- a/Sources/NetShears/Utils/NSHelper.swift +++ b/Sources/NetShears/Utils/NSHelper.swift @@ -23,7 +23,7 @@ final class NSHelper { } let textShare = [text] - let customItem = NSActivity(title: "Save to the desktop", image: UIImage(named: "activity_icon", in: Bundle.module, compatibleWith: nil)) { (sharedItems) in + let customItem = NSActivity(title: "Save to the desktop", image: UIImage(named: "activity_icon", in: Bundle.NetShearsBundle, compatibleWith: nil)) { (sharedItems) in guard let sharedStrings = sharedItems as? [String] else { return } let appName = Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String