Xcode Objective-C code completion broken for a single file - objective-c

My Objective-C code completion got broken for a single file in a big project that I'm working on.
There are many classes and completion if just file. But for a new file that I've created, code completion is not working:
Where is, for instance, UINavigationController? The code compiles and works fine though.
I have already:
Cleaned the project
Rebuilt the project
Restarted Xcode
Tried above steps a couple of times in different order
Removed DerivedData's contents (when Xcode is closed)
Removed xcuserdata folder from my workspace "file" (when Xcode is closed)
But it doesn't seem to work. My only observation is that, there was another class with the same name (which I completely forgot) when I created my class (it was in another folder though the same class name and the same project), and as soon as I've realized that it's not compiling due to that old class that wasn't used, I've remove the old one and my code started compiling successfully. I've done all the steps above after removing that class, so nothing should be left of it anyway.
Interestingly, syntax coloring is working properly even though not completing.
How can I get my code completion back on this file? I'm on Xcode 7.3.1.

I have no idea why, but it went away by itself after a few minutes.

Related

Values cannot be null. (Parameter 'baseName')

When trying to open the form deisgn it says values cannot be null. (Parameter 'baseName'). I still can run the system without error. Dont know how to fix it and have to change some gui design. Help me its for my school tnx
I had this problem this morning and a few hours later I decided to just start over and copy the code from the old project to the new empty project. Everything is working in the new copy of the project. I copied from old to new by drag-n-drop. I copied all the UserControls before I copied anything that uses them, and built, then copied over the remaining things, and went through all the errors caused by the change in name of the top-level Namespace.
(All of the Namespace errors were in the .Designer.vb files. I have posted elsewhere "never edit those files by hand unless you know what you are doing." This case was one of the rare exceptions.)
I had the OP's problem that when I tried to open a Form in the designer, I got the message
Value cannot be null. (Parameter 'baseName')
It didn't matter if I tried to open the Form in Solution Explorer or by pressing Shift-F7 in the Form's code window. However, sometimes Shift-F7 resulted in a wait cursor followed by silence - no error message.
Like the OP, the project did run without errors (well, same bugs as before but you know what I mean).
Another symptom: If I launched VS and tried to open the Form designer before Intellisense was initialized, instead of the other error, the window that should show the layout of the Form showed this instead:
File path: full path of the file I was trying to open
Frame GUID: 2c01570-c72c-11d0-88c3-00ac0c9110049
Frame mode: VSFM_MdiChild
Error code: 0x80131500
There are no MDI containers in my project. It's a reference to VS 2019.
The same error occurred in every Form and UserControl in the project.
The same error occurred in any new Form or UserControl that I added to the project.
The error did NOT OCCUR in any and all other projects built in VS 2019 with a target of .Net 5.0
The error DID OCCUR with the same project on another machine running a clean install of a later version of VS 2019.
Attempts to Clean Solution or Clean Project failed, with a generic error message, it was something like "Clean Project failed."
Nothing about these problems appeared in any event logs.
Every time the problem happened, when I shut VS, one process was left running (per TM).
Here are some other things I did to try to suss it:
Ran a repair install on VS 2019 and reboot.
Opened each and every VS-generated file in another project and compared them line-for-line (most are text) against the corresponding files in the broken project. No data-independent differences.
Searched exhaustively with 3 search engines and many terms for someone else that posted about this error. This is the only post I found.
Deleted, renamed, or moved files that are automatically generated by VS, including some Json files, XMLs, and caches.
What I did not try:
Roll back the code to the most recent commit.
Uninstall VS 2019 completely, reboot, install VS 2019 as if an initial installation.
Just had the same experience. I took me a while before I got everything to work again, but the clue in my case was that I had added a new item to my project, and for some reason I had managed to delete the file name in the process so the only thing left was 3 new files with only the extensions .resx, .cs and .Designer.cs
I quickly deleted the ".cs" file but forgot the rest.
Suddenly I was unable to open my main form in the designer - and the “Value cannot be null. (Parameter 'baseName')” started to appear. It was only affecting my main form.
I tried almost everything described above except the reinstalling part.
But then I deleted ".Designer.cs" and ".resx" from within visual studio (Solution Explorer), and then the problem went away.
I started getting this error after using a hack to support generics forms (e.g. MyForm). The designer generated a file:
MyForm.resx
which worked for design time (even with the form being generic) but crashed at runtime. My hack was to rename the .resx file:
MyForm`1.resx
However that is when the Designer stopped working. It stopped working for ALL forms/user controls in entire solution (not just the generic I was experimenting with). I assume there is some kind of process that crawls all the resx files whenever you open any Designer and that is the source of the Exception.
I was able to work around the issue by:
Renaming the resx back to its non generic title (i.e. MyForm.resx)
Restarting visual studio.

Intellij isn't analysing my code

I have a scala project that I'm working on in Intellij. When I opened it up this morning, suddenly none of the code is being analysed properly. The main things I've noticed are that it says every variable is unused (even when it's used in the next line), it doesn't show an error if I try to use a variable that doesn't exist, and I don't get any errors if I try to use a class I haven't imported. TODOs also don't come up in blue.
Does anyone know if there is some sort of setting that somehow could have changed that would affect this? The problem only happens in this one project, all of my other projects are fine.
Edit: I have tried closing it and opening it again, invalidating the cache and restarting and restarting the entire computer.
Edit 2: I forgot to say, if I try to run a test it will come up with the correct compilation errors for things that shouldn't work, but it still doesn't show the error in the code itself.
I'm still not sure why it happened, but I fixed it. I deleted the .idea folder and re-imported the project, and everything was analysed properly.

Xcode 6 Swift code completion not working

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.
Just go in user->Library->Developer->Xcode->DerivedData and delete the Data of folder(Derived data) and restart Xcode.
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…
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.
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
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
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.
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.
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
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".
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.
Select the file you are editing (in the framework )
Select the 'utilities' tab on the right
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.
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.
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.
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.

Code loses syntax color in Xcode 4

I have just upgraded to the new Xcode 4 and the code is not colored has it ought to be.
For instance, the string NSString is not colored in my custom code, but when I switch to Apple's code (NSString.h for example) everything is well colored.
How can I fix that?
It's a known bug with the latest XCode. This happens with some projects which are migrated from XCode 3.X to the new version. For some people it seems to help to go to the organizer, and in the project tab delete the derived data for the project where code sense does not work correctly.
If you have a small project, it might also help to create a new project in XCode 4 and import the files from the XCode 3 project.
Update: XCode 4.0.1 made the situation a bit better, at least in some of my projects I have syntax coloring and code sense back. But it's still far from fixed.
Update 2: XCode 4.0.2 did not change much. It seems that the problem is related to subprojects, specifically static libraries. According to comments of this blog post some people were successful by changing header search paths from relative to absolute paths, e.g. instead of Foo/Bar use $(SOURCE_ROOT)/Foo/Bar. This together with switching all projects to XCode 3.1 format and to use LLVM 2.0 fixed a lot for me as well. It's not perfect yet, but usable.
Update 3: After converting the sub projects to independent projects and putting them in a workspace (aka the XCode 4 way) I have now full syntax highlighting and code completion back.
My current environment is now a XCode 4 workspace with each projects being 3.1 compatible (as opposed to the default which is 3.2), LLVM GCC 4.2 (system default) and the header search paths are still absolute (using $(SOURCE_ROOT)/.../).
I used undefined Macro, But those macros defined in Preprocessor Macros in build settings. So the xcode4 didn't generate any error for that undefined macro.
Steps taken to resolve.
Removed undefined macros wherever I used those undefined macros.
Removed duplicate definitions of Marcos.
Removed duplicate Resources. (I'd added same (many Thumbs.db files) files into the project.)
Clean & Build.
if still you are not getting the color then, please relocate your project to some different location, I changed to my Desktop location.
After these steps I got the color in my eyes.
But its very bad issue. I sucks lot of valuable time. I think these steps may help you.
Thanks.
I had the same problem with mine. Its a cocos2d game with box and chipmunk. It was a hell of a mess getting the project to recognize and find the user search paths in the first place so I wasn't about to mess with those.
What I wanted to point out is that I DO HAVE recursive paths and I do have relative paths and I still got the issue. It happened when I added a new version of a 3rd party SDK I was using. It was Testflight 083 which I updagraded to 1.0. I erased my old version but only removed references. Then I manually deleted it from finder. Imported the new SDKv1 folder and readded it to my project and removed the old SDK0 folder path leaving only the newly added SDK1 folder path. For some reason I noticed that even though in v083 I had used a #import in my Prefix.pch file, it still wasn't recognizing a call to a method from AppDelegate. Which means the #import in Prefix.pch for some reason was not working. I had to add #import to my AppDelegate file individually. This gave me duplicate #imports as Jeeva said above. That sounded an alarm in my head.
So the solution was to go and effectively remove the duplicate #import in Prefix.pch therefore only leaving the one in AppDelegate. It reindexed and CodeSense works again. Thanks Jeeva!
This issue was driving me insane, and I had given up hope of fixing it without some ugly hack on XCode's configuration. I passed through this very forum thread a stack overflow of times. Then one day, I happened to accidentally fix it. I'm not sure if you need all these steps, but I've found this a sure-fire way to fix XCode's indexing issues:
Clean your project (Command-shift-K)
Open organizer, close your project.
Under the "Projects" tab in organizer, remove the derived data for the project you want to reset.
Quit XCode
In the terminal, run:
sudo mdutil -a -i on
This seems to reset spotlight indexing (I don't know much about it because I don't use spotlight).
When the command finishes, Spotlight will have to re-index. Look up to see a little dot in the magnifying glass for your spotlight's icon. When the dot leaves, spotlight has re-indexed. You can check the progress by opening spotlight.
Re-open XCode, and wait for it to re-index all your files.
Build the project.
On build success, you should now have appropriate syntax highlighting again. I hope you guys find this little discovery as useful as I did :)
EDIT:
I should probably add that the syntax highlighting sometimes seems to re-break when the debugger hangs the simulator during app launch. I just try to avoid this by being more careful about letting the process hang.
EDIT2: (sorry first contribution)
Works on XCode 4.6 and 4.6.2.

XCode Syntax Coloring Broken

XCode frequently seems to lose it's mind, and doesn't color code system classes or provide correct "code sense" suggestions. This is endlessly frustrating. The question has been asked on at least three other occasions:
Problems with Xcode Syntax Highlighting
xcode code sense color/completion not working
Xcode: code loses syntax coloring
I have switched by project version to/from 3.1-compatiable and 3.2-compatiable, completely restarting XCode before and after each change with no effect.
I have rebuilt the code sense indexes and completely restarted XCode with no change.
I have built my project to make sure there are no errors and restarted.
I have copied my files (sans .svn files) to a different location - same problem.
I've already completely disabled the argument "placeholders" because they screw up my documents when i type too fast... all I'm asking for is for the "esc" key to display the correct list of properties and methods.
You should clean your project's derived data. They are likely corrupted.
Go to Organizer > Projects > Your_Project > Derived Data > Delete
Xcode will reindex your project and you should be back to normal.
For anyone interested; my app has some precompile directives:
#if ...
Turns out there was an error in one of these sections.
I'm assuming my app built fine because these sections were stripped out before they ever got to the compiler... but CodeSense doesn't care about these (it still wants to color code everything inside these) - so CodeSense would puke all over the place because of the error, even though I didn't find it when I tried to build the app.
Once I fixed the error within that block of code, my coloring returned.
Would be nice if XCode just greyed out those sections instead of dying.