creating a reusable library in XCode 3.2 - objective-c

How do I create a reusable library/module in XCode 3.2? What I want to do is create a bunch of classes that provide certain functionality compile them into some kind of library, add such a library to an existing xcode project and use the classes in it.
I come from .NET world so what I want to do is basically to create an equivalent of 'assembly' and then reference it somehow in my XCode project.
I am developing for iOS btw.

If you add a target called static library you will get the equivalent of an assembly, just put all the sources in the target and decide what headers should be published and what should be hidden to the user of your library.

What you are looking to do is create a 'framework'.
This page has some useful information.
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Frameworks.html

Related

Binding Objective C Reference

I'm trying to use a binding library (an Objective-C library) in my Xamarin Project. I followed all the instructions in the documentation.
When I try to use it I can't find it in the edit References/Projects. What do I need to do so that it shows up?
If the projects are in the same solution, and both projects are of the same type (Xamarin.iOS vs classic) Then it will show up under projects and you can reference it. Try making sure both of the projects have Xamarin.iOS in the references.

Can I import classes from an existing Objective C project into a Swift app

I have an existing app and I'd like to share a large number of classes from that app within a new app target. I'd like to leave the existing app as-is and treat it as a module (like a framework), importing it into the new app target which will be written in Swift.
Note this is NOT the simple documented case of adding Swift code to an existing Objective-C application target. I would like to see an example of using the module capability in Xcode to re-use code from an existing target in a new Swift target/module.
The existing app is built as an objective-C application (not a framework)
I would like to build a new app in Swift but use some of the non-gui code from the old app in the Swift app.
I have tried several times to see if there is a way I can import classes from the old iOS-objc app but I'm having difficulties using it in the new Swift app target, methods are not being found
I have turned on modules in this source app.
A) I would ideally like to import classes from the existing App target in the project without refactoring the original app.
B) If that is not possible I could potentially factor out the classes that are common into a separate objective-c framework. This I can get to work thanks to this (http://youtu.be/9us3uijFFpo) , but I'd like to see an example of A) if anyone can crack it. That use case is not covered in Apple's documentation.
But I've searched the web and I can't find any detailed examples of how to do this and my many various attempts to do so have been unsuccessful. There are plenty of references to adding Swift files into Obj-C apps, but nothing specifically about this kind of case.
You should read the chapter "Mix and Match" of this book from Apple:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html
It shows you how to import objective class to your swift project.
In general you have to do some steps:
add a "Bridging-Header.h" to your project with name: "YourProjectName-Bridging-Header.h"
Place your Obc headers somewhere then import ObjcClass.h to your project. I recommend to use "Link to file" instead of "Copy to
project"
In your bridging-header file, you add #import "ObjcClass.h" to import your ObjcClass header to your swift project
You may eventually have to specify Headers location in "Build Setting"

How can I distribute my objective c library with source code embedded

I would like for people to be able to debug my library, should they feel like they want to.
For this I think a good idea would be to embed the source in the library / framework itself. Does Xcode support this option?
For reference of what I’m looking for, in Java you can build a Jar file which comes with the attached source code (and optional javadoc) embedded within the library https://stackoverflow.com/a/5064833/48062
Xcode does not support this option, no. Your best bet would be to upload the source to Github (https://github.com) and include the link in your documentation for the framework. That way you can be sure that your users can always get to the freshest, most up to date, code.

Adding custom frameworks to Xcode frameworks list?

I have made a framework in Xcode. Each time I want to add it to another project, I need to look for it in its folder. Is there a way to add it to the frameworks list (like all the Apple frameworks) so that it's easier to add to a project?
Thanks.

How do I start a new Obj-C library project with Xcode?

I am new to Xcode (and Objective C in general) and I want to create a new Objective-C Library (Framework?) which will be used by some of our iPhone applications in the future.
Which type of project should I choose when Xcode shows the new project dialog? I tried selecting "Blank Project" but then I faced some issues in defining the target, dependencies, etc.
I want my project to be easily re-usable in the future both in code form and as a .dylib.
I would appreciate some help with this. Links to online docs are welcome.
Since version 3 of the SDK you are able to create library projects in Xcode. However, those projects do not create .dylib libraries, but static .a libraries.
You cannot create Frameworks for iOS, as Apple's own App Store rules state that apps sold through the App Store cannot load code dynamically, which is what Frameworks are for. Libraries are designed to be statically linked.