Search code examples
iosobjective-cxcodeautomatic-ref-countingocunit

Issue implementing OCUnit in existing ARC project


I'm looking into adding unit tests into my existing app, mainly to teach myself how it all works. I've got to the stage where everything is wired up with dependencies, I can run some little checks like:

STAssertEquals(1, 2, @"This is a fail!");

And the result seems to be coming through correctly. Unfortunately, if I import any of my scripts, I get compiler errors on any @property line that uses a keyword such as unsafe_unretained or strong:

Expected a property attribute before 'unsafe_unretained'

I wondered, is this anything to do with ARC? Is OCUnit not ARC-compliant? Do I need to change my compiler settings?


Solution

  • Short story

    OP had a wrong compiler set in target's settings

    A bit longer story (for googlers of the "Expected a property attribute before ..." error)

    The only compiler supporting ARC today is Apple LLVM compiler. I believe Apple treats LLVM GCC as deprecated and bundles it with Xcode just for compatibility reasons. All new features are and will be added to LLVM compiler.

    Compiler settings can be set at File -> Project Settings..., "Build settings tab". The option's name is "Compiler for C/C++/Objective-C".