Using an ARC static library in a NON-ARC project - ios

I am trying to get this sorted out. I know how to get an ARC project working with files or static lib's that are not using ARC. For instance, using the compiler flags -fno-objc-arc.
But what if I have a project that is not using ARC and want to include a static library compiled with ARC? Every time I want to build the project it is telling me that it doesn't recognize things like "strong, __unsafe_unretained,...".

To add on to shw's answer. Add -fobjc-arc to compiler flags under build phases to ARC files to make them compile correctly for non-ARC projects.
More info here

It should work fine - are you sure you're using the newest Apple compiler with this non-ARC project and not the GCC one?

Related

import non-ARC code compiled .a file in ARC enabled project

There is a SVGKit on github is compiled in non-arc code, and I get its library file, named SVGKit.a and some header files.
However, my app project is developed on iOS 7 and above, so by default it is managed by ARC.
My question is, is it safe to link the non-ARC library .a file into my project and use it like usual? If not, then how can I use it?
is it safe
From an ARC point of view, certainly. ARC operates at compiler level - and your library is already compiled. One way or another, it is already doing whatever memory management it is doing.
Now, there may be other reason why you'd have trouble linking to a library; but that would have nothing to do with ARC.

Errors when adding C libraries to a project with ARC

I am trying to use a set of C libraries to allow custom graphs in my iOS project. My projects uses ARC, however, the custom graph libraries are based on a project that does not use ARC. The errors I am getting are related to ARC.
The documentation for the C libraries specify that when using the library to turn off ARC. However, my project is too evolved to revert to a non ARC project.
How might I still use this library in my project? The library is PowerPlot.
You can turn off ARC for the specific library, by adding the -fno-objc-arc compiler flag.
Go in your Target Settings > Build Phases > Compile Sources, and add the compiler flag to every implementation file from the library.
Further information can be found here: How can I disable ARC for a single file in a project?

How to build static lib without ARC for a project which uses ARC?

How can I build a static lib without ARC for a project which uses ARC?
I found some source for a static lib, I want build it for my project but I use ARC.
The static library can be built without ARC and included in your project with ARC without doing anything special. If you want to add the source directly, you'll need to add the following compilation option to each non-arc file in build phases: -fno-objc-arc.
In general case : You can opt for few files(static lib) not using ARC and your own files using ARC.
But for lib it is not required.
You can merge ARC and Non-ARC files quite simply, however you have compiled lib then it doesn't care.

How to use ARC compatible files in non ARC compatible projects

My project has dependent libraries that don't compile under the LLVM compiler, so my project is not compatible with ARC.
How can I include other third party libraries and source files that are ARC compatible in to my non-ARC project.
Thanks in advance.
You could add a complier flag to each compile source in the Build Phases. The flag you should add is -fobjc-arc
If you're not using LLVM your main project won't be able to use ARC at as it's a LLVM 3.0 feature.
If I was you I'd make your main project/target/app compile under LLVM and include your older external dependencies as static library dependencies. Once the static libraries are compiled the fact that they're ARC or non-ARC doesn't make a difference.
You'll need to move to Xcode workspaces that contain multiple Xcode projects, one for each of your third party libraries and have static library targets for each project. This setup allows independent build settings and greater flexibility. You'll find a lot of people create static libraries for third party things these days.
Checkout a blog post or two on setting up static libraries within an Xcode workspace, it's quite common these days.

WhiteRaccoon iOS 4.2 errors

I have a app with the WhiteRaccoon framework installed.
I cant compile it as it gives me errors with anything to do with retain or release in WhiteRaccoon.m/h.
Any ideas whats going on?
Thanks.
By the way, I have added the CFNetwork framework. Any ideas?
Your project is probably using ARC and WhiteRaccoon probably isn't.
You can either convert whiteRaccoon (whatever that is) to ARC or exclude the whiteRaccoon files by adding the following compiler flags to it's source files -fno-objc-arc.
To do that click the project on the left hand side then go to the "Build Phases"-> "Compile Sources" look for the white Raccoon .m files and add the -fno-objc-arc under the compiler flags section.
Another option would be to compile the WhiteRaccoon framework into a static library and as this to your project.

Resources