How do I create a cocoapod framework and add files to it?

♀尐吖头ヾ 提交于 2019-12-04 04:21:13

问题


I'm creating a private pod and would like it to be used as a module. According to Using Pod Lib Create, in CocoaPods.org:

The first question you're asked is what language you want to build a pod in. For both choices CocoaPods will set up your library as a framework.

In fact, when I run pod lib create MyLibrary, the initial project template they generate does have everything configured to be a framework, so that I can add a class to Development Pods/MyLibrary, and access methods of that class from the sample project simply by importing the module using @import MyLibrary; (or import MyLibrary, in Swift).

The problem lies on the fact that the same page tells us

With the questions over, we run pod install on the newly created Project.

And as soon as I do that, the module-related files are gone, and all the files that I had added to my Development Pods folders are gone. Not only that, the framework Target itself is gone, so it's not even a matter of simply adding the files back again.

What's the correct approach here? I don't seem to find anyone with the same problem.

I'm running Cocoapod v1.5.3

Any help is highly appreciated!

tl;dr:

  1. pod lib create MyLibrary
  2. cd MyLibrary/Example
  3. pod install
  4. Now notice that the project has no module configuration anymore. How can I avoid this?

回答1:


According to the same page:

[!] Note: Due to a Development Pods implementation detail, when you add new/existing files to Pod/Classes or Pod/Assets or update your podspec, you should run pod install or pod update.

In my experience, you have to be very careful when adding new files because they may end up on a different folder than the expected Pods/Classes.

When in doubt, I go to the folder containing the project and search for the missing file and move it to the correct folder.



来源:https://stackoverflow.com/questions/50661098/how-do-i-create-a-cocoapod-framework-and-add-files-to-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!