Fatal error: Failed to create set path

I am trying to make CocoaPod, which includes .xibfor two full days, but to no avail. I have a standalone Xcode project for my framework with the following .podspec:

Pod::Spec.new do |s|
  s.name         = "OrderStatusTable"
  s.version      = "1.2.0"
  s.platform = :ios
  s.ios.deployment_target = '9.0'
  s.summary      = "Order Status UITableView framework."
  s.description  = "A UITableView framework with custom view."
  s.homepage     = "https://github.com/myname/OrderStatusTableView"
  s.license = { :type => "MIT", :file => "LICENSE" }
  s.author = { "My Name" => "My Email" }
  s.platform     = :ios, "9.0"
  s.source       = { :git => "https://github.com/myname/OrderStatusTableView.git", :tag => "1.2.0" }

  s.source_files = "OrderStatusTable/**/*.{h,m,swift}"

  s.resource_bundles = {
    'OrderStatusTable' => [
        'Pod/**/*.xib'
    ]
  }

end

In my sample project, I am adding pod 'OrderStatusTable', :git => 'https://github.com/myname/OrderStatusTableView.git', :tag => ‘1.2.0’to my subfile. My file is .xibincluded in the Resources folder inside the module in the sample project, but I keep getting this error:fatal error: Could not create a path to the bundle: file /Users/myname/Desktop/appname/OrderStatusTableDemo/Pods/OrderStatusTable/OrderStatusTable/OrderStatusTable.swift, line 40

This is a UITableViewframework, and I am trying to register a custom UITableViewCellnib with a cell reuse identifier, for example:

    public class OrderStatusTable: UITableView {

    public override func awakeFromNib() {

        delegate = self
        dataSource = self

        let podBundle = NSBundle(forClass: self.classForCoder)

        if let bundleURL = podBundle.URLForResource("OrderStatusTable", withExtension: "bundle") {

            if let bundle = NSBundle(URL: bundleURL) {

                let cellNib = UINib(nibName: "OrderStatusTableViewCell", bundle: bundle)

                registerNib(cellNib, forCellReuseIdentifier: "OrderStatusTableViewCell")

            } else {

                assertionFailure("Could not load the bundle")

            }

        } else {

            assertionFailure("Could not create a path to the bundle")
            // This keeps getting called
        }
}

So I'm not sure if I have the wrong package URLForResourceor what? This is not well documented on the Internet. Can someone please advise? Thank!

+4
1

pod.

 s.resources = "YourProjectName/*.xib"
 s.resource_bundles = {
   'YourProjectName' => [
       'Pod/**/*.xib'
   ]
 }

s.resources = "OrderStatusTable/*.xib"
 s.resource_bundles = {
   'OrderStatusTable' => [
       'Pod/**/*.xib'
   ]
 }

.

 let podBundle = Bundle(for: self.classForCoder)

: -

let podBundle = Bundle(for:YourClassName.self)

 let podBundle = Bundle(OrderStatusTable.self)
0

Source: https://habr.com/ru/post/1651635/


All Articles