简体   繁体   中英

Avoid compiling Swift files for a single target

I have a large Xcode project, with a mixed Swift and Objective C codebase. One of my targets is a QuickLook plugin, which does not use any Swift files.

When building the QuickLook target, each Swift file with references to ObjC classes (correctly bridged in the main target) report "Cannot find type in scope" errors — even though none of those Swift classes are included in the given target.

I've tried changing SWIFT_COMPILATION_MODE to singlefile for both release and debug, but it didn't help. To be absolutely sure that no Objective C classes import any Swift files in this target, I've also set up a preprocessor macro to guard the inclusion of Project-Swift.h files. I can't find a flag to completely skip Swift compilation phase when building.

Are Swift they automatically compiled no matter what I do and regardless of their target membership?

For anyone else struggling with this in the future:

When QuickLook extensions are compiled, even for the simulator, it tries to compile any other targets that might include it. I had an old build target, which was no longer maintained. At some point, the bridging header of that target had fallen behind the actual project, and for some reason, Xcode threw an error for every Swift class.

Go through all any targets that include your extension, even tests, and make sure those compile correctly, or remove those altogether.

The errors were not associated with that particular target in the logs or in the UI, which is probably an Xcode bug.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM