Xcode completions, spelling checkings stopped - xcode

My Xcode 4.3.2 stopped to show up spelling errors and completions for code. The only way to find out if there is any error in the code - build it. Xcode colores only keywords such as if, else, for etc. All other code hasn't colored. Shown only a few very strange completions. For example:
CGPoint p;
p.y // completion is "YES"
p.x // completion is "xor"
Completions for methods calls are only nearaly used methods. How can I fix this? I rebooted my mac several times already, and didn't find any stuff about this in Xcode's preferences.

I also had this a lot of times, what helped for me was to set in the build settings precompile prefix header to NO

What I do to solve this issue is:
1.) Change build settings from LLVM 3.1 to GCC 4.2
2.) Go to Organizer>Projects>(Select Project)> Delete Derived Data
3.) Change Builds Settings back to LLVM 3.1
My syntax highlighting then works again. No need to restart Xcode, and jump through other hoops and hurdles.
Hope this helps you as it does for me !
UPDATE: Some people can get it working with only Step 2, if that doesn't work. Follow all 3 steps.

Related

Xcode 12.0 not showing variable when debugging

I have projects that I have created with earlier releases of Xcode. I was forced to upgrade to Xcode 12.0.
When I run my old projects, not tried all of them, I am not getting any variable declared outside of the current routine, the variables within the current routine do not show any value. I have created a new project and the same thing applies. I have checked old reports and all my optimization settings are none, and I have debug for my Build configuration along with many of the other suggestions on earlier versions of Xcode with the same problem. So there's probably something very simple that I need to do but I can't find it. Hope somebody has the solution.
for me what did the change is removing facebookSDK from swift packages and return to use pods.
Did you try going to warnings and pressing update to recommended settings?
Edit: The warnings are found in the tab that looks like an exclamation mark.
Open Menu
Product -> Scheme -> Edit Scheme -> Test
Tab [Info -> LLDB Init File]
Paste the following link
$(SRCROOT)/.lldbinit
I had the same problem, using Xcode 12.5.1, and eventually solved it by changing my default interactive shell to zsh, then closing and reopening Xcode.
To change the default interactive shell to zsh, use this command in a terminal (command line) window:
chsh -s /bin/zsh
I had already ensured that both Objective C and Swift were being compiled with no optimisation in debug mode, and that I was running a debug build of my app.
Before I made the change I couldn't see any variables, and no lldb commands worked. The change fixed both those problems.

Xcode 9 Autocomplete Not Working 100% - Partially Working

