How to develop distributable UI controls for iPhone? - iphone

I would like to develop a reusable UI control for iPhone. How should I go about doing this? When I say reusable I mean it's packaged in a dll (or whatever is used on iPhone platform) so it can be reused on multiple projects.

While dynamic libraries are not allowed to be used in iPhone applications that are to be sold on the iPhone App Store, here's a tutorial on building static libraries with the iPhone SDK. (assuming you don't want to release source code)

You have two options:
Supply the full source code. Other developers can then add it directly to their app.
Distribute the compiled version of your code as a static library.
As you're planning to develop a UI control, I suggest you also develop an IB plugin and ship that with it too.

You probably want to provide custom Interface Builder objects, or maybe source code libraries.

Well, the Xcode way would be to bundle your code into a Framework and link to that. However, under the iPhone you can't link to non Apple approved frameworks (even if they are your own)
So you would probably have to link in the source to the reusable code. A good article here

Related

Custom skins for iOS library

Background
I need to deliver library which will be used in other projets. It's front end to server API - contains API client and a few views to input data, make choices, commit changes - usual UI with very generic look & feel. Developer calls "start" it launches view, guides user throught some screens and then launches delegate definied by said developer.
EDIT: To clarify, I've that library up and running, my main concern is what is the best approach when it comes to applying skin from outside of the library.
What I want to achieve
To allow customisation of views by developers using my library
Server API logic should not be altered by developers(so compiled library)
Skinning should be as simple as possible
TL/DR
Is it possible to create compiled iOS library that contains views which can be skinned by typical iOS dev without 1000 page manual :)
Yes, you can distribute it as universal static library or .framework. Currnently both options require custom build scripts, but there are samples like Build fat static library (device + simulator) using Xcode and SDK 4+ . However how you make skinning without 1000 page manual is up to you ;)

iPhone : what the best way to integrated iPhone application to other application?

I want to reuse iPhone source code application with other application, so in Xcode iPhone does it be able build library .jar file?
You cannot reuse a whole application, but you can create a static library and have other apps link to it.
".jar" is a Java archive format, so no. iPhones don't come with a jvm. You can build libraries though.
The best way to recycle your code from one application to the next is to try to write in the most general or abstract way you can, i.e. in such a way as to minimize the dependence on any given project.

Does iPhone/iOS development allow the use of third-party compiled libraries?

We're currently negotiating an outsourced iPhone development - and one of our requirements is that we also get the project source at the end of the development to allow us to enhance/update once the initial app is released.
The developer does not want to release the source of their own common libraries - which is understandable - and have said that they will have to write new code to replace those libraries.
However - on other platforms, it is possible to include libraries as pre-compiled software so that the source code is not necessarily released. Is this possible with iPhone app development? And if so, is it easy to implement?
Yes it is perfectly possible look at the admob or flurry libraries for example
To make a static library look here http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html

Can I develop my own objective-C Framework for Cocoa Touch Applications?

Is it possible to create an own obj-C Cocoa Touch framework which can be used by other developers? And furthermore can you protect this framework?
I've created templates for Xcode 4 that allow you to build universal iOS frameworks (which work in both device and simulator).
Once the templates are installed, you simply select "Static iOS Framework" when creating a new project and it does the rest. It also works with unit tests.
https://github.com/kstenerud/iOS-Universal-Framework
You can create a static library. There is an option in the XCode project chooser to do this. You'll have to distribute the compiled static library file and the header files to users of your library. Your actual implementation files (.m) do not need to be distributed.
GHUnit does a good job of this - packaging up the libraries for both simulator and device - so I recommend looking at this project. (I also recommend using this library for unit testing :-)
The frameworks in Objective C are typically just C / ObjC code and a bunch of classes, nothing amazingly special. As such, you can create your own if you'd like, and then just include that in your project when you build it. The iPhone doesn't care about the difference, it just knows to put all that code into your app, along with everything else.
Have a look at the Framework Programming Guide on Apple's website. It will get you started. Essentially what you'll do is create a Framework project in XCode and then go from there.
As for "protecting" your framework, I assume you mean making your code unreadable. I'm not sure if and how you can do this, but perhaps Apple's guide will say something about it.
Yes you can create frameworks for use with Cocoa Touch.
However there are these caveats:
has to be a statically linked libary, no dynamic loading (dyld) for us
should be a combined (lipo) library for i386 (simulator), arm6 and arm7
you need to hack a bundle project into a framework
you should embed (small and few) images into the library so that the developer does not have to mess around with resources but just drags/drops it into his project
... or if you have large and many images build a bundle with these
I have guides for these things on my site.
1+2 = http://www.drobnik.com/touch/2010/04/universal-static-libraries/
The other links you have to google because this site does not let me post more than one URL.
You could make a static library available as binary (i.e. rudimentary "protection") to third parties, but not a dynamic one, as Apple's App Store policy prevents dynamic linking.
Take a look at a worked example for static libraries given at
this site
If you're going to do it, in my opinion JSON.framework is a great example to follow. To hide/obfuscate the source code is a different story, and a different question entirely,
When creating a new project, navigate to iOS > Framework & Library > Cocoa Touch Framework, it's as simple as that. When you are successfully compile, .framework will be created under Products folder in XCode. Right click to show in Finder, and you can find the output.
It's unlikely this will work the way you want it to because the other developers won't be able to use your framework. This StackOverflow Question explains why.

Reference a library in Xcode for iPhone App

I am used to Visual studio, I have class library projects that I reference in my web sites or windows applications. Using class libraries allows me to create common functionalities, utilities once and use them over and over again.
How do I do this with Xcode and iPhone App development?
I am looking for some details on how to create the library, where to stores the files and how to reference in my App. That is if it is possible.
I am very very new to Mac and Xcode.
Creating a Static Library for iPhone App
On the iPhone, you need to create a 'static library' target. This will build your code into a .a file which will then be integrated directly into your iPhone application.
http://db-in.com/blog/2011/07/universal-framework-iphone-ios-2-0/
This way has worked for me. If you need to use xibs or other non-compilable resource files in the framework, look at the embedded framework section.