What if the project uses ARC but you need non-ARC classes?
Answer
ARC is enabled per file, not per project. For legacy files with manual retain/release add the compiler flag -fno-objc-arc:
- Target → Build Phases → Compile Sources → Compiler Flags column next to the
.mfile →-fno-objc-arc. - The reverse case (a non-ARC project with one ARC file) — the
-fobjc-arcflag. - In SwiftPM for a C/ObjC target:
cSettings: [.unsafeFlags(["-fno-objc-arc"])]— butunsafeFlagsare forbidden for dependencies, so libraries usually just migrate the code.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep