Preparing my application for release

Member
Posts: 26
Joined: 2006.09
Post: #1
hi,

I have just recently started programming on Mac and I have still have a lot of troubles trying to find my way around.

So far I have been able to get SDL (using the precompiled framework), libpng and freetype from Darwinports working in XCode. My program is build on top of the OpenGL sample from the SDL distribution.

I took me a while to figure out how to open files, but with the help from the forums I got it working (changed the chdir in the .m file). I'm not sure why it works, but it does :) For example my font files are in the root folder of my project in a folder called Fonts. They are included in the project, but I need to access them without the path.

1) Everything works fine when I do Debug build, but when trying compile the Release version I et following errors:

/usr/bin/ld: warning /opt/local/lib/libfreetype.dylib cputype (7, architecture i386) does not match cputype (18) for specified -arch flag: ppc (file not loaded)
/usr/bin/ld: warning /opt/local/lib/libpng.dylib cputype (7, architecture i386) does not match cputype (18) for specified -arch flag: ppc (file not loaded)
/usr/bin/ld: Undefined symbols:
_FT_Done_Face
_FT_Done_FreeType
... (this list goes on with all the functions used from freetype, and SDL).

I'd guess it is trying to build universal binary, but the libraries I build are only build for x86.

2) How do I prepare my application to release? I have tried to look at the Apple Developer site documentation about the bundles, but it does not make any sense to me at all. I guess I don't understand where I should put that stuff and where to create the hierarchy, or is this something XCode does for me automatically. Are there any examples of how to setup a simple application?

3) Related to #2, how about dynaic libraries? I read from somewhere that I can include frameworks in bundles, but how about those Darwin port libraries? I want to get this simple drag & drop install process.

This all seems really confusing for now (including learning new keyboard layout!), but I know over time I will learn it, I just need a kick to right direction I guess :)
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #2
memon Wrote:2) How do I prepare my application to release? I have tried to look at the Apple Developer site documentation about the bundles, but it does not make any sense to me at all. I guess I don't understand where I should put that stuff and where to create the hierarchy, or is this something XCode does for me automatically. Are there any examples of how to setup a simple application?
If you use the SDL Xcode project templates, a lot of the work will be done for you automatically. An application bundle will be created, and the SDL framework will be copied to the Frameworks folder in the bundle for you. If you add individual graphics, sound, and data files to the Resources folder in the project's Groups and Files list, those files will get copied to the bundle's Resources folder when you build your project.

Things are a little trickier if you want to have folders for your files, such as Levels, Graphics, Sound, and Fonts. When you add the folder to your project, a window will open and you will have the choice of recursively creating groups or creating a folder reference. If you create a folder reference, and you add the folder to the Resources folder in the Groups and Files list, those folders should get copied to the bundle's Resources folder when you build your project.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
DesertPenguin
Unregistered
 
Post: #3
I am still learning as well, but here are some tips I have gathered:

1) Best to deploy as a dmg. You can easily create a DMG using Disk Utility in /Applications/Utilities. Simply drag your .app out of the releases build directory and create a dmg from it.

2) Everything can be contained in the .app bundle. This includes all your resources. If you put your resources in your xcode project resources directory, then they will be automatically copied into your bundle. Typically they are put in xxx.app/Contents/Resources. You can view the contents of any .app using %I from Finder.

3) You are correct, the release build is universal. I would try to get universal builds of all libraries you need. I was using static libraries for glew and lua - to create a univeral I built them for both targets and then lipo them together.

The more I learn about xcode, the more impressed I become.
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #4
Now it makes a bit more sense. I finally found this structure in XCode too yesterday (I think it is under Product or similar). So I guess the single icon I see in Debug folder actually is the whole bundle.

DesertPenguin, can you describe the steps on how to do compile to both targets and combine them? Is there some common procedure to create static libs, or is it dependant on the project I'm building? I have downloaded the freetype2 and libpng from drawinports if that makes any difference.

Is there some nice document describing the different files there are for each library? I noticed at least .a, .la, and .dynlib. I included the .a in the project. Sorry for these stupid questions.


I'm starting to get used to XCode too, but there are two things that are totally driving me nuts. First is the tab, in visual studio it indents, in XCode you need to press alt-tab to indent, another is how the word-skipping works.. especially the end of the line (it does not stop there!). It is funny to notice how much you actually start to trust on those automatic helpers. I have had hard time lately to try to learn to memorize function arguments again, too Smile
Quote this message in a reply
DesertPenguin
Unregistered
 
Post: #5
One Sad Cookie has a tip page that discusses the compiler settings for a Universal build, but I can't find the link.

I did find a quote of his from this forum that helps:
"From Xcode, you build a universal binary by choosing the 10.4u SDK in your project preferences, and adding both PowerPC and Intel to the architectures setting for your target.

From the command-line, you do it by building your application twice, once passing:

-isysroot /Developer/SDKs/MacOSX10.3.9.sdk -arch ppc

to the compiler and linker, and once passing

-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386

that gives you separate PowerPC and Intel binaries, which you stick together with lipo."

As far as which file types you need, that depends whether you want to statically link or not. The .a is the static archive. After linking with it, it's contents are embedded in your compiled code and it is no longer needed.

As far as XCode differences, you are correct some may be better and some may be worse....for the most part it is basically just as good but different.

One tip I didn't figure out for a while was code completion - which is ctrl-.
(That is control-period).