This morning, Xcode 9.0 (9A235) shows a new/strange Auto Complete box that is not at all what it used to be. How do I get the full auto-complete box so that autocomplete looks like how it usually does?
Try:
Go to Xcode > Preferences > Text Editing
Under Code completion - Uncheck 'Suggest completions while typing'
Quit out of Xcode and then relaunch Xcode.
Go to Xcode > Preferences > Text Editing again
Quit out of Xcode and then relaunch Xcode.
Now go to Code completion and check 'Suggest completions while typing'.
Try typing library function or enum and enjoy!
Deleting the DERIVED DATA folder seemed to fix my issue. Thanks to this post: swift println() not showing autocomplete options while writting code
Things to try:
#1
Run this command in the project directory if you use cocoapods:
rm -rf ~/Library/Caches/CocoaPods;
rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*;
pod deintegrate; pod setup; pod install;
#2
**Clean Cached Data**
Clean the Project -> Cmd+Shift+K
Clean the Build Folder -> Cmd+Shift+Option+K
If you skipped step one:
Delete Derived Data
Xcode Preferences -> Locations ->
Arrow Symbol Takes you to DerrivedData -> Delete Folder
#3
**Check your Build Phase's Compile Sources.**
Every .swift and .m file in the project should be in this list or it won't autocomplete in those files.
#4
**Optimize your Editor:**
Use fileprivate* on every class property and function that you can to reduce the scope of the Compilers work per item.
Write modular/OOP code so you have less code for the compiler to read.
Avoid using Type Inferance when the result is a complex calculation, and try to break down complex calculations into let this = smallerOperation statements
* In Swift 4 private became stricter than fileprivate
In Xcode 12 there have been significant improvements in how often deleting derived data is necessary (though freezing has increased).
Xcode Version 11.0 (11A420a)
I have tried the solution from Lal Krishna for Xcode V11.0. It worked a few times but later I got no result.
I found one solution. You must delete two files:
Library/Developer/Xcode/Derived Data (as described before)
Library/Developer/Xcode/UserData/IDEEditorInteractivityHistory
That solution helps me now. May be useful for others 😉
This can happen when the file is not a member of the Target. Open the file where autocomplete is not working and show the the "Utilities" tab in the top right of Xcode (blue in the screenshot below).
Ensure your Target (typically your app's name) is checked. Autocomplete should work almost instantly without restarting Xcode, cleaning, or deleting Derived Data.
If it is already checked, make sure to uncheck and recheck it again. For me, it did the trick.
I'm using Xcode 10.2 and I had the same issue.
This answer from axel helped me to fix.
Anyway, I'm going to describe a bit more:
Go to YourProject.xcodeproj by clicking with Right Mouse Click and open Show Package Contents
Go to xcuserdata and delete your youruser.xcuserdatad
If you have also the xcworkspace(if you already have any pods installed) then do step 3&4, if not then just skip step 3&4:
Go to YourProject.xcworkspace by clicking with Right Mouse Click and open Show Package Contents
Go to xcuserdata and delete your youruser.xcuserdatad
Quit Xcode
Delete Derived Data by using Terminal:
rm -rf ~/Library/Developer/Xcode/DerivedData
Open Xcode and check if it works.
This can also happen if you redundantly named your files. For example,
Data.swift
Data.swift
Here's a bit of workaround but works.
Clean the project... Command + Shift + K
Clean the build folder... Command + Shift + Options(Alt) + K
Delete derived data for the project...
This can be done with the help of this link:
How can I delete derived data in Xcode 9?
Close XCode.
Reopen XCode (let the indexing complete) and Build the project... Command + B
Once it will be done with building, The suggestions will be back. I have tried it twice.
Update:
Sometimes the issue can be as simple as Duplicate file names.
Carefully check if any new file names added by you are conflicting with older files.
In Xcode 11.4, even if you move an existing file to another group, the suggestions disappear. This can be cured simply by restarting Xcode.
Removing the file from the Test Targets fixed my problem.
After a long time of searching, I finally fixed the issue for me. In Xcode > Preferences > Text Editing, in "Code Completion", I had "Use Escape key to show completion suggestions" checked for some reason. As soon as I unchecked this box, auto completion worked like a charm, without even needing to restart Xcode! (Xcode 10)
Please try doing this:
Select the file >> check if the file is added to UITesting or UnitTesting targets (File inspector -> Target Membership). If so, please uncheck those two and make sure only the project target is selected. Then build and try if autocomplete is working fine.
This worked for me. Hope it help someone.
For Xcode 11.4 (11E146)
Back Slash in folder name breaking the autocompletion feature, If this is the case remove it and build again.
I added here what was going on in my project just in case it can help someone else... I had 2 files with the same name and I didn't realise.
Just lost a day trying to solve the autocomplete nightmare of Xcode (9.2). Deleting derived data seemed to work briefly then things reverted. Reboots etc and other suggested voodoo failed to make a difference.
I gave up and download the 30 day trial of AppCode from Jet Brains. Autocomplete worked fine there and this maybe coincidence but it then started working again in my project in Xcode. Can't guarantee that it'll keep working...
It seems to be file specific in my case (Xcode 9.2) For me the fix was:
Delete problem file (remove reference)
Clean and Build
Add file back into the project (I did not check test targets)
Build again
Finally after 3 hours of trying everything - autocomplete works as it should.
Problems mostly because there are missing location of some files in project navigator (build errors)
Press command+1 to open Project Navigator pane
Check if there are any missing files
Or you can:
Delete DerivedData (command+shift+K)
Clean build folder (command+shift+option+K)
Press build again (command+B)
You should see build error that Xcode could not find some files that prevent build tool to process auto complete.
Correct and fix any missing files that you see.
Hope this helps
Use Command + B
or Command + R to Build or Run the project
Xcode sometimes messes up ;)
Xcode 11.3, macOS catalina
process parsecd achieve 100% of cpu, so kill it helps me
goto underneath directory and delete all folders on it.
{Your User}/Library/Developer/Xcode/DeriveData
It worked for me.
For me it was happening in my test file, because it wasn't part of a target for some reason. Setting it's target membership solved the issue.
For me, the problem occured when I discarded all the changes of one file (under Source Control > Commit), which effectively deleted the file. This is what I wanted and I thought that the file and all references to it would be delted too.
However, there was still a reference to the file (shown in red) in the Project navigator. Deleting the (now non-existant) file in the Project navigator magically brought auto-completion back.
No amount of cleaning, deleting derived data, etc helped. I only realized the deleted file was still showing when I tried to build my project, which of course failed because it couldnt find that file.
Hope this will help someone save 30 minutes :)
check whether you selected the Suggest completions while typing in Xcode -> Preferences -> Text Editing
navigate to user->Library->Developer->Xcode->DerivedData in Finder and delete the DerivedData folder
My case might appear too specific to help, but it might give someone an idea of how to solve broken auto-completion. Xcode 10.2.1.
In my case, auto-complete stopped working entirely and non of these other answers helped me. In addition, the fan on the computer could be heard to go louder indicating something was overworking (no other apps running), it should be noted I was editing on a MacBook Pro laptop. It seemed to be linked with the editor struggling to parse the equation I'd written:
switch mtype {
case .indeterminate:
newPosition.x = (frame.width - mainFigureText.frame.width) / 2
case .right:
newPosition.x = (((frame.width / 2) - mainFigureText.frame.width) / 2) + (frame.width / 2)
case .left:
newPosition.x = (((frame.width / 2) - mainFigureText.frame.width) / 2)
}
I was looking to animate a text view left, right, or to the middle depending on user prefs. The newPosition is a CGPoint that the text will animate to. Anyway, I split the equations up and all of a sudden auto-complete started working and the fan went quiet! I've been able to recreate this specific problem more than once by re-typing the above code and then replacing it with:
let halfFrameWidth: CGFloat = frame.width / 2
let middleLeft = (halfFrameWidth - mainFigureText.frame.width) / 2
switch doseType {
case .right:
newPosition.x = middleLeft + halfFrameWidth
case .left:
newPosition.x = middleLeft
default:
newPosition.x = (frame.width - mainFigureText.frame.width) / 2
}
I would like to add one more to the pile of solutions, because it is the only one that worked for me and is nowhere to be found here.
Xcode normally comes with two default build configuration for every project. Release & Debug. I have an extra one for my unit tests called Testing. In Xcode 10.1, 10.2, 10.3 and 11 beta, the new build system does not seem to like it and will only auto-complete if you either use Release or Debug. Any custom build configuration breaks auto-completion in mixed (swift + objc) project with unit tests.
I faced the same problem in Xcode 11.3.1. In my case The issue was cause due to duplicate file names / Deleted file name. Better to run the application once and check whether there are any deleted files/classes so that you will get a syntax error.
This Link helped me. Open the Build Settings & fill the framework search paths. See the below image.
Build errors can break the autocompletion feature in Xcode.
I had the issue with 100% not working auto-complete, none of written here helped. One thing I noticed – it was broken right after adding some entities into .xcdatamodel file, which have codegen class definition by default.
So I wasn't surprised when using old-style codegen none (and generating classes of course) fixed the issue immediately, even without restarting the xcode.
With Xcode 11.1, simply performing Clean Build Folder or deleting derived data was not enough to fix autocomplete.
Only after restarting my Mac, everything was back to normal
If you have issue with weird completion/auto-completion/intellisense (not showing default stuff like delegates and datasource protocols methods) just change your target (e.g. from simulator iPhone 8 to real device), build the project and switch back to your original target.
Similar with issues with Interface Builder (storyboards) not showing anything, but only "nothing selected" whenever you select any part of the view. Just switch to other Xib/Storyboard (or even create new), check if it works there and switch back.
These workarounds worked for me in both cases (had both issues in one day with one project on Xcode 10.2.1). From what I've seen all over internet forums it seems these are bugs never fixed since Xcode 6.x or so.
Cheers!

