Xcode 6 Swift code completion not working
Objective CXcodeSwiftObjective C Problem Overview
Using Xcode 6 GM seed my code completion has stopped working. It was working the other day. I was trying to get the unwind segue work around to work. I had made an Objc header file and assigned it as a header for a Swift class.
At this point I get code completion with an Objective-c project. But, not with a Swift project.
I have tried restarting Xcode, making a new empty project.
Objective C Solutions
Solution 1 - Objective C
Just go in user->Library->Developer->Xcode->DerivedData
and delete the Data of folder(Derived data) and restart Xcode.
Solution 2 - Objective C
This fix from apple dev forums works for me. I have had autocomplete issues with Xcode 6.1/Yosemite.
- Quit Xcode.
- Restart the computer (this is to clear any in-memory caches).
- Delete the contents of the DerivedData folder (~/Library/Developer/Xcode/DerivedData), precisely run, **a) cd ~/Library/Developer/Xcode/DerivedData/
b) rm -rf ***
- (Try this if Steps 1-3 dont really work as it rebuilds the cache later on restart which takes time) Delete the contents of folder ~/Library/Caches/com.apple.dt.Xcode, i.e.,
**a) cd ~/Library/Caches/com.apple.dt.Xcode
b) rm -rf ***
Now launch Xcode once more…
Solution 3 - Objective C
I experienced a serious breakdown of code completion because I had some 'notes' after the @end statement of my .m file which were as follows:
/*
NSAlertFirstButtonReturn, NSAlertSecondButtonReturn, NSAlertThirdButtonReturn
*/
These lines can appear before the @end statement without destroying code completion.
Solution 4 - Objective C
There's an easier way to delete the Derived Data from within Xcode (no need to open finder or restart):
Xcode Organizer -> Projects -> (Your Project) -> Delete Derived Data
Solution 5 - Objective C
I just recently had this problem. Autocomplete did not work ...and when i typed for example tableView.... it did not give me the different functions available.
I tried the following and it worked for me.
-
Xcode Organizer -> Projects -> (Your Project) -> Delete Derived Data
-
delete the file ~/Library/Developer/Xcode/DerivedData/ModuleCache
-
Restart xcode
Hope this works
Solution 6 - Objective C
Another possible reason why it isn't working is because it's not part of the target membership. To fix this, select the file you're working on. Then, go to the File Inspector and in the Target Membership section, make sure your project is checked.
Solution 7 - Objective C
Try the following - as silly as it may sound: Change Device to iPhone 6, close Xcode, Reopen Xcode and wait for the indexing to finish.
Solution 8 - Objective C
Go to Xcode menu, then Window -> Organizer, then select Projects. Pick your project and press on delete button beside dervied data Then restart Xcode
That solution worked with me on Xcode 6.1
Solution 9 - Objective C
If your code completion problem is only with UI classes (e.g. UIImage, UIDevice), then you just need to add "import UIKit".
Swift files will NOT have code completion for UI classes unless there is an "import UIKit".
Solution 10 - Objective C
I had the same issue but under different circumstances, I have 2 projects in my workspace
- Swift framework for iOS and OSX
- iOS Project (which uses the swift framework)
My code completion works fine in iOS but it keeps failing in the swift framework. I tried all the about solution and had no luck and was killing my productivity.
Finally i figured out the solution to this problem.
> 1. Select the file you are editing (in the framework ) > 2. Select the 'utilities' tab on the right > 3. uncheck the Mac target (just keep the target you are working for > currently)
Thats it, this solved my problem. hope it helps someone who is in this kinda situation.
Solution 11 - Objective C
user/Library/Developer/Xcode/DerivedData Delete all the files shown in this folder. after that go to your project name and clean project then come back to the file where you wanna see suggestions. Type any word and its done.
Solution 12 - Objective C
So all you have to do is make sure, in the file inspector view on the right side, under Target Membership, the first box is checked. I'm not sure why this changes things but I'm sure someone can come along and give a more complete answer.
Solution 13 - Objective C
In my case Some File(s) were deleted in File System but were still referenced in the Project i.e. in Red Color. Just delete those from Project and everything was fine. Code Completion started working.
Also Like to point that all the above answers about Clearing/Deleting Derived Data folder seems to work momentarily but whenever there was a new pull or update the problem started again, so the root cause was the unreferenced/moved/deleted files which show up as RED in the project, they needs to be manually cleared.