Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift code completion not working with Cocoapods

I have an demo app that uses various internal development pods written in swift. All of the swift code in the development pods has trouble code completing. For example, when holding command and clicking on import UIKit, Xcode complains of a Symbol Not Found when tapping on UIKit. There's no compiler errors, everything builds and runs just fine.

If I have swift code outside of the pod in the demo project itself, that code completes just fine, but when I put it in a pod and run pod install, it either stops code completing immediately, or works for a few hours / pod update commands, and then randomly stops working. I have other development pods in my project, and those written in Objective-C have no trouble code completing ever.

I have tried multiple different solutions, namely the solutions listed here: Xcode 6 Swift code completion not working. None of these worked for me.

I tried various combinations of these solutions from the post above multiple times:

  • deleting Xcode's derived data
  • selecting a different simulator device to force a re-index
  • deleting Cocoapod's cache (both in the library and the Podfile.lock and Pods directory)
  • running pod deintegrate and then pod install
  • restarting Xcode and computer
  • using different versions of Xcode (6.3.2, 6.4, 7.0-beta2)
  • on a completely different machine

None of which seem to work.

Any help would be greatly appreciated!

like image 818
ranunez Avatar asked Jan 08 '23 01:01

ranunez


2 Answers

This was also driving me crazy for a few hours, everything seemed fine, but the auto complete wasn't just working.

In my case I was using RestKit 0.25 with CocoaPods 0.39.0 on Xcode 7.2.1 (Since im still on Yosemite)

Since everything was compiling fine, I tried to find where the autocomplete feature kicks in, and I realised that there was something weird at the Project Build Settings level.

Of course it will compile and build fine if the Build Settings of your Target are correct, but what about the project one?

Just select YourProject->(PROJECT)YourProject->Build Settings-> Header Search Paths, and removed everything but "$(inherited)" non-recursive. Finally clean your project and autocomplete will be working again.

like image 51
WilliamX Avatar answered Jan 18 '23 02:01

WilliamX


For me adding anything to the Build Settings didn't work, but deleting Derived Data and building the Pod scheme explicitely did the trick.

Go to "Manage Schemes" and check the Pods-MyProject scheme. Select this scheme (button next to the run and stop button) and Build for Running shift + cmd + R Switch back to your project scheme afterwards.

like image 42
fruechtemuesli Avatar answered Jan 18 '23 02:01

fruechtemuesli