The documentation states that "This project compiles to a static library which you can include, or you can just reference the source files directly."
Here's what I've done. I've downloaded it from GitHub and unzipped it. Here are the classes I can see.
Now which file among these is the 'static library' that I should import into my project?
Additionally, if I just want to reference the source files, should I just copy the .h/.m files in Classes into my project? I tried doing that but throws the following error when I try to build it:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_CALayer", referenced from:
objc-class-ref in AQGridViewCell.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Can any one show me how to set this up?
You may try to add the QuartzCore framework to your target.
All you need to do is add the class files to your project. Use the AQGridView.xcodeproj just as a reference to see how it uses the classes. It is actually a very friendly to use library of classes.
Once you added the class files to your project, when you create a new viewController, just follow the setup. Make sure you use the delegates for it and if you want to modify the gridViewCells just extend the AQGridViewCell class.
Also, as #FoJjen mentions, make sure you add the QuartzCore.framework to your project
First, add the classes. Then attach the library QuartzCore from Build Phases->LinkBinary with Libraries.
That's all.
Wasted 1-2 hours myself so wanted to share it with others
I see two possible ways of achieving this (tested on Xcode 4.5)
First way - Proper referencing
Ensure no other Xcode instance is open. Drag the Xcode project file (from Finder) into your project (into Xcode explorer window).
Click on your project in the explorer window, go to Build Phases, under Link Binary with Libraries, add "libAQGridView.a" and QuartzCore.framework
You should be all set. Just remember to include the necessary header files when you use it
Second way - Copying classes
You can have a look at the samples. It's merely copying the source code into the project (as opposed to linking it as a static library)
Related
I know something like this is already asked many times on SO, but I've tried everything (been at this for three hours now) and I still didn't find a solution. I'm quite new to xCode and I'm starting to work on a project that was originally created by somebody else.
So, I have a library project in my xcode (XS2Library) and now I would like to reference to that library in my other project (WaarBenJij). Building the Library succeeds and I reference to it by adding the LibXS2Library.a to the Project target's "Link Binary With Libraries".
Xcode doesn't give me any errors, so it looks like the library project is referenced appropriately. However, when I try to build my project I get the error that a class that resides in my library project cannot be found ("'XS2URLLoader.h' file not found").
Can anybody steer me in the right direction, maybe?
There's a sensible difference between the .a file, which is needed for linkage and contains the library source, and the .h file, which is needed to compile (and preprocess) and which contains the functions and classes declarations.
Here you included the .a file, which is required for a later step, but to use the library you also need to import the required .h files into your project.
The easier way is to simply put them in your project.
Or you can add the whole library as a subproject and as a dependency.
I'm creating an iphone app using xcode 4.2, and trying to use the AVFoundation Framework to play some radio stream.
When i import it to the project's frameworks and the build, i get the following warning:
ld: warning: ignoring file /Users/xanthos/Documents/tabbartest/AVFoundation.framework/AVFoundation, file was built for unsupported file format which is not the architecture being linked (i386)
and of course when using anything of the framework (eg AVAudioSession) i get errors like:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_AVAudioSession", referenced from:
objc-class-ref in RadioStreamer.o
I've read so many posts about how to compile AVFoundation Library, by i really don't get it, i'm really inexperienced in all these. I can see there's something with the linking of the library, but not completely understand it.
Any clues please?
Thank you in advance.
It looks like you have you copied AVFoundation.framework from somewhere to your project directory. That's wrong. You just need to add it to the "Link Binary With Libraries" build phase of your project:
In Xcode, select the project in the navigator on the left.
Select the 'Build phases' tab in the main area in the middle.
Open up the 'Link Binary With Libraries' section.
Click the '+'.
Select `AVFoundation.framework. and click 'Add'.
I am trying to build an App using the GData static library libGDataTouchStaticLib.a
I have made all the appropriate linkings in my project settings and have copied GDataXMLNode.h and GDataXMLNode.m to my project.
I am receiving the error below. Can someone help me understand what this is?
ld: duplicate symbol _kGDataXMLXPathDefaultNamespacePrefix in
/Users/myUser/Library/Developer/Xcode/DerivedData/GData-edmqtrniowvhfjgfgngtlfxttvri/Build/Products/Debug-iphoneos/libGDataTouchStaticLib.a(GDataXMLNode.o) and
/Users/myUser/Library/Developer/Xcode/DerivedData/MyApp-grzimbvctfmwhmdluxbuxmskcvzy/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/GDataXMLNode.o for architecture armv7
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
You shouldn't have to copy in GDataXMLNode.h and GDataXMLNode.m to your project. I believe the reason you are getting the duplicate symbol error is because the libGDataTouchStaticLib.a library already contains the compiled GDataXMLNode.m class.
I am currently using the GData library in a project I am working on, and got it set up by using these instructions: http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/, so this answer assumes that you have the same setup. However I have used a slightly different way of importing the headers that was suggested by one of the comments on the above blog.
In your Xcode project remove the GDataXMLNode.h and GDataXMLNode.m files, and make sure that the GData.xcodeproj project is linked into your project the same way as in the above blog, but do not drag the headers directory to your source tree. Add these arguments to the Debug and Release Header Search Paths of your current target instead:
/usr/include/libxml2
${BUILT_PRODUCTS_DIR}/Headers
You can find this under the Build Settings tab of your target. The second argument will import all the GData headers into your project if you have set up the GData.xcodeproj file correctly. Once you have done this you should be able to import the various GData classes including GDataXMLNode.h class wherever you need it by typing this at the top of the appropriate class:
#import "GDataXMLNode.h"
Much credit goes to Kelvin's blog for his great tutorial. Hope that helps!
GDB: Program received signal "SIGABRT"
I'm running a problem with a few things according to the Build log, please could you shed light on the possibilities that these errors could be caused by. All help is appreciated.
Summary of project:
I have two projects which i have taken some .h, .m and .a files from one project folder, dragged them into the other project, then going through
Menu > Project > Add to project I have imported them into the Static Library of the project.
Some lines of code I have blanked my details out for privacy.
Here are the errors I'm getting...
found branch-22 without store in _SOGLH
found branch-22 without store in TrackerInterface::InstantiateTracker()
ld: warning: ignoring file /Users/myname/Desktop/*projectname*/*It's_a_dot_A_file*.a, file was built for archive which is not the architecture being linked (armv7)
I'm relatively new to Xcode so I'm not confident with some of the terms so please bear that in mind.
King Regards,
R.
For the last error, it is quite self-explanatory: you are trying to include a library (.a) file that has been built for a different architecture.
Probably a library that has been built for OSX-32bits or OSX-64bits and that you are trying to use for iOS (which uses architectures armv6 & armv7).
Rebuild the library for the correct architecture (armv7) of if it is a third-party library, use the appropriate .a file for the appropriate architecture.
I have 2 projects and I want to use in the first project, a class (i.e. view controller) of the second. Instead of importing all the files of the second project in the first one, is there a way to link it like a framework or library?
I tried the following unsuccessfully:
Dragged-dropped SecondProject.xcodeproj and checked SecondProject.app as a target
Added it as a dependency project in the first project dependencies
Pointed to the header files by adding in the "Header Search Paths" a path pointing to the second project which I copied in a subfolder of the first project.
When I include "SecondProjectViewController.h" I get no errors but when I try to instantiate it I get the "OBJ C referenced from" error.
Any help is deeply needed and appreciated! =)
F.
As an experienced developer I would suggest not sharing code this way across projects. The simple reason is that changes in one project will then directly effect other projects, often rendering them un-compilable. For example, if you share a controller class and decide to implement a change with a new import, then any project that uses that class will be broken until you open then in xcode and ensure that the imported class is available.
A better method is to compile your first project as a static library or framework. I'd also recommend ensuring that it is version some way. For example, in my projects I create static frameworks and store them in a directory called "v0.0.1", "v0.0.2" etc.
The framework can then be dragged and dropped into a second project to use it. The second project then refers to it via the directory path. The advantage of doing this is that if I then change the first project, the second one if not effected by the changes until I choose to update the frameworks path.
Sharing files between projects will work for small cases, that being 2 or 4 projects, but once you have more than that it rapidly becomes un-manageable.
You have only a few steps to go:
4) in First project, click the disclosure triangle in the Groups and Files section for the Second Project reference. this will display the targets of Second Project.
5) Drag the target reference (e.g., static library) from Second Project to the target in First Project's link phase.
That should clear up all the linker errors for the symbols which exist in Second Project's library. Of course, you'll have to remove those sources (based in second Second) which are compiled and linked from First.
Managing static libraries for huge codebases is dead easy this way (although I prefer the build up to the minute (as well as several build variants), and don't reference archived binaries as Derek does). Learning to minimize changes which break builds takes time to learn. dynamic libraries are a bit different - depending on their distribution, you may want to version (as Derek outlined). It's good to share, but you should put the shared exported symbols in a library, which is a dependency of both apps. Just be careful not to add too much unnecessary objc symbols to the library - objc symbols and their references cannot be stripped from the final executable and they will cause runtime collisions if they appear in two images (dylib, app, static lib) within the same process.
You can add the view controller's files to your 1st project regardless of where they are on disk -- the project will make a reference to their location.