How to convert a non-ARC project into an arc project

Source: Internet
Author: User
Tags naming convention

How to convert a non-ARC project into an arc project

Xcode has an automatic conversion function, but only suitable for smaller projects, not suitable for large projects, so large projects require full manual conversion.

1. Change the project compilation environment to ARC

Change the red circle from No to Yes

If your current project does not support arc technology, you can convert your project (tools in Edit>refactor>convertto Objective-carc) through an automated conversion tool. This tool automatically converts all points in the project that manually manage the memory into the appropriate automatic mode (such as removing retain, release, etc.). This tool will convert all the files in the project. Of course you can convert a single file.

2. These functions: Dealloc,retain,release,retaincount,autorelease. Prohibit any form of invocation and implementation (Dealloc may be implemented)

Erase or annotate all of these memory-managed items

3. NSAutoreleasePool cannot be used. You can consider direct annotations

Instead, @autoreleasepool is introduced and you can use this more efficient keyword.

4. In doing bridge conversion times wrong, with Xcode prompts to replace

Some rules of the 5.ARC syntax

5.1. Cannot use retain, release, retain, autorelease in code

5.2. Do not overload dealloc (if you are releasing processing other than the object's memory, you can overload the function, but you cannot call [Super Dealloc])

5.3. Cannot use Nsallocateobject, Nsdeallocateobject

5.4. Cannot use object pointer in C structure body

Between and void * If cast requires a specific method (__bridge keyword)

5.6. Cannot use NSAutoreleasePool, but need @autoreleasepool block

5.7. Attribute names that cannot be started with "new" (if used there will be the following compilation error "property" synthesized getter Followscocoa naming convention for returning ' owned ' Objects ")

7. Third-party package issues, third-party framework issues

Many third-party frameworks may be referenced in our project.

Most of them use macros to allow the code to adapt to both arc and non-arc (#if __has_feature (OBJC_ARC). If you have a small amount of code, consider rewriting it yourself.

You can use the above steps to manually change the third party frame to arc.

If it is a large frame, you can take this frame to keep the non-arc environment unchanged and continue to use it.

1, select the targets in the project, select the target you want to manipulate,

2, select Build phases, in which Complie sources choose the file you want ARC to double-click and enter in the input box:-FOBJC-ARC, if not arc, enter:-fno-objc-arc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.