views:

501

answers:

4

i have iphone with os ver. 2.0 i read that for app store all appplication must be run 3.0 os.so how could i make my application to run in both firmware.is there a way i can detect if os ver.>3.0 then run different statments alse run statments for lower than 3.0 os.currently i am using this.

#if __IPHONE_3_0
cell.textLabel.text=cellValue;
[cell.textLabel setFont:[UIFont systemFontOfSize:15.0]];
[cell.textLabel setLineBreakMode:UILineBreakModeTailTruncation];
#else
cell.text=cellValue; 
[cell setFont:[UIFont systemFontOfSize:15.0]];
[cell setLineBreakMode:UILineBreakModeTailTruncation]; 
#endif

will it run on both firmware

i want to make my app to be run on >=3.0 os and lower than this...please help me

how do i check my application for deprecated methods...i can only see this line as deprecated cell.text=cellValue;

is there anything to change.i have installed new sdk named iphone_sdk_3.0__leopard__9m2736__final.dmg

+1  A: 

There was a similar post some time ago. Have a look at Apple's MailComposer sample to see en example of an app that supports both 3.0 and 2.x firmware

Vladimir
i want to run on greater than or equal to 3.0 and lower than 3.0
Rahul Vyas
i have not included any framework which is only available in 3.0
Rahul Vyas
i just want to sure that my 2.0 app will work on 3.0 or greater os.
Rahul Vyas
See Benno's answer then. Application build with 2.x SDK must work on 3.0 firmware. However some methods defined as deprecated in 3.0 and may not be available in future. Deprecated methods usually generate compiler warnings so you can easily find them in your project.
Vladimir
A: 

If you build it against the 2.0 (or 2.1, or 2.2.1, etc) SDK, it will run on that SDK and any later version unless Apple specifically discontinue support for that SDK. I see plenty of apps in the App Store that say they work with iPhone OS 2.x or later and they run fine on my iPhone 3G running 3.1.

Benno
+1  A: 

Your code above will not run on both sets of OSes. When you use #if statements, you are basically excluding code for one version of the OS for that particular build. In other words, each version that you build, one when you define __IPHONE_3_0 and one when you don't, will exclude the code for the other.

What you are doing is building two executables, one that is built for __IPHONE_3_0 and another for ! __IPHONE_3_0.

If you want to build one executable, that is one app, that runs on both, then you need to replace the #if statements with runtime ifs, not compile time #ifs, like:

if (theOS >= kiPhone3)
   ....
else
   ....

You can also link in libraries that are 3.0 only, but test for the availability of the framework at runtime, and then skip the call if the methods aren't available. There are different calls you'll need to use, one for checking to see if a method is available, and one for if a class is available:

Class newClass = (NSClassFromString(@"NewClassName"));
    if (newClass != nil)

Last thing, there is a later version of the SDK than the one you mentioned.

Good luck!

mahboudz
i use this float version = [[[UIDevice currentDevice] systemVersion] floatValue];if (version >= 3.0) { cell.textLabel.text = [self.FriendName objectAtIndex:indexPath.row];// iPhone 3.0 code here } else { cell.text = [self.FriendName objectAtIndex:indexPath.row];// iPhone 2.0 code here }but it's failed when build for 2.0..giving error in this linecell.textLabel.text = [self.FriendName objectAtIndex:indexPath.row];request for member "textlabel" in something not a structure or union
Rahul Vyas
i just want to run my app either on 2.0 or above and either 3.0 or above..using one executable only
Rahul Vyas
Don't build for 2.0 anymore. You want one executable, so you build once with the 3.0 SDK in the Project Base SDK (and the active SDK).
mahboudz
it worked..i set the device 3.0 debug in active target..set base sdk to 3.0 and deployment target to iphoneos 2.0..so i test it on my 2.1 iphone..it's run.but i'm not sure how do i check that it will run on 3.0 os
Rahul Vyas
A: 

The if-else directives will hide one part of the code from the compiler so it won't run on both software.

garyhgaryh