How to build my own static lib and link it to iphone game

Apprentice
Posts: 5
Joined: 2008.07
Post: #1
Hi, everyone,

I am not sure if it is right to post this question here... I am totally new to iMac and iPhone but have years of exp. on PC. I am just wondering if there is a way to create my own static lib and link it to other iphone game, which is my preferred way to develop games on other platforms.

I download iPhone SDK and use Xcode. I created a new iPhone app and added a new target to iphone static lib. After building the project, there is no such a .a file generated. Do I need to set up some preferences or sth?

What if I succeeded, how could I link this to my other iPhone project? I try to google the manual of Xcode, but it doesn't help me much.

Thanks!

-Hao
Quote this message in a reply
Member
Posts: 21
Joined: 2008.06
Post: #2
Hi,

. create a project... lets say "my_project"
. create a new target... lets say "my_lib"
. create a new target... lets say "my_game"
. project -> edit active target -> general -> direct dependencies -> [+] (add my_lib)
. project -> edit active target -> general -> linked libraries -> [+] add (my_lib.a)

riq.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.07
Post: #3
Thanks!

I followed your instructions and I can add "my_lib.a" to linked libraries, but I still don't have this my_lib.a. how can I compile this lib? it seems they share the same soure code?
Quote this message in a reply
Member
Posts: 21
Joined: 2008.06
Post: #4
I don't know what's happening in your machine. Those steps works Ok for me.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.07
Post: #5
I was thinking of if there is an automatic way to generate compiling resources, but now, I can only add files to my lib target.

So, is there a way, like filter or group, to add source files and headers to my corresponding targets?

thanks

hao
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.07
Post: #6
I figured it out. Different tools have different preferences and I think xcode is more compatible.

here comes another issue. if i compile a lib file, say mylib.a, and add it to another project, say mygame, then what i need to do is to copy .a file to mygame project, is it? and does code signiture of mylib.a matter to run on iphone?

-Hao
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #7
zwstudio Wrote:does code signiture of mylib.a matter to run on iphone?

Since it will be linked statically, a code signature would only be applicable to the final built executable.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.07
Post: #8
Thank all you guys! All I questioned is resolved.

Hao
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Xcode 4 Build Failure on iPhone target SparkyNZ 2 7,304 Apr 7, 2011 02:48 AM
Last Post: SparkyNZ
  Static libraries... the_wandering_monster 6 4,397 Dec 31, 2009 03:46 PM
Last Post: the_wandering_monster
  How can I build BOX2D as a static lib for the iPhone? riruilo 3 4,747 Oct 8, 2009 06:27 AM
Last Post: Skorche
  Static Library kendric 9 3,511 Sep 17, 2009 11:24 AM
Last Post: kendric