Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Aug 28, 2008
201
0
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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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

macrumors regular
Original poster
Aug 28, 2008
201
0
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?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
There's no problem with using a static library. It doesn't violate the SDK agreement. Only dynamic libraries do that.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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

macrumors 68040
Sep 2, 2008
3,114
93
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.