Happy X-Coding!
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #6
So today I had a little bit of time to try the realease build thing again, and I tried at least six or sevent different things out there. Including bunch of scripts earlier post by OneSadCookie on this forum. For some reason all the stuff I could found asked me to use lipo to combine the libraries, but I just could not get it to work. No matter what I tried.

After giving up already I finally found this page, where I could find frameworks for the libraries I need:

http://www.kyngchaos.com/software/unixport/frameworks

Not sure if that is the greatest way to do it, but now it works.
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #7
memon Wrote:I'm starting to get used to XCode too, but there are two things that are totally driving me nuts. First is the tab, in visual studio it indents, in XCode you need to press alt-tab to indent, another is how the word-skipping works.. especially the end of the line (it does not stop there!). It is funny to notice how much you actually start to trust on those automatic helpers. I have had hard time lately to try to learn to memorize function arguments again, too Smile
I'm not sure what you mean about the tab-indentation thing, but in Mac OS X word jumping ignores punctuation and white-space (as you noticed). To jump a word use option-right/left arrow. If you want to jump to the front or the end of a line you typically use command-right/left arrow. For jumping to the top or bottom of a paragraph use option-up/down arrow. Similarly if you want to jump to the top or bottom of a page/document you typically use command-up/down arrow.

Additionally, in most cocoa apps you can use unix-style keyboard commands to jump around. (control-a/e for example)
Quote this message in a reply
Moderator
Posts: 770
Joined: 2003.04
Post: #8
memon Wrote:I'm starting to get used to XCode too, but there are two things that are totally driving me nuts. First is the tab, in visual studio it indents, in XCode you need to press alt-tab to indent,

Xcode > Preferences... > Indentation > Syntax-aware indenting > Tab indents: In leading white space/Always/Never
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #9
@Blacktiger, The option+arrow does not seem to stop at the end of the line either. I think visual studio has it's own special "programmer aware" word jumping, which is really fast way to move around once you get used to it.

@PowerMacX, That seems a bit better, but what I ment was that in VS if you select a piece of code and press tab it will indent the whole block one notch right. Enabling that option you mentioned does not anymore clear the block, so it helps a bit the withdrawal symptoms Smile

It seems I'm getting used to some things, like curly braces in Finnish mac keyboard are much nicer than on windows keyboard (once I got used to that).

As for the framework problem, it seem still unsolved. I simply cant believe it made so complicated. Does anyone now a good "lipo for dummies" or "gcc library files inside out" tutorials?

What I really would like to do is to build freetype2, libpng and libjpg (and later maybe openal and ogg too) as static libraries and also be able to compile them for universal binary (release) too. The goal is to build nice bundle I can distribute without any hassle to install frameworks, etc.

So far I have tried among the others the following ways, but so far they all seem to lack something, let it be compiling the universal binary or some lipoing or requiring to copy the frameworks, etc:
- darwin ports
- http://pythonmac.org/wiki/UniversalLibra...Extensions
- http://www.kyngchaos.com/software/unixport/frameworks
- the nice script bunch from OneSadCookie (could find the link for now)
- the 'compiling open source projects' doc from apple dev site
- bunch of other a bit more shady advices...

Gotta love SDL for the framework they distribute... Smile
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
For information on how to use lipo, read man lipo

My scripts just create PPC and Intel versions of the libraries, without joining them.* Since they're static libraries, that's not a problem (they'll be linked into your application in the end) it's just a matter of pointing Xcode at one place for PPC builds and another for Intel builds.
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #11
@OneSadCookie, I took another look at you scripts and now I almost got it working. There were quite some details I somehow overlooked the first time. Now I got the libraries combined with lipo (I think I was just using the wrong files the first time). The only thing I think I'm missing there is that for some reason the zlib is not being included in the ppc builds, hence undefined symbols.

I could not find any separated settings for the ppc and intel builds.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
The Xcode release notes explain how to make separate settings for PowerPC and Intel builds. I don't recall the details offhand, sorry.

A universal zlib is included with Mac OS X -- it shouldn't be any problem at all. You might have to add it to your project, though.
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #13
I think I got it working now. I have to send a package to my friend for testing still. The way I got it working now is to use the scripts from OneSadCookie's svn, and setting the the search paths as follows (I removed the paths automatically added when adding the library file to the project):

User Header Search Path:
/Users/memon/libs/Root/$(CURRENT_ARCH)/include /Users/memon/libs/Root/$(CURRENT_ARCH)/include/freetype2

User Library Search Paths:
/Users/memon/libs/Root/$(CURRENT_ARCH)/lib

Where /Users/memon/libs is path to the folder where the libraries are. I think the $(CURRENT_ARCH) is the trick OneSadCookie mentioned in previous post. For some reason I had to add -lz to the 'Other Linker Flags' to include the zlib. The compiler seemed to find it for the Intel builds just fine but complained about the missing symbols in PPC build. Weird...

Let's hope this finally resolves my issue... (fingers crossed). At least I learned a lot about setting up a project in XCode Smile

Thanks for all the help guys!

[edit] yep... it worked Smile
Quote this message in a reply
Rectangle
Unregistered
 
Post: #14
I compile my own carbon project with my company's static library.When I build it under
debug environment, everything perform well. But when I build it under release environment,I can't complete the build procedure. I don't understand what are the differences between release and debug. Who can tell me ? Thanks!
Quote this message in a reply
Post Reply