xcode 发布 Cocoapod 时包含图像资源

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28126788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:31:42  来源:igfitidea点击:

Including image assets when releasing a Cocoapod

xcodecocoacocoapodsnsbundle

提问by Daniel Farrell

I have made a custom Cocoa control and want to release it and write a podspec.

我制作了一个自定义的 Cocoa 控件,想发布它并编写一个 podspec。

My control contains one image. How can I package this image so that when others install my pod, my code can find the image?

我的控件包含一张图像。如何打包此映像,以便在其他人安装我的 pod 时,我的代码可以找到该映像?

At the moment the image is included in the example applications Images.xcassets file and loaded using [NSImage imageNamed:...]. However, when others come to install my pod they won't want the example project: they will just want the classes and the image.

目前,该图像包含在示例应用程序 Images.xcassets 文件中并使用[NSImage imageNamed:...]. 但是,当其他人来安装我的 pod 时,他们不需要示例项目:他们只需要类和图像。

回答by Keith Smiley

You can either include the files individually or with an xcassetsfile. Either way on the CocoaPods side you just need to include them in your spec as resources

您可以单独包含这些文件,也可以包含在一个xcassets文件中。无论哪种方式在 CocoaPods 方面,您只需要将它们包含在您的规范中resources