PDA

View Full Version : How to compile it??




arnieterm
Nov 13, 2008, 12:00 AM
For an Iphone project, I have created a custom UIButton subclass [.m/.h] and it is working fine with that project.
What I want to do is to compile the .m file and convert it into a library like we does in windows where a class library is compiled into DLL and then that dll is sharable by multiple programs.
How can I achieve the same thing in objective c for I phone program so that I do not need to add the .m file for the subclass each time when I work on any new project instead just add reference like framework library



robbieduncan
Nov 13, 2008, 05:22 AM
The correct Cocoa answer is to put it in a Framework and link against that. But your not allowed to do that on the iPhone. The only real solution available to you is to include the .h/.m files in each and every iPhone project you want to use the code in.

arnieterm
Nov 13, 2008, 06:34 AM
Though i do not fully understand static library still wnat to know whether it can be an alternative for my question? If yes then how?

robbieduncan
Nov 13, 2008, 06:38 AM
Though i do not fully understand static library still wnat to know whether it can be an alternative for my question? If yes then how?

As far as I am aware no: the SDK agreement clearly and simply states the case. I suggest you read it.

PhoneyDeveloper
Nov 13, 2008, 08:34 AM
There's no problem with using a static library. It doesn't violate the SDK agreement. Only dynamic libraries do that.

robbieduncan
Nov 13, 2008, 09:19 AM
There's no problem with using a static library. It doesn't violate the SDK agreement. Only dynamic libraries do that.

If it's statically compiled into the main executable of the application I 100% agree. But in this case you might as well simply include the files into each project...

If it's shipped as a separate file I'm not so sure. Section 3.3.2 says "An application may not itself install or launch other executable code be any means, ..., calling other frameworks, other APIs or otherwise ..."

PhoneyDeveloper
Nov 13, 2008, 10:10 AM
A static library is by definition compiled into the app. I agree that for a small number of source files there's little benefit to using a static lib. If you have a larger number and they make up a coherent module then it makes sense.