0

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?

jowie
  • 8,028
  • 8
  • 55
  • 94
  • OCUnit works with ARC. I would first check the architecture - the newest Objective-C features are only supported on 64bit OSX architecture for example. – Fruity Geek Jan 22 '13 at 18:10
  • Sorry, forgot to mention this is an iOS project. Architectures are standard (armv7, armv7s). – jowie Jan 22 '13 at 20:09
  • 2
    Check your compiler settings for OCUnit target. Looks like you have LLVM-GCC there or something instead of the Apple LLVM Compiler. – hoha Jan 22 '13 at 20:13
  • Ahhh you got it! The main target was set to Apple LLVM, but the main project compiler was set to LLVM-GCC. This wasn't a problem before because the target overrode it, but I guess OCUnit inherits from the project settings. Thanks! Please feel free to add it as an answer so I can tick it and give you points :) – jowie Jan 22 '13 at 20:21

1 Answers1

3

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".

hoha
  • 4,418
  • 17
  • 15