0

I'm trying to add prefix file to my Swift project, that use CoreData. My steps:

  1. Create MySwiftProject-Prefix.pch;
  2. Add header to my .pch file (#import <CoreData/CoreData.h>);
  3. In Build Settings of my Target set Precompile Prefix Header to Yes and Prefix Header to MySwiftProject/MySwiftProject-Prefix.pch;
  4. Clean and build project.

And now i get some errors like you need import CoreData. But why? Where did i wrong?
Thanks.

pacification
  • 5,838
  • 4
  • 29
  • 51

1 Answers1

3

If this is a Swift project, it doesn't use a .pch file. That's for Objective-C. Simply put import CoreData at the top of your Swift file(s).

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Ok. But what if i want to import objective-c lib. Maybe `MagicalRecord`. I should use `.pch` file to import headers. – pacification Sep 02 '15 at 16:39
  • 1
    No, you can use the bridging header to do that. I repeat: Swift knows nothing of `.pch` files. You're barking up the wrong tree. – matt Sep 02 '15 at 17:15
  • oh yes, sure! My fault. I don't know why i use prefix file instead of bridge header. Well, need to sleep. Thank you very much. – pacification Sep 02 '15 at 17:37