如何创建一个cocoapod框架并向其中添加文件? [英] How do I create a cocoapod framework and add files to it?
问题描述
我正在创建一个私有容器,并希望将其用作模块.根据使用在CocoaPods.org中创建Pod Lib :
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:
首先要问的是您要使用哪种语言来构建广告连播.对于两种选择, CocoaPods都会将您的库设置为框架.
实际上,当我运行pod lib create MyLibrary
时,它们生成的初始项目模板确实将所有内容配置为框架,因此我可以向Development Pods/MyLibrary
添加类,并从示例项目中访问该类的方法.只需使用@import MyLibrary;
(或Swift中的import MyLibrary
)导入模块即可.
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
问题结束后,我们在新创建的项目上运行
pod install
.
一旦这样做,与模块相关的文件就会消失,并且我添加到Development Pods
文件夹中的所有文件也都消失了.不仅如此,框架Target本身已经不复存在,所以甚至不必简单地将文件重新添加回去.
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.
我正在运行Cocoapod v1.5.3
I'm running Cocoapod v1.5.3
我们非常感谢您的帮助!
Any help is highly appreciated!
tl; dr:
-
pod lib create MyLibrary
-
cd MyLibrary/Example
-
pod install
- 现在请注意,该项目不再具有模块配置.如何避免这种情况?
pod lib create MyLibrary
cd MyLibrary/Example
pod install
- Now notice that the project has no module configuration anymore. How can I avoid this?
推荐答案
根据同一页面:
[!]注意:由于Development Pods实现的细节,当您 将新文件/现有文件添加到Pod/Classes或Pod/Assets或更新您的 podspec,您应该运行pod install或pod update.
[!] 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.
根据我的经验,添加新文件时必须非常小心,因为它们最终可能位于与预期Pods/Classes
不同的文件夹中.
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.
这篇关于如何创建一个cocoapod框架并向其中添加文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!