0

While editing a Swift file, I am getting several:

@objc attribute used without importing module 'Foundation'
@objc can only be used with members of classes, @objc protocols, and concrete
extensions of classes 
Use of unresolved identifier 
Use of undeclared type

compiler errors.

For instance,

@objc func returnTrue() -> Bool { return true }

complains @objc attribute used without importing module 'Foundation' even though my pch file contains #import <Foundation/Foundation.h>

I have restarted Xcode/Mac; uninstalled/reinstalled Xcode; deleted derived data; changed/reverted the pch file; checked class target memberships; and cleaned the build folder (several times). I can successfully compile and run the code.

Any thoughts?

Tom Howard
  • 4,672
  • 2
  • 43
  • 48

1 Answers1

0

As a programmer, I am not a fan of magic answers, but the following worked for me (assuming my branch is MyBranch):

  1. Committed and pushed my local MyBranch's working copy changes.
  2. Switched branches. Built. Deleted my local MyBranch.
  3. Checked out the remote MyBranch.

Voila!

Tom Howard
  • 4,672
  • 2
  • 43
  • 48