如何在OS X静态库中包含一个笔尖? [英] How can I include a nib in an OS X static library?

查看:95
本文介绍了如何在OS X静态库中包含一个笔尖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过几篇有关iOS的主题的文章,但是提到OS X的一两个内容只是说要构建框架而不是静态库. (我找不到具有不错的框架说明的帖子.)

I've seen several posts addressing this topic in regards to iOS, but the one or two mentions of OS X just say to build a framework instead of a static library. (I can't find the post that had decent framework instructions.)

我已将我的项目创建为静态库,并相应地对整个内容进行了编码.现在,我只想将我的框架放在演示应用程序中,并且抱怨缺少笔尖.作为权宜之计,我已将笔尖复制到父项目中,但是我想适当地划分整个内容.

I've created my project as a static library, and coded the whole thing up accordingly. Now, I simply want to put my framework in a demo app and it's complaining about a missing nib. As a stopgap, I've copied the nib into the parent project, but I want to properly compartmentalize the whole thing.

什么是最好的方法?

对于上下文:我创建了一个笔尖以在Mac应用程序中初始化NSWindowController.

For context: I've created a nib to initialize an NSWindowController in a Mac app.

推荐答案

不可能,因为静态库与捆绑包"不同.

No it isn't possible, because a static library is not the same as a "bundle".

静态库是一个单个文件,其中包含由库创建者链接在一起的类,代码和变量.它不包含"其他文件,它实质上是一个已编译代码的数据库.尽管可以将xib的数据放入其中,但是Xcode无法知道它是否在其中,因为Xcode会将它们作为文件系统中的单个文件进行查找.

A static library is a single file that contains classes, code and variables that were linked together by the library creator. It does not "contain" other files, it is essentially a database of compiled code. Although it would be possible to put the data for the xibs in there, Xcode would have no way of knowing that it was in there, as it looks for them as individual files on the filesystem.

选项1 :(不好)

只需将XIB与包含说明的README文件一起保存在静态库中即可.有点愚蠢的方法,但是它又快又不可怕,因为您已经拥有了一切.

Just keep the xib with the static library with a README file including instructions. Kind of dumb way but it's fast and not horrible since you already have everything.

选择2 :(还算不错)

Option 2: (fairly good)

您可以创建一个框架",实质上是一堆代码,资源,设置等,可以被多个项目重用

You may create a "Framework" which is essentially a bundle of code, resources, settings etc which may be reused by multiple projects

Apple Doc for Framework: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

Apple Doc for Framework: https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

https://developer.apple .com/library/mac/documentation/macosx/conceptual/BPFrameworks/Tasks/CreatingFrameworks.html

OS X Frameworks随机指南:(与旧版本的Xcode相同,但概念相同)

Random guide for OS X Frameworks: (it's with older version of Xcode but it's the same concept) http://www.intridea.com/blog/2010/12/28/a-visual-guide-to-creating-an-embeddable-framework-for-mac-osx

[UPDATE 1] 请注意,它不适用于iOS,因为App Store规则不允许应用程序捆绑包中的框架. (不是动态加载的代码). [感谢@nielsbot,他在评论中让我想起了这个.]

[UPDATE 1] Note that it won't work with iOS, since frameworks in app bundles aren't allowed by the App Store rules. (Dynamically loaded code isn't anyway). [Credit to @nielsbot who remind me of this in comments.]

[UPDATE 2] 阅读有关iOS 8的更多信息,他们在这方面进行了很多更改. (由于苹果的NDA不能谈论这一点)

[UPDATE 2] Read more about iOS 8 they changed a lot of things in this regard. (Cannot talk on that because of the Apple's NDA)

这篇关于如何在OS X静态库中包含一个笔尖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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