2016-08-18 9 views
4

.xibを含むCocoaPodを2日間使用しても無駄です。私は私のPodfileへpod 'OrderStatusTable', :git => 'https://github.com/myname/OrderStatusTableView.git', :tag => ‘1.2.0’を追加している、私のサンプルプロジェクトでは致命的なエラー:バンドルへのパスを作成できませんでした

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 

:私は次の.podspecと私のフレームワークのためのスタンドアロンのXcodeプロジェクトを持っています。私.xibファイルは、サンプルプロジェクトでポッド内のResourcesフォルダに含まれるが、私はこのエラーを得続ける:fatal error: Could not create a path to the bundle: file /Users/myname/Desktop/appname/OrderStatusTableDemo/Pods/OrderStatusTable/OrderStatusTable/OrderStatusTable.swift, line 40

それはUITableViewフレームワークだと私は、セルの再利用識別子を使用してカスタムUITableViewCellペン先を登録しようとしているが、このように:私は間違っているバンドルURLForResourceまたは何を持っている場合

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 
     } 
} 

だから私はわからないんだけど?これはあまりよくオンラインで文書化されていません。誰か助言してもらえますか?ありがとう!

答えて

0

ここでは、これをポッドの仕様に追加する必要があります。この特定の問題については

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

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

次に、あなたのコードでエラーが発生しました。この質問のために

let podBundle = Bundle(for:YourClassName.self) 

、それは

let podBundle = Bundle(OrderStatusTable.self) 
する必要があります - :

は、代わりにこのように、この1つの使用の

let podBundle = Bundle(for: self.classForCoder) 

を使用しないでください

関連する問題