Xcode 8.2 Code Completion Not Working

For some reason, in Xcode 8.2 my code completion has stopped working. I have cleaned my product, restarted Xcode, restarted my computer, and deleted the derived data, and still no luck. I have submitted this to Apple Support. Has anyone run into this before and been able to fix it?
Update:
As per #Dareon solution below also works for Xcode Version 8.3 (8E162) and 8.3.2 (8E2002). Thanks, #Dareon for the confirmation. :)
I was facing the same issue and following worked for me.
I am using Xcode Version 8.2.1 (8C1002).
Go to Xcode > Preferences > Text Editing
Under Code completion - Uncheck 'Suggest completions while typing'
Quit out of Xcode and then relaunch Xcode.
Go to Xcode > Preferences > Text Editing again
Quit out of Xcode and then relaunch Xcode.
Now go to Code completion and check 'Suggest completions while typing'.
Try typing library function or enum and enjoy!
At least, it worked for me.
Code completion also stopped working for me in Xcode 8.2.1, and no amount of clean-up, derived data throwaway or restart fixed it. After a while, I realized code completion was only broken within the extension scope I was working on. If typed manually, the code would be correctly highlighted and would compile fine, so it was not an issue of the source throwing off whatever parser is in charge of code completion.
Here is the specific context in which it happens, in this very simple example:
struct SomeStruct {
static let foobar1 = {
return NSBezierPath()
}()
}
extension SomeStruct {
static let foobar2 = {
return NSBezierPath()
}()
}
Code completion works fine within the implementation block of foobar1, but not for foobar2. It's the presence of a static let within an extension that seems to trigger it. The issue appears for both struct and class.
Looks like a bug with Xcode, so the only workaround for me was to move foobar2 into the main definition of SomeStruct.
Just restarting Xcode worked for me.
Just clean and build your app once on Generic iOS Device, it might be due to some compile time issue, which disables the intelligence, I am seeing this bug since Xcode 8.2.1.
What worked for me was deleting derived data:
Xcode Preferences -> Locations -> arrow symbol takes you to "Derived Data" -> delete folder
I have had major issues with this as well. For me the code completion and formatting gets lost on my current working source file when ever I do a compile. If I go back and switch to a different tab and come back, after a second or two it starts working again. Sometimes even that doesn't work and I have to stay in the same tab and open up a different file and then navigate back.
Even those methods fail if I leave Xcode open and put the computer to sleep for a few hours and come back. When that happens I have to quit Xcode, sometimes Force Quit it, and then after getting back in do the steps above. But I have had to mess around with it after every single compile or compile and run I do. Haven't tried 8.3 beta yet.
I had the same issue where the "indexing" did not work. As I was using a pod and static libraries. What I did just rebuild the static libraries separately.
Hope this helps.
If you have any large static literals, try commenting them out. Those can sometimes trip up the compiler.
Nothing else worked for me, but this bizarre approach did:
Quit Xcode
Go into your home directory, which if you're like me, is riddled with empty directories with garbage names
rmdir * (as long as you leave the tags off, this will kill only empty directories, which is what you want)
Launch Xcode, happy times again

