CocoaPods / Podspec和* .framework [英] CocoaPods/Podspec and *.framework

查看:549
本文介绍了CocoaPods / Podspec和* .framework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CocoaPods问题:

CocoaPods question:

我已经创建了一个与内部静态库捆绑在一起的框架,具体取决于AFNetworking和资源包(基于这两个教程来创建FWK < a href =http://www.blackjaguarstudios.com/blog/programming/2012/11/22/xcode-45-creating-ios-framework-and-hold-my-hand-im-3-years-old rel =nofollow noreferrer> http://www.blackjaguarstudios.com/blog/programming/2012/11/22/xcode-45-creating-ios-framework-and-hold-my-hand-im-3-years -old 和 https://github.com/bclubb/iOS-Framework

I have created a framework bundled with a static library inside, depending on AFNetworking and a resource bundle (based on those two tutorials to create FWKs http://www.blackjaguarstudios.com/blog/programming/2012/11/22/xcode-45-creating-ios-framework-and-hold-my-hand-im-3-years-old and https://github.com/bclubb/iOS-Framework)

我想创建一个podspec,这样人们只需在他们的Podfile中添加一行,在pod安装时,可以添加我的框架和AFNetworking,如果需要。

I'd love to create a podspec so that people just add a line in their Podfile, which would, on pod install, add my framework and the AFNetworking, if needed.

这可能吗?

推荐答案

我实际上已经完成了这在我办公室很多。我们有大量的私有源代码可以重复使用。 CocoaPods帮助更快地启动新项目并使它们更容易更新。

I have actually done this a lot at my office. We have tons of private source code that is re-used quite a bit. CocoaPods has helped get new projects started much quicker and makes them a whole lot easier to update.

虽然可以将您的框架添加到podspec,但我发现它通过CocoaPods传递静态库和标题更容易,而不用担心框架。

While it is possible to add your framework to the podspec, I have found it much easier to just pass the static library and headers over via CocoaPods rather than worry about the framework.

您必须根据您的项目更新podspec,但这里是重要部分:

You will have to update your podspec based on your project, but here are the important parts:

s.source_files = 'StaticLib/Headers/*.h'
s.preserve_paths = 'StaticLib/libYourLibrary.a'
s.library = 'YourLibrary'
s.xcconfig = { 'LIBRARY_SEARCH_PATHS' => '$(PODS_ROOT)/ProjectFolder/LibraryFolder' }    

s.dependency = 'AFNetworking'

这将复制你的静态库,并将你的pod带入AFNetworking。这将使您的静态库更小(无需构建)并加快用户导入pod的速度。

This will copy your static library over as well as bring over AFNetworking with your pod too. This will make your static lib much smaller (not having to build it in) and speed up how quickly the user can import your pod.

如果必须使用框架,上面相同的东西仍然适用,但你可能会做一些轻微的调整。无论如何,所有框架都是静态lib和头文件的漂亮文件夹结构,所以为什么要烦恼额外的东西。无论如何,源仍然都内置在lPods.a静态库中。希望这会帮助你。

If you must use framework, the same stuff from above still applies, but you might have some slight tweaking to do. All a framework is is a pretty folder structure for a static lib and headers anyway, so why bother with the extra stuff. The source is all still built into the lPods.a static lib anyway. Hope this helps you out.

这篇关于CocoaPods / Podspec和* .framework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