Targeting iOS version, and which features will be available - iphone

I am learning iOS development. And I had couple of questions, hope people don't mind
answering them here.
I was reading a chapter about ARC in a book. It seems nice. I've heard it is for iOS 5. Now, my question is, if I want my app to be available for iOS4 - does it mean I can't use ARC? (that would be a shame).
Also, I am not sure yet, for which version of iOS I should target my app. How is this reflected on my code? For example, I suppose if I target iOS5 I can't use features of iOS6 right? But if I target iOS6, then my app won't run on iOS4?
Any tips in this direction appreciated.

I agree with David's comment and you should concentrate on iOS 6, but for information and future you would construct your app using a combination of weak linking and respondsToSelector: so that your app can use features of newer versions of iOS but still be compatible with older versions.

NO Arc can be only for iOS 5 or later but if you want your older code to be ARC enabled then you can Refactor->convert to ARC for that file. Also if you want your code to be Arc disabled then for each file you can write down "-fno-objc-arc" in build settings.
Ya new features wont be compatible for your older versions. So make sure you should be very specific for your requirements. The requirements of your App will make you conclude which iOS version you should target.
Hope this helps :)

You can make individual file non-arc as per your requirement in Project.
It is very simple way to make individual file non-arc.
Follow below steps :
Disable ARC on individual file:
Select desired files at Target/Build Phases/Compile Sources in Xcode
Select .m file which you want make it NON-ARC
PRESS ENTER
Type **-fno-objc-arc**

you can use ARC in ios 5 and above but not in IOS4.
If you targeting your app to IOS 5 then you will be able to use ARC as well. If u target it to iOS 5 then it will work on IOS 6 as well (only the deprecated features wont work on iOS 6).

Related

Run iOS 5 application in iPhone 4.3.3

I am creating an iPhone project for iOS 5. I need to know if i can run the program in iPhone 4.3.3 and higher ?
Are you using anything in your code that was introduced with iOS 5.0 & newer? (such as storyboards)
If your answer is yes, then you can't run it on 4.3.3.
If no, then you can set the minimum required version to 4.3.X (and here's a tutorial you can use).
Here is a related question (and another one) that may help you out a bit more.
IIRC, you can configure the simulator in xCode to emulate an earlier version of iOS so you can confirm whether or not it will work on 4.3.3. Have a look at the build settings for your project, you can change the target O/S. I'm not sure all versions are available by default though. You might need to download other versions to test.
You said you are using ARC. ARC will work with iOS 4.x, but not iOS 3.x. So ARC will not be a problem. Based on everything else you said about not using storyboards and everything being coded, you should be okay. If you click on a method in Xcode it should allow you to bring up the documentation, and in the documentation it will provide the iOS version that it was released for. Make sure that this it iOS 4.3.3 or lower.

Developing Iphone app for iOS 4.0 in iOS 5.0?

I developing iPhone application for iOS 4.2 using latest SDK iOS5. I trying to add external classes Kal
but i gives me error "ARC forbids explicit message send of 'autorelease', 'retain', and 'release'". And i want to add this classes in my application in any how condition.
I want to execute that classes in my application.
I stuck on two points basically,
1) How i use explicit use of retain, release, and autorelease keywords
2) How i deploy my app on 4.0 lower version from latest iOS 5.0(Containing ARC scheme)
Thanks
RRB
There is a refactoring that will convert your classes to be compatible with ARC.
In XCode menu: Edit - Refactor - Convert to Objective-C ARC.
See this question for an explanation of how to disable ARC on a per-file basis. The solution here is probably to disable ARC for the Kal files while leaving it enabled for the rest of your project. (ARC works fine on iOS 4.0 with a couple of minor exceptions.)
You can turn the ARC off in the Xcode 4.2 for your project.
For more info , see the blogpost
Also , see this SO question

Is the use of storyboards in Xcode 4.2 production ready and recommended? (c.f. previous XIB methods)