Xcode 4 code sense is not working

I am running a "old" Xcode 3 project in Xcode 4 and code sense is not working for my own classes. I have tried following:
Clean/rebuild
Remove Derived Data
Installing 4.3 documentation
Restart
Without any luck.
Sometimes the code sense works but mostly I just get "No Completions".
Try this:
Open Organizer then Project Tab.
Clear the "Derived Data". Xcode should re-index your project then and code sense should work. At least worked for me.
I know this is late, but for reference: http://sealedabstract.com/code/when-xcode-4s-code-completion-autocomplete-breaks/
Close the project, leaving XCode still running.
Open XCode’s Organizer window, go to the Projects Tab, select the correct project, and hit the Delete button next to “Derived Data”.
Quit XCode.
Navigate to your project’s .xcodeproject file in Finder. Right-click, choose “Show Package Contents.”
Leave the project.pbxproj file, but delete the project.xcworkspace file, any .pbxuser files, and the entire userdata folder.
Open the project in XCode. You will see XCode riding high on the CPU usage for around 10-60 seconds, depending on the size of your project. The activity window will say “Indexing”
When your CPU spike returns to earth, code completion will be working again.
There's a lot of deleting going on there so please be careful, but this definitely worked for me.
I've been doing this, and it's worked multiple times for me (after trying all of the above previously).
Edit: Now I just hit space, backspace (the mac version) and rebuild... works nice. Then, remember to scroll (sometimes the colors don't show up until you scroll somewhere)
Find your prefix file: "ProjectName_prefix.pch".
Comment out some line. (basically change it)
Build your project, doesn't matter if it fails or not.
Uncomment it.
Build again.
I'm betting only step 2 (modify the prefix) is what does it, but these essentially get you back to running. Suddenly everything magically recolors itself and completes functions.
Good luck if that doesn't fix it, perhaps try doing this to your dependency pch files (three20 or FB api's)
Clearing the "Derived Data" only works temporarily for me. I have to do it and then restart Xcode like 3-4 times each day to get code sense working again.
I found out the real cause is in the Target's Build Settings. I moved everything from Header Search Paths to User Header Search Paths and it is fixed. In my case, the framework I'm working with is RestKit.
BTW, I came up with this because I was adding another project (QuickDialog) into my project and I was curious that it is using User Header Search Paths, but not Header Search Paths. Here is the difference between them.
You can able to fix that issue by change build settings like this, PreCompile Prefix Headers :NO
FYI, if one file doesn't have code sense but the rest of your project does, check that its added to a target. Once I did that I got code sense back in that file.
It's been ages but the answer is just to move the code into a new folder and the code sense should be working now.
This happened when I added a new Objective-C Class and the code sense doesn't work only on the newly added .m and .h files (on XCode 4 latest update during this post).
Close all xcode windows
Delete all your projects from xcode>window>organizer and restart your project. It will now sense and index your project properly.
I wrote about it in detail here.
Basically my fix was that with localization. I upgraded from xcode 3.2.5 to xcode 4 and then screwed around with built in interface builder and turned on localization for a XIB file accidently which placed my source files in en.lproj directory. After moving them back to Classes folder it worked perfectly.
Again, for the sake of helping others with this issue which, in my case, happened upon upgrading to Xcode 4.3.
Of course I tried the solutions offered in this post, and none of them worked. But the suggestion to move the location of the project in Finder brought back some Code Sense, but the suggestions didn't make any sense.
I ended up deleting my project and re-cloned it from the git repository.That brougt back Code Sense for me...
I open a second project in the background whenever my Xcode's code sensing stops working (it usually works the first time i open the project but after a while code sense no longer works). So what i do is to open a second project in Xcode. Xcode will start indexing the second project and magically the code sense for my main project is back.
Running Xcode 4.3.1 on Lion
Hope this helps someone.
From this comment here I was able to debug the problem on my end, it seemed to be a bad -w flag that the clang preprocessor wasn't recognizing properly. Basically, running
defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3
in Terminal increases the verbosity of the indexer, and should help you track down issues. Open Console.app and look for messages from Xcode, the search string IDEIndexingClangInvocation helped me find them.
For me it happened simply because the file had no target membership. If the first few answers did not work for you, go to your .m file (presumably it's this file that you're having trouble with), open the Utilities view (Edit -> Utilities -> Show File Inspector) and under "Target Membership" check the target to which you want this file to belong.

