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
Related
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).
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.
I am writing an iPhone app in which I want to support the largest user base possible at this point in time (with minimal pain), so I decided that targeting IOS 4.3+ would be a good subset of users for my audience.
I started working in XCode 4.2, but reverted back to XCode 4.1 when I realized that the project templates had changed and everything seemed very intertwined with storyboarding, ARC, etc.
I have built out my application to the point I actually want to test on my device, which has iOS5 installed. When I attempt to use it though, I get this message as soon as I click 'use for development' in Organizer/XCode:
The project's build settings look like this:
My Question Is This: How do I get this application, built in XCode 4.1, to run on both iOS 4.3 and iOS 5 phones?
Are iOS SDKs not backward compatible? I come from Android development in which a less than current SDK will generally work on a newer SDK - is this different in the iOS world? And if so, how is this handled typically?
Any direction on how I should proceed would be greatly appreciated.
You can go ahead and open your app in Xcode 4.2 and it should still work. I've been working on a particular app since Xcode 3.x days and I'm nearly done, chugging along in Xcode 4.2 right now. It shouldn't be a problem. If you want to work with Xcode 4.1 you will be fine, but you won't be ale to use new features introduced in iOS 5.
There are several aspects of "cross-version" development to note.
Testing: You can only test on version of iOS that are included with your SDK, or that are installed on physical devices that you may have. The SDK generally comes only with the latest iOS, sometimes the previous one is included as well, but since Xcode 4 was released, the older SDKs have been progressively deprecated with each release. This is not to say that your app which is linked against the iOS 5 SDK won't run on older versions of iOS. It just depends on how you implement new features.
Features: In order to support older versions of iOS properly, you want to make sure that you don't implement new features without properly checking for the existence of classes, methods, and properties that were introduced in the newer versions of the OS. Unlike Android, you don't have to worry about a million hardware configurations. ;-)
Weak Linking: To support a new feature and still be compatible with older versions of iOS, you need to weak link against frameworks that you are using to implement new features. You can read more about that in the Apple Documentation on Weak Linking.
Deployment Target: The setting that prevents the app from loading on older devices is called the "Deployment Target". If you set this to 3.1.3, then your app will run on iOS 3.1.3 and higher. Remember that if you don't code the the proper version checking, your app may break.
ARC: You can choose to enable or disable Automatic Reference Counting when you create the project. ARC scans your program at compile time only, not at runtime, it doesn't break the app on older versions of the OS.
You need the latest version of XCode and the iOS SDK to install your apps onto your iOS 5.0 phone. That doesn't mean the inverse is true -- you don't need the same version of iOS on your device that you have installed on your computer.
Hope this helps!
You can use the latest SDK and simply set the "IOS Deployment Target" version to 4.3 in the project build settings.
XCode 4.1 doesn't support iOS5 in the sense that Xcode package doesn't contain the iOS5 SDK. So you must return to Xcode 4.2 and target your project for iOS 4.3 (you can also target it for iOS 4.0 with this Xcode version, but you will not be able to simulate it; you can even download older iOS 4.x package versions from the Xcode preferences menu if you really need to simulate them in your device).
You can opt-out of ARC if you want, this choice is given to you when you create the project, so don't worry; but consider that ARC does its magic at compile time only, not at runtime, so your backward compatibility will be kept if you decide to use this technology. Finally if you don't want Storyboard just pick the Empty app template and it will simply put in your project only the basic files. From this template you can create any iOS app, this is the approach I normally follow.
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.
I wrote a code on IOS SDK 4.0 and tried running on a device which contains IOS 4.2. I am seeing a empty navigation view. What changes in my code I should do to run it on the target version of SDK.
It's very hard to say without having more information on the project and what technologies within iOS it makes use of. Is there anything in the release notes that sheds light on your problem:
http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-4_2/
Might be worth checking 4.1 ones as well:
http://developer.apple.com/library/ios/#releasenotes/General/RN-iPhoneSDK-4_1/