0

I was trying to use @import feature of XCode 5. I have replaced all #imports with @import for all iOS frameworks. Also, in Project settings I have enabled “Enable Modules (C and Objective C).

But then when I remove UIKit framework from my project, I start getting compilation errors.

Am I missing anything here?

Abhinav
  • 36,284
  • 39
  • 178
  • 301
  • 1
    What are the errors? Linker errors, etc? – JRG-Developer Feb 18 '14 at 21:52
  • BTW, you don't need to explicitly replace `#import` all over the replace... Xcode will take care of it for you if you set `enable modules` to `YES` on your project target. – JRG-Developer Feb 18 '14 at 21:53
  • 2
    Do you also have `Link Frameworks Automatically` set to `YES` on your project target's build settings? – JRG-Developer Feb 18 '14 at 21:54
  • Yes I am getting the link errors and have already tried the link shared by JRG-Developer. I tried putting @import and even with that I am getting compilation errors. Checked "Enable Modules (C and Objective-C)" and "Link Frameworks Automatically" and they are set properly. Also, I am doing this on an already existing project. – Abhinav Feb 18 '14 at 22:10

1 Answers1

0

Where did you add @import UIKit and @import Foundation?

I ran a quick test. I removed UIKit and Foundation from the "Link Binary with Libraries" pane, and @import'd in my app-Prefix.pch precompiled header file. It worked like a charm. Try the @import statements there, for any of your "global" libraries.

Other than that, I do have "Enable Modules (C and Objective-C)" and "Link Frameworks Automatically" turned on, but that was out of the box, as far as I can tell.

greymouser
  • 2,774
  • 18
  • 22
  • I tried putting @import and even with that I am getting compilation errors. Checked "Enable Modules (C and Objective-C)" and "Link Frameworks Automatically" and they are set properly. Also, I am doing this on an already existing project. – Abhinav Feb 18 '14 at 22:08
  • @Abhinav where are you putting the `@import` statements? Specifically, what file? – greymouser Feb 18 '14 at 22:14
  • I am putting it inside MyProject_Prefix.pch file. – Abhinav Feb 18 '14 at 22:33
  • This cannot work in the pch file... this is not a precompiler directive. – jimpic Feb 25 '14 at 13:41