0

I'm unable to compile the project after adding MagicalRecord, I'm getting this errors:

MagicalRecord.h:14:1: error: function definition is not allowed here
MagicalRecord.h:42:28: error: cannot find interface declaration for 'NSObject', superclass of 'MagicalRecord'
MagicalRecord.h:51:4: error: expected a type
MagicalRecord.h:60:4: error: expected a type
MagicalRecord.h:85:32: error: expected a type
MagicalRecord.h:94:4: error: expected a type
MagicalRecord+Options.h:17:1: error: function definition is not allowed here
MagicalRecord+Options.h:43:1: error: function definition is not allowed here
MagicalRecord+Options.h:77:4: error: expected a type
MagicalRecord+Options.h:86:49: error: expected a type
MagicalRecord+Options.h:95:4: error: expected a type
MagicalRecord+Options.h:104:64: error: expected a type
MagicalRecord+Options.h:114:4: error: expected a type
MagicalRecord+Options.h:124:47: error: expected a type
MagicalRecord+Options.h:137:4: error: expected a type
MagicalRecord+Options.h:146:27: error: expected a type
MagicalRecord+Options.m:11:8: error: unknown type name 'MagicalRecordLoggingLevel'
MagicalRecord+Options.m:11:63: error: use of undeclared identifier 'MagicalRecordLoggingLevelVerbose'; did you mean 'kMagicalRecordLoggingLevel'?
MagicalRecord+Options.m:12:8: error: unknown type name 'BOOL'
fatal error: too many errors emitted, stopping now [-ferror-limit=]

how to make it works under a Swift project? I need a modified version? there's a plan to release a Swift version of MagicalRecord?

Enlil
  • 1,027
  • 14
  • 28

2 Answers2

3
  1. It's better to use Cocoapods for managing third-party libraries, MagicalRecord works perfectly when added to project via cocoapods.
  2. Seems like you forgot to import Foundation headers in the ProjectName-Bridging-Header.h header file.
  3. Make sure ProjectName-Bridging-Header.h selected as 'Objective C Bridging Header' in project build settings
  4. MagicalRecord's main include file is CoreData+MagicalRecord.h, not MagicalRecord.h
vitalyster
  • 4,980
  • 3
  • 19
  • 27
  • `cannot find interface declaration for 'NSObject'` clearly states about missing Foundation headers, added note 3 to my answer. – vitalyster Aug 12 '14 at 18:53
  • 1
    This is my Bridging-Header file: #import #import "CoreData+MagicalRecord.h" – Enlil Aug 12 '14 at 19:21
  • We use `pod 'MagicalRecord/Shorthand', git: 'https://github.com/magicalpanda/MagicalRecord.git', branch: 'develop', commit: '77c186ab7a993d9743a6d2dd8ff78088989f65a2'` at present. –  Jun 21 '15 at 00:03
3

Solved: I followed the errors, and imported the frameworks

looks like a bug in Swift projects

Enlil
  • 1,027
  • 14
  • 28
  • 4
    Hi Marcelo, I have the same issue. How do you solved this? I've put this : #import #import "CoreData+MagicalRecord.h" in my bridging header file but it doesn't work... – dpbataller Sep 18 '14 at 10:26
  • 1
    Hello, MagicalRecord thinks that Foundation framework is imported in the .pch file, but a Swift project doesn't have that file, so I solved by manually adding the framework where required – Enlil Sep 21 '14 at 18:54