你能从iPhone上的静态库中引用Xib文件吗? [英] Can you reference Xib files from static libraries on the iPhone?

查看:190
本文介绍了你能从iPhone上的静态库中引用Xib文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我目前将所有代码分成静态库,以便更轻松地为实际应用程序设置xcode项目目标,并为我的代码进行单元测试。这个问题是我想把我的大部分xib文件放在静态库中,但似乎当我运行我的应用程序并尝试引用xib时它无法找到它,除非它包含在实际中应用程序的目标而不是静态库目标。是否可以将静态库中包含的xib文件和其他资源包含在同一个库中的代码中,如果是这样,如何?

In my app, i currently have all my code separated into a static library, to make it easier to set up the xcode project targets for the actual app and for unit tests for my code. The problem with this is that i want to put most of my xib files in the static library as well, but it seems that when i run my app and try to reference the xib it can't find it unless it is included in the actual app's target instead of the static library target. Is it possible to have xib files and other resources included in static libraries that can be referenced by code in that same library, and if so, how?

推荐答案

不可能,因为静态库与bundle不同。

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

包是一个目录,可能包含各种文件,包括资源文件(xib),可执行文件和静态库。它作为一组单独的文件存在于文件系统中。

A bundle is a directory that may contain all manner of files including resource files (xib), executable files and static libraries. It exists on the filesystem as a group of individual files.

静态库是一个单独的文件,其中包含由库创建者链接在一起的类,代码和变量。它不包含其他文件,它本质上是一个编译代码的数据库。

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.

虽然可以将xib的数据放在那里,Xcode会无法知道它在那里,因为它将它们作为文件系统上的单个文件进行查找。

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.

在Mac OS中,您可以创建一个框架,本质上是一组代码,资源,设置等,可以由多个项目重用。但是,Apple似乎不支持为iPhone OS创建自定义框架。

In Mac OS, you may create a "Framework" which is essentially a bundle of code, resources, settings etc which may be reused by multiple projects. However, Apple does not seem to support custom framework creation for iPhone OS.

Bundles
https://developer.apple.com/library /content/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1

静态图书馆
http://en.wikipedia.org/wiki/Static_library

这篇关于你能从iPhone上的静态库中引用Xib文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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