__Bridge throws are unaffected unless ARC is used

When compiling an older project in Xcode 4.5, a warning appears:

Drives

'__ bridge' does not work unless ARC is used

How can I get rid of this warning so that the code works well both in ARC and in projects other than ARC?

+4
source share
3 answers

Any single source file must be compiled using ARC or not compiled with ARC. You just have to decide what it is and always use this method for a specific source file. If you adhere to memory management naming conventions, you can mix the ARC and non-ARC source files in one project.

The reason why I say above is that if you have code that was written for ARC and you compile it without ARC, there will be memory leaks and premature releases from unauthorized access in place due to the fact that all saved , issues and auto implementations.

+5
source

With multiple #define it is entirely possible to write source files that compile correctly for multiple MRC, ARC, and GC.

Xcode does not allow you to include both ARC and GC, knowing that we can write:

 #if defined(__OBJC_GC__) # define USING_GC 1 #else # define USING_GC 0 #endif #if __has_feature(objc_arc) # define USING_ARC 1 #else # define USING_ARC 0 #endif #if USING_ARC || USING_GC # define USING_MRC 0 #else # define USING_MRC 1 #endif 

which will only define one of USING_GC , USING_MRC and USING_ARC as 1 , and the other two as 0 . You can put this in the project prefix header (.pch).

You can use these definitions directly in your code to include / exclude things like bridges; or it is better to define macros for memory calls, castings, etc. that expand to the appropriate code based on the memory model used.

NTN

0
source

Just enable ARC for this file:

 -fobjc-arc 

(Go to "Phase Assembly"> "Compile Sources"> "Compilers")

0
source

Source: https://habr.com/ru/post/1435239/


All Articles