# Fixing autocompletion on mixed Objective-C and Swift projects

DevFeed: [Fixing autocompletion on mixed Objective-C and Swift projects](<https://devfeed.tech/articles/fixing-autocompletion-on-mixed-objective-c-and-swift-projects-21621.md>)

Original publisher: [Read original article](<http://miqu.me/blog/2017/06/16/fixing-autocompletion-on-mixed-objective-c-and-swift-projects/>)

Author: Miguel Angel Quiñones

Published: 2017-06-16T22:55:27Z

Content type: tutorial

Language: en

Sources: [Miguel Quinones](<https://devfeed.tech/sources/miguel-quinones.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [code-completion](<https://devfeed.tech/topics/code-completion.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [code-completion](<https://devfeed.tech/tags/code-completion.md>), [debug](<https://devfeed.tech/tags/debug.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [latest-release](<https://devfeed.tech/tags/latest-release.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>), [swift](<https://devfeed.tech/tags/swift.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

## AI overview

This article explains intermittent Swift code-completion failures in mixed Objective-C and Swift projects using Xcode 8 or Xcode 9 beta. It attributes the problem to library classes imported without their framework or library path, which can prevent SourceKit from indexing correctly. The article recommends including the path in bridging-header imports and describes using Xcode's debug mode and SourceKit service logs to investigate the issue. An update says the problem appeared to be fixed in Xcode 9.0.1.

## Source excerpt

This year I had the privilege of attending WWDC for the first time. I knew the labs were very important, and I want to share a resolution to fix a problem for our big project at Peak: Autocompletion on Swift code was not working most of the time in the IDE, and with the help of an Apple engineer in the labs we got it sorted. Update on 30/10/2017: The issues described here seem to be fixed with latest release version of Xcode 9.0.1 (9A1004). Also the 'internal' menu doesn't seem to be accessible anymore. If you know how to access it I'd love to hear from you! The issue If you are using Xcode 8 or Xcode 9 (beta 1 as of this writing), when you have a project with mixed Objective-C and Swift, you might encounters problems with autocompletion inside the Swift code. We've had this intermitently and most recent IDE versions made work very difficult as we would not have any autocompletion for our Swift code, or it would work intermitently. Our gut feeling was that the bridging header had some classes that were causing SourceKit to fail, but we didn't know how to debug the issue nor provide good feedback for Apple to fix it. Our chance came while visiting the labs at the conference, and a very helpful and patient Apple engineer worked with our project to understand what was wrong. Bridging header imports It turns out that if you import classes from libraries (in our case using CocoaPods) omitting the path may result in Sourcekit unable to index properly. For example, a class in some library: #import "MyClass.h" Code will compile fine but your code completion in Swift side might break because the indexer fails when encountering this file. I'm still unsure if it's because of importing the file somewhere else differently or if it's just a bug in the indexer. Anyway, the way to work around it (Apple is supposedly aware of this) is to import with the framework or library style, including the path: #import "path-to-library/MyClass.h" How to debug The engineer kindly made a wrote u