This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

using a cocoapod that is in a library that is in an app?

I am trying to use your swift iOSDFULibrary cocoapod. What I am doing is the following. I have a library written in swift. That library is where I have your iOSDFULibrary. I have a class object that imports your iOSDFULibrary. I can build my library just fine and I can access your cocoapod fine as well.

The problem I am having is when I try to use my library inside a test app that we have, which that test app is also written in swift. When I try to build my test app, it is telling me that it cannot find your cocoapod that is referenced in my library (ex via the import statement: import iOSDFULibrary).

I did try to add the iOSDFULibrary cocoapod to our test app as well and the error I had that it could not see the Zip cocoapod, which your iOSDFULibray cocoapod needs and is automatically installed when I install your cocoapod.

Has anyone seen or done anything like this? Am I supposed to do anything in the configuration so our app will recognize your iOSDFULibrary cocoapod and its dependency Zip cocoapod when those are installed inside my library? Any information on this would be great. Thanks.

  • Hi robmonti!

    This is a good question, to use the library as a dependency you simply need to add it as a dependency to your own cocoapod's podspec file, to do that, simply remove all the references to iOSDFULibrary from your podfile, then open up your myLibrary.podspec file and add a dependency field, it should look like the way we added zip as a denpendency to our podspec, you may see that here for reference.

    Simply, replace

    s.dependency 'Zip', '~> 0.7'
    

    to be

    s.dependency 'iOSDFULibrary', '~> 3.0'
    

    Note: You do not need to add Zip as a dependency, since our library already has that built in.

    after doing that you should go to your app and run

    pod install
    

    and you should be set to go, next time you run

    pod trunk push
    

    to release your cocoapod, your dependencies should be ready out of the box.

    hope this helps, if you encounter issues just let us know.

  • Thanks for the reply. While I was not originally using our library as a cocoapod (we were adding the library directly into our app), it looks like this may be the route I have to take.

  • @robmonti, it's a much better route for you that's true, you need to decouple your code and it'll be easier to use it with other libraries as well, also remember that you can have private cocoapods that are not published to the cocoapods trunk if you are not planning to release this to the public

    Please remember to the mark the question as answered to make the solution visible to future search visitors :)

Related