I am working on an Xcode project that uses a Calendar framework, here: https://github.com/mmick66/CalendarView.
In the readme is says in order to use the Event system, you need to set custom swift compiler flags in the build settings. For some reason it isn't shown as an option for me.
Here is a screenshot of what I see in my projects build settings.
On the repository is a sample project. When I open that in Xcode, "Swift Compiler - Custom Flags" is one of the sections unlike my project.
Why would this be happening?
Here is a screenshot from the open source example project:
As per Richard Robinson's comment. I was able to find the required settings by restarting Xcode, and in the Build Settings tab, click all (combined is default) then searching for "custom flags". From there I was able to add the required flags for the calendar framework.
Edit 1: I jus thought I should add this clause to this answer. This doesn't technically answer the "why" is this happening, rather just how to fix it.
I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile right now. I recall hearing that there was a way to disable ARC on a per-file basis, though I have been unable to find this option.
Is this possible? How do I disable ARC on a per-file basis?
It is possible to disable ARC for individual files by adding the -fno-objc-arc compiler flag for those files.
You add compiler flags in Targets -> Build Phases -> Compile Sources. You have to double click on the right column of the row under Compiler Flags. You can also add it to multiple files by holding the cmd button to select the files and then pressing enter to bring up the flag edit box. (Note that editing multiple files will overwrite any flags that it may already have.)
I created a sample project that has an example: https://github.com/jaminguy/NoArc
See this answer for more info:
Disable Automatic Reference Counting for Some Files
Disable ARC on MULTIPLE files:
Select desired files at Target/Build Phases/Compile Sources in Xcode
PRESS ENTER
Type -fno-objc-arc
Press Enter or Done
;)
For Xcode 4.3 the easier way might be: Edit/Refactor/Convert to objective-C ARC, then check off the files you don't want to be converted. I find this way the same as using the compiler flag above.
It is very simple way to make individual file non-arc.
Follow below steps :
Disable ARC on individual file:
Select desired files at Target/Build Phases/Compile Sources in Xcode
Select .m file which you want make it NON-ARC
PRESS ENTER
Type -fno-objc-arc
Non ARC file to ARC project flag : -fno-objc-arc
ARC file to non ARC project flag : -fobjc-arc
Note: if you want to disable ARC for many files, you have to:
open "Build phases" -> "Compile sources"
select files with "left_mouse" + "cmd" (for separated files) or + "shift"
(for grouped files - select first and last)
press "enter"
paste -fno-objc-arc
press "enter" again
profit!
Just use the -fno-objc-arc flag in Build Phases>Compile Sources
Select Xcode project
Go to targets
Select the Build phases section
Inside the build phases section select the compile sources.
Select the file which you do not want to disable ARC and add -fno-objc-arc
It is possible to disable ARC (Automatic Reference Counting) for particular file in Xcode.
Select Target -> Build Phases -> Compile Sources -> Select File (double click) -> Add "-fno-objc-arc" to pop-up window.
I had encountered this situation in using "Reachibility" files.
This is shown in below figure :
use -fno-objc-arc for each file in build phases
The four Mandatory Step as explained in this video
//1. Select desired files
//2. Target/Build Phases/Compile Sources
//3. Type -fno-objc-arc
//4. Done
Please Just follow the screenshot and enter -fno-objc-arc .
If you're using Unity, you don't need to change this in Xcode, you can apply a compile flag in the metadata for the specific file(s), right inside Unity. Just select them in the Project panel, and apply from the Inspector panel. This is essential if you plan on using Cloud Build.
I think all the other answers are explaining how to disable MRC(Manual Reference Count) and enabling ARC(Automatic Reference Count).
To Use MRC(Manual Reference Count) i.e. Disabling ARC(Automatic Reference Count) on MULTIPLE files:
Select desired files at Target/Build Phases/Compile Sources in Xcode
PRESS ENTER
Type -fobjc-arc
Press Enter or Done
Add flag “-fno-objc-arc”.
Simple follow steps :
App>Targets>Build Phases>Compile Sources> add flag after class “-fno-objc-arc”
Just use the -fno-objc-arc flag in Build Phases>Compile Sources infront of files to whom you dont want ARC to be apply.
GO to App -> then Targets -> Build Phases -> Compile Source
Now, Select the file in which you want to disable ARC
paste this snippet "-fno-objc-arc" After pasting press ENTER
in each file where you want to disable ARC.
select project -> targets -> build phases -> compiler sources
select file -> compiler flags
add -fno-objc-arc
Following Step to to enable disable ARC
Select Xcode project
Go to targets
Select the Build phases section
Inside the build phases section select the compile sources.
Select the file which you do not want to disable ARC and add -fno-objc-arc
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.
Is there an iOS 5 arc compatible lazy Image loading library? I've not found one.
My next thought is to make EGOlazyloading a compiled library and link it to my project. Would that work? Any pointers on going about?
Thanks!
I wrote one. You can download it here:
https://github.com/nicklockwood/AsyncImageView
Alternatively, if you do want to use EGO, or some other library, select Edit>Refactor>Convert to ARC and in the dialog that comes up there's a little drop down to select which files to convert.
Just tick the files that should be converted to ARC and un-tick ones which shouldn't be. If a file is already using ARC then leave it ticked (it won't double convert it).
That gives you the option of either trying to convert the library files to ARC or to leave them alone. Files that are unticked will be marked with the -fno-objc-arc flag automatically so you won't have to do anything.
Byron, you could just use a regular library like EGOlazyloading you suggested and order the compiler not to use ARC on those specific files by adding the flag -fno-objc-arc in "Build Phases -> Compile Sources"
I have already created a project in XCode 4.2 with ARC checked. The problem is that I have to download and add the ASIHttpRequest files. This is giving a whole bunch of errors when I try to compile. Is there some way to fix this (other than to create a project again) ?
Click on the name of the project on the navigation view in the left side, go to Targets -> Build Phases and add -fno-objc-arc to the "compiler flags" for any relevant files.
You can turn off ARC per-file by passing the flag -fno-objc-arc to each as they are compiled. Add the flag to the files that need ARC disabled in the Compile Sources group under the target in the project navigator.
Another option would be to compile ASIHttpRequest as its own framework that doesn't have ARC enabled and just link against the framework. Speak of, isn't ASIHttpRequest already in a framework? (I've not looked at it in a while)
Keep using ARC, but disable it for the ASIHttpRequest files. This answer should point you in the right direction:
How can I disable ARC for a single file in a project?