I have a problem
@import Foundation;
and I see:
@import vs #import - iOS 7
and I set "Enable Modules" to "YES"
and my problem is not solved
I have a problem
@import Foundation;
and I see:
@import vs #import - iOS 7
and I set "Enable Modules" to "YES"
and my problem is not solved
I got this warning in a zero-swift project whenever I tried to add the @import SafariServices;
statement.
Solution: Enable the modules. Go to the Target > Build Settings and set the Enable Modules (C and Objective-C modules) to YES.
OR
Note: I haven't verified this potential solution, but probably worthy of consideration if there are side effects caused by this solution.
Rather than enabling modules to entire project, we can enable modules for a specific file which is importing c++ file. Go to build phases -> Compile Sources -> Select the file -> Add compiler flag
-fmodules
I've been mixing ObjC, ObjC++, C++, and Metal. Whenever I get the "use of @import when modules are disabled" I try replacing:
@import Name;
with:
#import "Name/Name.h"
example, replace:
@import Metal;
@import MetalKit;
@import CoreVideo;
with:
#import "Metal/Metal.h"
#import "MetalKit/MetalKit.h"
#import "CoreVideo/CoreVideo.h"
It seems to work.
@import
is not supported yet for.mm
files or ratherObjective-C++
(I tested with bothg++
andclang++
as I really wanted to make this work). – Top-Master