So I'm using the Static Library template included in Xcode. Right now just trying to build a simple template to see how static libraries really work.
Anyways in my static library I have two classes:
mylibrary (.h/.m) - This is simply an NSObject
modalView (.h/.m) - This is a UIViewController
The problem though is when I build the static library. The project builds the mylibrary.a file... however there is no "Headers" folder in the output. This means that when I add the library to my other project it gives "undefined" errors because it can't find the .h file for myLibrary.
Any ideas on how to fix this?
Thanks
You need to drag .h files to the new project, along with .a file
I have a bunch of scripts here:
https://github.com/drekka/dUsefulStuff/tree/master/scripts
Which I use to build static libraries and frameworks. You might find them useful in helping to assemble your library. The main (controller) build script is here
https://github.com/drekka/dUsefulStuff/blob/master/build.sh
Related
I have an app with two localizations.
Usually I use 'NSLocalizedString' and keep the same source code for both localizations, but one of my ViewControllers has to look and function different for each locale.
So I pressed 'Localize..' and created two localized versions of it. Normal stuff.
Since then - on runtime I get:
Unknown class MyViewController in Interface Builder file.
and the viewcontroller is not displayed (it's a UITableViewController if it matters).
I checked in my storyboard and the custom class is still listed & linked to the view controller display. I didn't change the class name in each locale - it's still the same.
what gives here?
thanks
i experimented this kind of problem in my project and my problem was my viewcontrollers .m file was not included in the compile sources in Build Phases->Compile Sources i manually add it to the Compile Sources and problem solved for me.
i hope it will help you.
I'm trying to use the open source STHorizontalPicker library to implement a horizontal picker to my project but when importing the .m and .h files from GitHub to my project I'm getting multiple errors when compiling.
Does it require any special implementation?
I'm simply copying the .h and .m and adding to the project. Error are like : property 'cornerRatius' cannot be found in forward class object 'CALayer'...
Do I have to import some class to those files ?
Thnaks in advice.
Do I have to import some class to those files?
Yes, you'll need Quartz.
#import <QuartzCore/QuartzCore.h>
Do you have any idea?
Why XCode compilation give this result?
ld: duplicate symbol _kJSONDeserializerErrorDomain in
/Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)
and /Users/Shared/_BUILDS_/Debug-iphoneos/libLACDLibrary.a(CJSONDeserializer.o)
I have exactly the same problem. And it only complains for arm6 build (not arm7 build). I found a workaround: remove "-all_load" in Other linker flag under Build<-Get Info<-Target. I am not sure whether it is a correct workaround. I hope somebody can explain further and provide the correct workaround if this one is not.
This error occurs if you link the same library into your project multiple times.
Project dependencies are subtly different from linking the libraries together. It is okay to have several projects depend on the same shared library project X; however, make sure that only one of the projects actually links the library.
Hey, you probably have a duplicate reference in XCode to CJSONDeserializer, so it's compiled and linked twice.
I hit this issue with code like the following in a file called Common.h:
void dumpViews(UIView* view, NSString *text, NSString *indent) {
// ...
}
By adding static in front of the method definition it cleared the problem up for me:
static void dumpViews(UIView* view, NSString *text, NSString *indent) {
// ...
}
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?
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:
alt text http://img211.imageshack.us/img211/1221/xibbrowser.png
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.
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.
David
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.
I followed this guide to link with my static lib Create static lib
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:
[MyLibraryClass version]; // Substitute your class name for "MyLibraryClass".
This worked. version is a class method of NSObject, so all subclasses of NSObject inherit it.
I have a static library that includes some xibs. These will basically be the same across projects. I'd like to include the xibs as part of the library. I can include their veiwcontrollers, reference these controllers in the calling project but then there isn't a xib to load. When I right click the xib in the library project, it can't be part of the target.
I thought about creating a CFPluginBundle but that creates a new project. I'd loose all of my IBOutlet and IBAction references. What is the best way to reuse xibs that also have outlets and actions to specific controllers?
Here more discussion about it: Can you reference Xib files from static libraries on the iPhone?
I had the same problem when I wanted to export my project as a library for other developers to use.
I found the perfect solution to my view and it seems it will answer yours too.
There is an xcode plugin that allows you to build your project as a library which includes the resources as well.
https://github.com/kstenerud/iOS-Universal-Framework
I do not know the guys that built this plugin, but it works like a charm
I'm not sure what you mean by "include the xibs as part of the library", since static libraries can't have resources--but they also aren't shipped stand-alone, so they don't need to. If you just want code re-use for your own projects, you could keep the xibs where-ever you keep the static library, and just include the xibs in any project that uses the library.
If you go the CFPluginBundle route, you can make new bundle targets in an existing project; there's nothing magic about the templates, they just take care of making dummy files and turning on the right build settings. You can copy those into a new target in your existing project and it will work just fine. That said, I'm not sure what you mean about losing IBOutlet and IBAction references, since that information is part of the xib (and the class you are using in the xib), not the project.