KAREEM MAHAMMED
KAREEM MAHAMMED

Reputation: 1695

Issue By Adding NON ARC Files to ARC iPhone Application?

I added add .h and .m files from an non ARC application to ARC iphone Application. I set -fno-objc-arc as compilerflag in build phases to these files. But when I try running this application after adding these files I am facing a problem. Application does not give any error is just shows failed once and stops the process of building.

I am confused and trying to understand what is the problem in this. After I delete these non ARC files, it is running normally.

Upvotes: 0

Views: 436

Answers (2)

David Hoerl
David Hoerl

Reputation: 41652

First, you add the .h file but don't set any compile flag on it - your comment on this is a bit confusing - in fact your question and comments are confusing. So lets try to sort this out:

  • you added both the .m and the .h to your project - you can see them in the left pane
  • the .m file was added to the build phase of the desired target with a compile flag of -fno-objc-arc

Now it gets tricky, as your question is self contradictory:

1) you tried to build and the build failed. So then edit your post and provide the error messages.

2) the build succeeded, you ran the project, but it failed somehow. Problem is you don't tell us how it failed.

So, in addition to clarify your question, please note that if you add a non-ARC file to your project, that file must conform to certain conventions, which you can read about in the ARC docs (two very short articles, one from Apple, one from llvm). For instance, if you have a method in that file that starts with "init" or "create" then whatever object it returns must be retained not autoreleased.

I personally have used non-ARC files with an ARC project for a year now with no problems.

Upvotes: 1

Senthilkumar
Senthilkumar

Reputation: 2481

Just do the following thing:

  1. Reset your simulator.

    2 . Clear your Build

in your non arc file content remove the release,retain,autoreleasepool and auto release.

After build and run. hope it will work.

Upvotes: 0

Related Questions