Using nibs from cocoapods in swift 4












0















I have made a framework that contains a function that displays a login view according to a xib that is contained in that framework. Both the xib file and the swift file for the view are called AuthenticationViewController



However when I try to use this function in another project that uses this as a pod, it fails with "Could not load NIB in bundle...(not yet loaded)' with name 'AuthenticationViewController'"



The view is being shown by the following code that is located in my pod/framework:



func authenticate(viewController: UIViewController){
let bundle = Bundle(for:AuthenticationViewController.self)
let newViewController = AuthenticationViewController(nibName:"AuthenticationViewController" , bundle: bundle)

viewController.present(newViewController, animated: true, completion: nil)
}


What is the issue here? Is there supposed to be a separate bundle for my pod, because I only get one bundle when calling:



Bundle.allBundles


My .podspec file contains the following section:



s.resource_bundles = {
"MyPodName" => ["MyPodName/*.xib"]


}



but I have tried to load the bundle using:



Bundle(identifier:"MyPodName")


and that does not work either.



How are you supposed to use nibs from pods?










share|improve this question





























    0















    I have made a framework that contains a function that displays a login view according to a xib that is contained in that framework. Both the xib file and the swift file for the view are called AuthenticationViewController



    However when I try to use this function in another project that uses this as a pod, it fails with "Could not load NIB in bundle...(not yet loaded)' with name 'AuthenticationViewController'"



    The view is being shown by the following code that is located in my pod/framework:



    func authenticate(viewController: UIViewController){
    let bundle = Bundle(for:AuthenticationViewController.self)
    let newViewController = AuthenticationViewController(nibName:"AuthenticationViewController" , bundle: bundle)

    viewController.present(newViewController, animated: true, completion: nil)
    }


    What is the issue here? Is there supposed to be a separate bundle for my pod, because I only get one bundle when calling:



    Bundle.allBundles


    My .podspec file contains the following section:



    s.resource_bundles = {
    "MyPodName" => ["MyPodName/*.xib"]


    }



    but I have tried to load the bundle using:



    Bundle(identifier:"MyPodName")


    and that does not work either.



    How are you supposed to use nibs from pods?










    share|improve this question



























      0












      0








      0








      I have made a framework that contains a function that displays a login view according to a xib that is contained in that framework. Both the xib file and the swift file for the view are called AuthenticationViewController



      However when I try to use this function in another project that uses this as a pod, it fails with "Could not load NIB in bundle...(not yet loaded)' with name 'AuthenticationViewController'"



      The view is being shown by the following code that is located in my pod/framework:



      func authenticate(viewController: UIViewController){
      let bundle = Bundle(for:AuthenticationViewController.self)
      let newViewController = AuthenticationViewController(nibName:"AuthenticationViewController" , bundle: bundle)

      viewController.present(newViewController, animated: true, completion: nil)
      }


      What is the issue here? Is there supposed to be a separate bundle for my pod, because I only get one bundle when calling:



      Bundle.allBundles


      My .podspec file contains the following section:



      s.resource_bundles = {
      "MyPodName" => ["MyPodName/*.xib"]


      }



      but I have tried to load the bundle using:



      Bundle(identifier:"MyPodName")


      and that does not work either.



      How are you supposed to use nibs from pods?










      share|improve this question
















      I have made a framework that contains a function that displays a login view according to a xib that is contained in that framework. Both the xib file and the swift file for the view are called AuthenticationViewController



      However when I try to use this function in another project that uses this as a pod, it fails with "Could not load NIB in bundle...(not yet loaded)' with name 'AuthenticationViewController'"



      The view is being shown by the following code that is located in my pod/framework:



      func authenticate(viewController: UIViewController){
      let bundle = Bundle(for:AuthenticationViewController.self)
      let newViewController = AuthenticationViewController(nibName:"AuthenticationViewController" , bundle: bundle)

      viewController.present(newViewController, animated: true, completion: nil)
      }


      What is the issue here? Is there supposed to be a separate bundle for my pod, because I only get one bundle when calling:



      Bundle.allBundles


      My .podspec file contains the following section:



      s.resource_bundles = {
      "MyPodName" => ["MyPodName/*.xib"]


      }



      but I have tried to load the bundle using:



      Bundle(identifier:"MyPodName")


      and that does not work either.



      How are you supposed to use nibs from pods?







      ios xcode swift4 bundle nib






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 13:06







      Metareven

















      asked Nov 21 '18 at 12:57









      MetarevenMetareven

      532420




      532420
























          2 Answers
          2






          active

          oldest

          votes


















          0














          I seem that the bundle is not the correct one. I use this function in my pod library in order to get the bundle



          - (NSBundle *)getBundle {
          NSBundle *podBundle = [NSBundle bundleForClass:self.classForCoder];
          NSURL *podBundleURL = [podBundle URLForResource:@"MyPodName" withExtension:@"bundle"];
          NSBundle *bundle = [[NSBundle alloc] initWithURL:podBundleURL];
          return bundle;
          }


          Once you have the bundle you can load the view. Also, run a pod install after you edit the .podspec and add a new file to reorganize the files.






          share|improve this answer































            0














            The problem was that I was using:



            s.resource_bundles = {
            "MyPodName" => ["MyPodName/*.xib"]
            }


            This does not seem to work with the approach i had done. So I had to change podspec file to:



            s.resources = ["MyPodName/*.xib"]


            That made everything work






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412542%2fusing-nibs-from-cocoapods-in-swift-4%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              I seem that the bundle is not the correct one. I use this function in my pod library in order to get the bundle



              - (NSBundle *)getBundle {
              NSBundle *podBundle = [NSBundle bundleForClass:self.classForCoder];
              NSURL *podBundleURL = [podBundle URLForResource:@"MyPodName" withExtension:@"bundle"];
              NSBundle *bundle = [[NSBundle alloc] initWithURL:podBundleURL];
              return bundle;
              }


              Once you have the bundle you can load the view. Also, run a pod install after you edit the .podspec and add a new file to reorganize the files.






              share|improve this answer




























                0














                I seem that the bundle is not the correct one. I use this function in my pod library in order to get the bundle



                - (NSBundle *)getBundle {
                NSBundle *podBundle = [NSBundle bundleForClass:self.classForCoder];
                NSURL *podBundleURL = [podBundle URLForResource:@"MyPodName" withExtension:@"bundle"];
                NSBundle *bundle = [[NSBundle alloc] initWithURL:podBundleURL];
                return bundle;
                }


                Once you have the bundle you can load the view. Also, run a pod install after you edit the .podspec and add a new file to reorganize the files.






                share|improve this answer


























                  0












                  0








                  0







                  I seem that the bundle is not the correct one. I use this function in my pod library in order to get the bundle



                  - (NSBundle *)getBundle {
                  NSBundle *podBundle = [NSBundle bundleForClass:self.classForCoder];
                  NSURL *podBundleURL = [podBundle URLForResource:@"MyPodName" withExtension:@"bundle"];
                  NSBundle *bundle = [[NSBundle alloc] initWithURL:podBundleURL];
                  return bundle;
                  }


                  Once you have the bundle you can load the view. Also, run a pod install after you edit the .podspec and add a new file to reorganize the files.






                  share|improve this answer













                  I seem that the bundle is not the correct one. I use this function in my pod library in order to get the bundle



                  - (NSBundle *)getBundle {
                  NSBundle *podBundle = [NSBundle bundleForClass:self.classForCoder];
                  NSURL *podBundleURL = [podBundle URLForResource:@"MyPodName" withExtension:@"bundle"];
                  NSBundle *bundle = [[NSBundle alloc] initWithURL:podBundleURL];
                  return bundle;
                  }


                  Once you have the bundle you can load the view. Also, run a pod install after you edit the .podspec and add a new file to reorganize the files.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 21 '18 at 13:34









                  Fede HenzeFede Henze

                  555615




                  555615

























                      0














                      The problem was that I was using:



                      s.resource_bundles = {
                      "MyPodName" => ["MyPodName/*.xib"]
                      }


                      This does not seem to work with the approach i had done. So I had to change podspec file to:



                      s.resources = ["MyPodName/*.xib"]


                      That made everything work






                      share|improve this answer




























                        0














                        The problem was that I was using:



                        s.resource_bundles = {
                        "MyPodName" => ["MyPodName/*.xib"]
                        }


                        This does not seem to work with the approach i had done. So I had to change podspec file to:



                        s.resources = ["MyPodName/*.xib"]


                        That made everything work






                        share|improve this answer


























                          0












                          0








                          0







                          The problem was that I was using:



                          s.resource_bundles = {
                          "MyPodName" => ["MyPodName/*.xib"]
                          }


                          This does not seem to work with the approach i had done. So I had to change podspec file to:



                          s.resources = ["MyPodName/*.xib"]


                          That made everything work






                          share|improve this answer













                          The problem was that I was using:



                          s.resource_bundles = {
                          "MyPodName" => ["MyPodName/*.xib"]
                          }


                          This does not seem to work with the approach i had done. So I had to change podspec file to:



                          s.resources = ["MyPodName/*.xib"]


                          That made everything work







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 28 '18 at 13:35









                          MetarevenMetareven

                          532420




                          532420






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412542%2fusing-nibs-from-cocoapods-in-swift-4%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              Tangent Lines Diagram Along Smooth Curve

                              Yusuf al-Mu'taman ibn Hud

                              Zucchini