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?
Related
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.
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.
I'm trying to add the Mixpanel SDK to an iOS app that uses ARC. After adding the SDK I get some compile errors related to ARC usage. How can I integrate Mixpanel into a project that uses ARC?
In my personal projects I always manage mempory manually. Perhaps there's some way to tell the compiler this code uses ARC while this code doesn't.
Click on your project name in the navigator. Choose "Build Phases" from the list header in the right hand window. You should see a bar named "Compile Sources"; expand it and you should see a list of the source files in the project and a column labeled "Compiler Flags". For every file in the Mixpanel SDK, double-click in this column and add the following line:
-fno-objc-arc
This will signal the compiler to not use Automatic Reference Counting when compiling these files. If you ever need to do the reverse (compile ARC code in a non-ARC project) do the same thing but add this line instead:
-fobj-arc
I believe this may be a duplicate of this question.
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.
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?