0

I am new to iphone development. I have learnt that ARC is a new feature introduced in IOS now . My question is, I have an old Non ARC project with the release written manually, is it possible to switch this project from non ARC to ARC ?

Thanks,

Raj

Raj
  • 1,119
  • 1
  • 15
  • 32

1 Answers1

6

Make sure you are using version control, then use:

Edit > Refactor > Convert to Objective-C ARC…

justin
  • 104,054
  • 14
  • 179
  • 226
  • 1
    version control, or a backup. at least (which I think XCode will offer to do automatically here). – Thilo Aug 29 '12 at 06:20
  • Hi Thilo, it worked for the small code sample which i have created my self. My doubt is will it work for the huge projects, where I may be releases written outside the dealloc as well – Raj Aug 29 '12 at 06:39
  • @user1626799 it's *largely* automated. depending on the complexity of your program, some intervention and bug hunting may be required. i suggest that if your project does not have ObjC++, you just go ahead and try it out on the smallest real project, and prepare yourself for some debugging and memory analysis. then you will know the effort involved in migrating your codebase. for a lot of people, the transition is painless, but hunting down memory issues is no fun so -- try it for a few hours (again, use version control). – justin Aug 29 '12 at 06:45
  • @Justin :Thanks for the response. I got one more doubt.Version Control refers to the project targeted version right. What I assume here is my project should be targeting ios 4.0 as ARC is supported 4.0 onwards.Sorry for the lack of knowledge – Raj Aug 29 '12 at 06:54
  • @user1626799 version control is a software you use to track changes to your sources. Xcode supports a few, such as git. it would allow you commit and revert changes to your project's files over the files' life. for some more introduction: http://en.wikipedia.org/wiki/Version_control as Thilo mentioned, you could simply use a "Snapshot" in Xcode; which Xcode would ask you about before performing the transition. Snapshots aren't anywhere near the power/granularity of git (last i checked), but it would be better than no backup in the event something went wrong. good luck – justin Aug 29 '12 at 07:04
  • @user1626799 you're very welcome -- good luck with the migration – justin Aug 29 '12 at 07:45
  • 1
    Bear in mind that you can mix arc files with non arc file by disabling arc in the compiler. If you have problems converting your whole project, try it one file by another and leave the problematic file non-arc. – brainray Aug 29 '12 at 07:47
  • Not sure when that happened, but in current versions of Xcode (10.1) the command is `Edit -> Convert -> To Objective-C ARC` – pckill Feb 22 '19 at 15:38