Xcode: code loses syntax coloring

I find that in various situations Objective-C code in Xcode 3.1 (Leopard) can fail to get appropriate syntax coloring after typing or lose coloring that it had.
This isn't just a "refresh" issue with new custom symbols -- but affects Cocoa framework symbols as well.
Sometimes CMD-a to select all text on the code page will make the coloring (re)appear, sometimes double-clicking on a line to select it will work, sometimes I have to add/delete a space in a symbol to get that symbol to (re)color. Rebuilding, or closing/reopening the project may or may not work.
Is this a known issue with Xcode? For something so annoying to me, I'm not finding the plentiful discussions of it on SO and elsewhere I'd expect.
And is there any command to force global syntax recoloring?
1.) Go to Project --> Build Settings --> Header Search Paths
2.) Add "$(SRCROOT)/**"
3.) Close and reload the project
4.) Go to Xcode --> Window --> Organizer --> Projects --> $YourProject --> Delete Derived Data
5.) Wait a moment until XCode rebuild all indicies
To get more information activate verbose logging:
1.) Increase Xcode log level in Terminal app:
defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3
2.) Open Console app. Search for "xcode"
3.) I saw "file not found" errors for header files mentioned in the pch file (therefore the fix above)
I had the same issue with a project that was fine in Xcode 3 and for which the syntax highlighting and code completion has broken in Xcode 4. It took me the better half of the day to figure it out but I found that the following steps will reproduce / fix the issue 100% for me.
After trying all the aforementioned solutions to no avail, I tried creating the project from scratch and reimporting every file and folder painstakingly. Every time I imported a couple of files I checked and syntax highlighting still worked. Even after the last few of them it still did. Then I hit build which failed because I forgot to include a couple of common header files in the project .pch file that were there in the old project. And that was when CodeSense broke again.
After further investigation we found that if you import a header file that in turn imports the same framework header file than the .pch already does, then CodeSense will break. The same setup did not cause any issues in Xcode 3.
Example:
project.pch
#import <Foundation/Foundation.h>
#import "projectConfig.h"
projectConfig.h
#import <Foundation/Foundation.h>
#import "one.h"
#import "two.h"
So by removing the wholly unnecessary
#import <Foundation/Foundation.h>
directive from the 'projectConfig.h' you can fix the highlighting and code completion will come back for you as well. If your issue is the same as mine that is.
Just select the file who lost the syntax coloring , press Editor > Syntax Coloring > ( choose your language (Objective c++ for ex) instead of 'Default'
I have found the best way to regain syntax coloring is just to quit Xcode and re-launch it. I couldn't tell you why, but that works every time.
I find that the following will often do the trick…
"Reselect" both "Base SDK" - and "Architecture" - in "Build Settings".
(CLick on blue project icon in top left, while in "Browser mode", aka ⌘1, then click project settings and mess with the stuff there.
Make sure they all line up / it doesn't hurt to do a little toggly-wogglying up in there, while you're in there… ya know just mix it up a bit. You'll notice xCode has a teensy-tiny mini-stroke - every time you switch between 64 and 32 bit… This is usually when I know if code highlighting is dead for the night, or if I'm good to go.
Often, I will have a project that gets highlighted instantly in 32 bit mode, and just sits there in 64… Who knows.. Ahh, Xcode, you wacky botch.
Select your Project -> Build Settings tab -> Apple LLVM Language 5.0 -> Precompile Prefix Header to YES. NSLog was not highlighting. Currently running Xcode 5.0.1 Hope it helps =) Thanks #rebelzach
I can confirm a 100% fix for this problem, based on a question I had asked (and actually answered), as pictured below. One thing i will add is that sometimes it is "errant whitespace" that can also contribute to the loss of highlighting. Either clean it up yourself, or use the Goggle Toolbox for Mac Xcode 4 plugin, which adds an entry in the XCode Edit menu called Clean Up Whitespace.
This appears to be a similar error from this question
I was able to correct this issue by setting Precompile Prefix Header to No in the build settings.
I recently had a similar issue, all coloring and autocomplete stopped working for built-in frameworks, my own classes still worked. Someone recommended to me that I turn off "Run Static Analyzer" in the build settings. It's weird, but it worked.
For me it was that I renamed my project, and Tests target was still pointing to the old pch location, but my App target was pointing to the new one.
If your app delegate still has code sense, this might be the case for you too. Go into project, select the 'Tests' target search 'prefix' and set it to the equivalent value in the 'app' target.
Open the project settings (Project > Edit Project Settings menu) and then click the Rebuild Code Sense Index button in the General tab. This will recreate the index that Xcode uses for syntax coloring.
This process can take a while for larger projects, so you can check the progress in the Activity window (Window > Activity menu).
Moreover, in XCode4 there is no button to rebuild the code sense index.
I had the same problem and solved this by updating my build settings to use the system default compiler, LLVM GCC 4.2.
It seems there are multiple factors.
I experience this issue as well, and have tried the solutions either "rebuilding the index", "relaunch XCode", "change the compiler setting to LLVM GCC 4.2". Those didn't help me out.
So I tried to add the following code right away along with the fresh creation of header file.
#include "header.h"
using namespace cocos2d
Then, the code added earlier in header file is colorized, and it can recognize classes and stuff.
I've used cocos2d-x, so my syntax is based on c++. I don't test it with Objective-c yet though.
For someone still have don't know why. Let open with XCode 8.2, it should work

Resources