Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARC don't work on iOS 4 #70

Closed
Piero87 opened this issue May 8, 2012 · 25 comments
Closed

ARC don't work on iOS 4 #70

Piero87 opened this issue May 8, 2012 · 25 comments

Comments

@Piero87
Copy link

Piero87 commented May 8, 2012

I have a question about it, i doing an app that is compatible for ios 4 and ios 5, and i see you have used ARC, but on ios 4 it's not compatible, and give me some warning, and then crashing using it on ios 4:

-No 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed
-Default property attribute 'assign' not appropriate for non-gc object
-Method possibly missing a [super dealloc] call

how i can do to solve it, to use on ios 4 and ios 5?

Thanks!

@shrtlist
Copy link

shrtlist commented May 8, 2012

Did you remove the -fno-objc-arc compiler flag in your target build phase settings for SVProgressHUD.m?

@Piero87
Copy link
Author

Piero87 commented May 8, 2012

No...how i can do it?

@shrtlist
Copy link

shrtlist commented May 8, 2012

In your project settings, select your target. Then select the Build Phases tab. Expand the Compile Sources section. Double-click on SVProgressHUD.m. Remove the -fno-objc-arc compiler flag.

@Piero87
Copy link
Author

Piero87 commented May 8, 2012

and then it's compatible with ios 4 and ios 5?...or i have to write release and dealloc in SVProgressHUD.m?

@Hackmodford
Copy link

If you have the -fno-objc-arc compiler flag set for SVProressHUD.m it means that it will treat that file as if there was no ARC. So when you remove it the compiler should be able to build the file without any errors/warnings. ARC is compatible with 4 I thought. Here's a stack overflow topic on compatibility http://stackoverflow.com/questions/7747783/is-arc-really-supported-in-ios-4-the-ios-4-2-sdk-is-missing-arc-related-symbols

@Piero87
Copy link
Author

Piero87 commented May 8, 2012

if i double-click on SVProgressHUD.m, there is no -fno-objc-arc flag...is empty, how i can do?

@Hackmodford
Copy link

You might need to set your deployment target to iOS 4.3 instead of 4.0 and use the iOS 5 SDK
The -fno-objc-arc flag is used to exclude a file from using ARC

According to the stack overflow post:

ARC is supported on iOS 4.0 and above. You need to use the iOS 5.x SDK but can select iOS 4.3 for the Deployment Target. The one thing that is not supported in 4.x is automatic weak reference zeroing.

@Piero87
Copy link
Author

Piero87 commented May 8, 2012

ok, so i have for deployment target iOS 4.2, and i use iOS SDK 5.1, it's the same?...so now i have to add the -fno-objc-arc flag for the SVProgressHUD.m?

@Piero87
Copy link
Author

Piero87 commented May 8, 2012

i have tried in ios5 and give me the same EXC_BAD_ACCESS on this line:

[fadeOutTimer invalidate], fadeOutTimer = nil;

so i think the problem, over the three warning about ARC, is another, i use the SVProgressHUD in this way, i have the FirstViewController class, inside a UIPageController so there is a lot of FirstViewController class, and in this firstviewcontroller i use the SVProgressHUD, i press a button, and i see the SVProgressHUD and then dismiss when do his job, then i scroll to pass to another Firstviewcontroller class, and when i press the button to display the SVProgressHUD give me that EXC_BAD_ACCESS on that line above...what i wrong?

@samvermette
Copy link
Contributor

@Piero87 before I investigate this issue any further, are you sure you're using the latest version of SVProgressHUD?

@Piero87
Copy link
Author

Piero87 commented May 8, 2012

yes i use it, i hope you can solve this problem because it's a great project! thanks for all your work...

@samvermette
Copy link
Contributor

@Piero87 to make sure I understand this correctly: you have a UIPageViewController instance with a bunch of FirstViewController (which I'm assuming are UIViewController instances). You switch between them using a swipe gesture. When you show the HUD in one VC and then have it dismissed, showing it again in the next VC makes it crash?

@samvermette
Copy link
Contributor

@Piero87 I also don't understand why you keep getting those ARC warnings. Does your project uses ARC? If not, did you try using the version on the last-mrc branch?

The EXC_BAD_ACCESS exception usually happens when you try accessing an object that has been released. But ARC automatically takes care of releasing objects and "nilifying" them. I'm think your crash has to do with a misconfiguration in your project settings...

@Piero87
Copy link
Author

Piero87 commented May 9, 2012

@samvermette the answer to your first comment is right, you have understood my implementation, for your second comment i have download the last-mrc branch, and i have tried it, and now i have no warning, and the SVProgressHUD works perfectly :)...can i ask you why? what is the difference between the last-mrc and the last?

@samvermette
Copy link
Contributor

@Piero87 well you can use a non-ARC class inside an ARC project by setting the -fno-objc-arc compiler flag, but not the other way around. I don't think you can use an ARC class inside a non-ARC project.

Bottom line is: you should consider migrating your code to ARC :)

@Piero87
Copy link
Author

Piero87 commented May 10, 2012

@samvermette thanks for the answer, so i can use with no problem the version of SVProgressHUD i'm using now?

@samvermette
Copy link
Contributor

@Piero87 yep, except that version is no longer supported and won't be receiving updates.

@Piero87
Copy link
Author

Piero87 commented May 11, 2012

@samvermette ok, so what you suggest to do?..given that the new version don't work for me...

@samvermette
Copy link
Contributor

@Piero87 Like I said, I think you should convert your project to ARC :)

@jwilling
Copy link
Contributor

Switching to ARC should be a no-brainer for all projects. If you need weak references, and you must keep supporting iOS 4, try using PLWeakCompatibility to enable this functionality without sacrificing compatibility.

@lbsnrs
Copy link

lbsnrs commented May 22, 2012

I have hit the same issue in a project that we currently cannot migrate to ARC. Using the the latest code available in master caused EXC_BAD_ACCESS in [fadeOutTimer invalidate].

The solution, in case anyone else hits it and ends up here, is to set -fobjc-arc for SVProgressHUD.m under Project, Targets, Build Phases.

@samvermette
Copy link
Contributor

@andrelieb hah, had no idea you could set a compiler flag that enables ARC for specific files. That's very good to know, will add it to the Read me.

@Piero87
Copy link
Author

Piero87 commented May 23, 2012

yes thanks, i have tried it but when the view disappear give me an error, so i have to but also this: -fobjc-arc in targets build setting, and Other Linker Flags, and now work fine...

@samvermette
Copy link
Contributor

@Piero87 yep, like @andrelieb said that seems to be the right fix for this bug. Will add it to the read me. Sorry it took so long to find the proper fix!

@Piero87
Copy link
Author

Piero87 commented May 23, 2012

no problem! but @andrelieb said only for the SVProgressHUD.m, but only there the problem is not fixed, so i add also this -fobjc-arc in targets build setting, and Other Linker Flags, and now work fine...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants