xcode Interface Builder 看不到静态库中的类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1058766/
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
Interface Builder can't see classes in a static library
提问by teabot
I have refactored some UIView sub-classes into a static library. However, when using Interface Builder to create view components for a project that uses the static library I find that it is unaware of the library classes. What do I need to do to make the class interfaces visible to Interface Builder?
我已经将一些 UIView 子类重构为一个静态库。但是,当使用 Interface Builder 为使用静态库的项目创建视图组件时,我发现它不知道库类。我需要做什么才能使类接口对 Interface Builder 可见?
Update:The correct answer refers to dragging the headers into the 'XIB browser'. The '.h' files can be dragged from a finder window to the window area identified in this image:
更新:正确答案是指将标题拖入“XIB 浏览器”。可以将“.h”文件从查找器窗口拖动到此图像中标识的窗口区域:
alt text http://img211.imageshack.us/img211/1221/xibbrowser.png
采纳答案by Reed Olsen
Try dragging the static library into your xib browser in Interface Builder. I haven't tried this with a static library, but the concept is the same. When you drag header files into IB, you can access those classes.
尝试将静态库拖到 Interface Builder 中的 xib 浏览器中。我还没有用静态库尝试过这个,但概念是一样的。当您将头文件拖入 IB 时,您可以访问这些类。
回答by Dave
LexH, try linking with the -ObjC flag when building your static library. That worked for me... for about a year :-) I found this post as the problem has returned with a fresh OSX install and an upgrade in xcode. But it worked in XCode 3.1.2.
LexH,在构建静态库时尝试使用 -ObjC 标志进行链接。这对我有用......大约一年:-)我发现了这篇文章,因为问题已经随着全新的 OSX 安装和 xcode 的升级而回归。但它适用于 XCode 3.1.2。
- David
- 大卫
回答by CodeFlakes
Add the same problem as LexH. It worked only when I called a dummy class method. The problem was that I did not add my static library to the "link binary with libraries" under target. Strangely everything else worked.
添加与 LexH 相同的问题。它仅在我调用虚拟类方法时才起作用。问题是我没有将我的静态库添加到目标下的“链接二进制文件”。奇怪的是,其他一切都奏效了。
I followed this guide to link with my static lib Create static lib
我按照本指南链接到我的静态库创建静态库
回答by Michael Hourigan
I had the same problem. Dragging the library or headers to XIB Browser didn't work. Read Class Files didn't work. So I called:
我有同样的问题。将库或标题拖到 XIB 浏览器不起作用。读取类文件不起作用。所以我打电话给:
[MyLibraryClass version]; // Substitute your class name for "MyLibraryClass".
This worked. version is a class method of NSObject, so all subclasses of NSObject inherit it.
这奏效了。version 是 NSObject 的一个类方法,所以 NSObject 的所有子类都继承它。