Altruistic Programmer's Blog (EN)

Meanings of Base SDK and Deployment Target

without comments

Please read SDK Compatibility Guide to get details. 
(http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/cross_development)

 

Weak Linking

  • No link errors occur even if you don't have symbols(variables, methods, classes) to be linked.
  • No runtime errors occur even if you don't have symbols to be loaded.
  • Therefore, you must ensure the availability of  the symbols  before using them.

Strong Linking

  • Link errors or runtime errors occur if you don't have symbols.

Base SDK Version

  • The maximum version of SDK(or iOS) on which your app can run.
  • You can not use the new features introduced in the higher versions.

Deployment Target Version

  • The minimum version of SDK(of iOS) on which your app can run.
  • The symbols in the versions higher than this are weakly linked.
  • The symbols in the versions lower or equal to this are strongly linked.

How to use

  • Determine the minimum and the maximum version on which your app can run.
  • Set the maximum version to the Base SDK version.
  • Set the minimum version to the Deployment Target.
  • For weakly linked symbols, you must ensure the availability of them at runtime before using them. 
  • For strongly linked symbols, it will make errors at compile time.

Special Note

  • If the superclass is unavailable, the subclass is unavailable, too.
  • If the delegate which your class implements is unavailable, a runtime error occurs when your app is loaded.

Tip

  • To make compile errors for expected problems on a specific version of iOS, set the iOS version to the Base SDK version and build your project.

Written by muscly

May 10th, 2011 at 11:45 am

Posted in Programming

Using private properties in Objective-C 2.0

without comments

You can use class extension to hide properties from the header.

// A.h
@interface A : NSObject {
}
-(void)setXXX:(int)i;
-(int)xxx;
@end

// A.m
#import "A.h"
@interface A()
@property int m; // HERE
@end

@implementation A
@synthesize m; // AND HERE
-(void)setXXX:(int)i {
self.m = i;
}
-(int)xxx {
return self.m;
}
@end

Class extension is better than category because

  1. You can define properties.
  2. Declaring a method without an implementation makes an error.

Written by muscly

May 1st, 2011 at 11:23 pm

Posted in Programming

Checking CPU architecture of object files

without comments

Sometimes XCode shows me a link error that the architecture doesn't match when I build an open source library. Yo can check the target architecture of the .o files in an .a file like this.

otool -hv libxxxx.a

Though I thought I had made no mistake at all, linking was failed. I checked it out, and it was built for x86_64. Finally I succeeded in building it for the simulator by a forceful -arch i386 options.

If you remove a -v option, otool shows you cputype and cpusubtype as number. You can find the meaning of that number in /usr/include/mac/machine.h (But, you don't need to…)

Written by muscly

April 29th, 2011 at 7:47 pm

Posted in Programming

My blog has become multilingual.

without comments

I repaired my blog so that I can post in Japanese and English. You can see the flags on the upper right corner. My english is still poor, but I wish I could post in Japanese and English fluently someday.

Today, I just subscribed to PayPal and paid about one thousand dollars. So a woman who speaks English called me. I was too embarrassed because I was eating. Why I did speak in Japanese? I'm ashamed. ^^;;

Written by muscly

May 8th, 2010 at 9:09 pm

Posted in Etc.