Is the use of storyboards in Xcode 4.2 production ready and recommended?
That is, would iPhone/iPad developers that have used storyboards recommend (for native iPhone/iPad apps) to definitely use storyboards? Or are there some gotchas and issues still with the concept?
P.S. Also do storyboards assist in getting a Universal Application designed/working?
This depends, for the most part, on your target audience. The only potential deal-breaker is the fact that using storyboards requires you to set your app's deployment target to iOS 5.0 or later; a storyboarded app cannot run on any earlier version of iOS.
If you must cater to previous versions of iOS, you have to continue using individual nib files if designing your interface with Interface Builder. I'd also recommend sticking with whatever you're already using in your existing projects. (You can introduce storyboards into your existing projects in steps, but remember that they'll only work in iOS 5. There's a WWDC 2011 presentation that walks you through this process.)
For new projects, storyboards seem to be the way to go, as long as you're sure you won't need to deploy to previous iOS versions.
Also do storyboards assist in getting a Universal Application designed/working?
Not sure what you mean by "assist", but you have to create one storyboard of nibs for each device family. So one for iPhone/iPod touch, and one for iPad.
It would be interesting to know how much of the market you are missing out on by targeting only iOS 5. I have noted that there is a significant percentage of iPhone users who dont upgrade their iOS be it from iOS 3 to iOS 4 or even iOS 5 so any apps targeting iOS 5 will mean they can not download any app you create.
I started out using iOS 5 with storyboard and it's a great feature, but had to pull back and use xibs so that I get backwards compatibility. There's just too much of the market you will miss out on by only targeting iOS 5.
ARC is a great plus, and just for that feature alone I am happy with the transition to iOS 5. Not to mention the new CLGeoCoder class and JSON now included. Anyone who wants to use JSON API have a look at this great tutorial from Ray Wenderlich.

Using XCode 4.2, Is it possible to use Storyboards to make an iOS 4 compatible app?

I have searched for this answer, and have had mixed reviews. Some say it SHOULD be possible (like using ARC), and some say it's not possible. Can anyone give me a definitive answer either way?
According to apple NO. Apple always said storyboarding would only be for iOS5. But prove it to yourself. Start a new project, check use storyboarding, create the project. Then change the target iOS to 4.3 and run, the view will not load.
ARC will run even down to 4.2, though you can't use weak references below 4.3.

iPhone and SDK different version compatibility issues

I am a beginner Apple developer and I have some issues I would like to resolve.
First of all, I am curently working on Xcode 3.2.6 because I haven't enrolled for the developer program yet. I would like to know if Apple only accepts apps (for the App Strore) compiled on SDK 4.
Secondly, I want my apps to work both on iPhone 3 and 4. What would you advice me to do? I have read in several developer forums that in order to achieve this I have to build my application with 3.1 iOS as a target. Is this correct?
Finally, is there any problem due to the difference in resolution between iPhone 3 and iPhone 4? Which resolution do you think I should use?
Thank you in advance,
Cherry
Set Base SDK to latest (4.3).
Set Target SDK to 3.1.
Avoid features available only in iOS 3.2 or later (e.g., don't use blocks, don't frameworks introduced in iOS 3.2 or later, always check availability of methods). Later, when you get more experience with Objective-C, you may try to combine features of more modern iOS, but still keep compatibility with older iOSes.
Don't worry about resolution. It affects only images – if you want to take full advantage of Retina display, then you will need to create images for both resolutions (std. and hi-res).
P.S. I suggest you to avoid support for iOS 3.2 or earlier. iOS 4 introduces a lot of nice and helpful features. And I pretty sure, Apple will revoke support for iOS 3.x soon after iOS 5 release.
If you are aiming for iOS 3, you will end up not using the features of iOS 4, which is the majority.
This is Apple's statement.
Target the latest iOS release.
Targeting the latest release allows you to take advantage of all the features
available in the latest version of iOS. However, this approach may offer a smaller
set of users capable of installing your application on their devices because your
application cannot run on iOS releases that are earlier than the target release.`
Target an earlier iOS release.
Targeting an earlier release lets you publish your application to a larger set of
users (because your application runs on the target OS release and later releases),
but may limit the iOS features your application can use.`
But I would suggest that you target the iOS 4 as people are now targeting iOS 5, and in another 8 months, I am sure Apple would release iOS 6 (They are very quick with their updates), and I personally feel that targeting iOS 3 is not going to give you great results in the long run.