55

I am having an issue where the code associated with some of my View Controllers is not showing up in the Assistant Editor window to the right of the Storyboard. It says "No Assistant Results" where the swift code should be.

Things I have tried (There are many things):

  • Cleaning project
  • Deleting DerivedData
  • Creating new, identical View Controllers to see if the issue was just in those particular views.(the same issue occurred)
  • Deleting and Reinstalling Xcode
  • Restarting my Computer.

NOTE: I also am getting a warning at the top of the editor: Internal Error has occurred, source Editor functionality is limited.

enter image description here

Ryan Cocuzzo
  • 3,109
  • 7
  • 35
  • 64

36 Answers36

47

Ok, I've had this problem before. I couldn't remember how I solved this so I searched on Google and found this question. But this time, nothing helped me. These are the things I did. I believe the last one solved this.

  1. Clear Derived Data. Go to Terminal and enter this: rm -rf ~/Library/Developer/Xcode/DerivedData
  2. Quit the whole Xcode.
  3. Close all tabs of Xcode and make sure to view some class files instead of Interface builder and go try again viewing assistant results.
  4. Remove the assigned class to the View Controller nib you think causes the problem, then assign the class again. Boom! Solved!
Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
  • This just helped me after refactoring - Xcode didn't build correctly and also didn't show the Assistant file... Seems to be an issue with the Xcode project file – brainray Jun 25 '20 at 11:55
  • 4
    Still happening in Xcode 12.0.1. Quittng xcode works. It's just sad how many annoying problems xcode has with adding/syncing files and this is the *12th* major iteration... – Govind Rai Oct 02 '20 at 16:13
  • Still happens in XCode 12.3. As above, closing and re-opening XCode and re-selecting the project fixes the problem. – SimonKravis Aug 04 '21 at 23:03
  • 1
    Closing and re-opening XCode didn't work for the latest instance of this problem but renaming the project folder (the one containing .xcodeproj file) did ... – SimonKravis Aug 12 '21 at 08:39
  • Quitting Xcode and reopening is resolving this for me in 13.3.1 but it is disappointing that Apple hasn't fixed this in their flagship IDE – John Harrington May 26 '22 at 19:36
37

This method worked for me: (Xcode 10.2)

1- Select the broken ViewController on the StoryBoard

2- In Identity Inspector, change the item in Class to another class (any class)

3- Change the Class back to related class

4- Save and close the project

5- Reopen the project

Arash HF
  • 837
  • 12
  • 10
35

What worked for me was to close Xcode entirely, open again, and then I tried assistant.

black
  • 353
  • 3
  • 6
19

Just do a simple close the app and open the app again. It worked for me

arman
  • 191
  • 1
  • 5
11

Go to Assistant Mode on the upper right.

Click Command + Shift + T. New window will be opened and close the old one. You will be able to see something. Now go to Top Level Objects and select your file.

user11894123
  • 131
  • 1
  • 4
8

Deleting derived data did not work for my problem. This is how I solved this when I encountered this issue,

Go to the file that contains your class, go to File inspector > Target Membership, and then make sure that there is a check mark in the target of your project.

File inspector

I hope this solves your issue.

7

Click option+alt and click on the view controller you want to present.

ortalPozniak
  • 131
  • 1
  • 3
3

Argh! This annoyance happens to me all the time.

I'm not 100% sure I know what the fix is, however I think I may have just "fixed" this a few seconds ago using the following voodoo:

1) Delete derived Data

2) Close xcode, reopen Xcode. Maybe Wait for indexing to finish?

3) View a source code file (.m,.h, .swift) in the main editor, the assistant editor should now show "Counterparts".

4) Change this to "Manual" rather than "Automatic"

5) Switch back to your nib/storyboard

6) Change back to "Automatic" rather than "Manual"

7) Probably continue pulling hair out :)

Edit

Seems as though maybe only step 3 is required as this happened again just now.

Chris Birch
  • 2,041
  • 2
  • 19
  • 22
2

I had this issue and was able to resolve it. I resolved it by viewing the storyboard as source. I then removed everything in and including the tags (Saving it to restore later). I then went back and viewed the storyboard normally and created a new ViewController. Once the new ViewController was on the storyboard the assistant editor acted as normal. I then went back and viewed the storyboard as source code once again and replaced the current tags with the one I removed previously. This resolved my issues hopefully it will help for you.

2

For me (Xcode 11) it was cause by installing cocoapods, tried all the trick that I could find. Finally this helped me. Go to Xcode File Menu -> WorkSpace Settings -> enable legacy build systems enter image description here

M.Yessir
  • 202
  • 3
  • 11
2

The same problem happened to me. I only have to restart Xcode (12.2)

Dharman
  • 30,962
  • 25
  • 85
  • 135
Nguyễn Trí
  • 41
  • 1
  • 1
  • 4
2

For any one who is encountering the same problem in Xcode version 13.3

Explanation: for me, the reason why it wasn't working is that I created a controller, view, and model Folder and I put the Main.storyboard inside the view folder and the viewController.swift inside the controller view, therefore when I try to access the assistant Result Xcode doesn't know where the viewController file is, so he is not able to connect between the storyboard file and the latter.

Solution: What worked for me is that I simply ran the app and it automatically connected the viewController with the storyboard.

I hope this was helpful.

1

I don't know if this is still helpful or not, for what is worth, the way I managed to restore this when it's been working perfectly and all of a sudden it stopped is by changing Assistant Editor view-mode.

I usually have it in Assistant Editors at bottom, so just change it to whatever else, such as All Editors Stacked Vertically and go back, and it should be working ok now.

xcode 8.3.2, if it's any use.

Ale Ravasio
  • 98
  • 12
1

xcode screenshot of the location

I tried various ideas mentioned here but nothing worked for me. So in the Project navigator, I right clicked on the .DS_Store file, clicked on Delete, and then chose "Move to Trash" on the confirmation prompt. After closing Xcode and opening it again, a new .DS_Store file was created. The Assistant Editor is working again and the .h and .m files appear in the Project navigator again. I am using Visual Studio for Mac which communicates with Xcode. Today I had to close and open both Visual Studio and Xcode after deleting the .DS_Store file.

Gary Z
  • 155
  • 2
  • 6
  • Where was this .DS_Store file that you deleted? I'm using Xamarin as well and am facing the same issue. – Justin Jan 15 '20 at 17:20
1

you may have changed the name of the .swift file after you connected your IB oulets and IB actions.

select main.storyboard and select your view controller. at the far right select identity inspector. check if the class name is the same name as your .swift file, if it is not you need to put in the file name and the assistant should show up now.

0

In my case, the class name of File's Owner is incorrect (the class doesn't exist). I corrected the class name and it works again

sweet-2
  • 157
  • 1
  • 4
0

Identity Inspector

Go to the view controller Identity Inspector (see the image). Change your controller to something incorrect, then change it back.

Machavity
  • 30,841
  • 27
  • 92
  • 100
0

I had the same problem and I realized that selecting the Outlets option in the top of the Assistant Editor View solves the problem.

In addition to this, I found that if your classes are in several groups for some reason Xcode losses the reference to the class.

enter image description here

0

I setup the folder for the derived data when I installed Xcode in a folder I deleted cleaning my disk! So I created a new folder and I assigned in locations as above. Thats it! I was cleaning a file that didn't exist.in the Xcode->preferences->locations

araferna
  • 71
  • 1
  • 5
0

If the problem started after renaming the ViewController, first check whether you've changed the class name inside the ViewController file as well.

enter image description here

2apreety18
  • 181
  • 3
  • 8
0

I have disabled xcode indexing, so after enabling indexing it starts working

shmakova
  • 6,076
  • 3
  • 28
  • 44
0

Faced same issue. For me it happen when I moved my view controllers to the new group. The solution was unfortunate, but at least it worked again - I just moved the files back to the origin folder.

0

In Xcode 12.x, this will happen if you rename your ViewController file after creating it. If this is the case, just simply delete that ViewController file, and create a new one with a file name that you will not change, and then the Assistant window should automatically populate.

0

Please make sure that there is

no error in your project and your project is complining succesfully.

In my case, there was an error om some other class due to which I was not able to see assistant results.

Ghulam Rasool
  • 3,996
  • 2
  • 27
  • 40
0

After 7 imaginary hours, I finally found the answer. this is only for the storyboard for other people out there reading this is the answer if it does not help I don't care but here it is.

(This is an example project I cloned from GitHub)

Just select veiwcontroller.swift in the document outline, it should work.

Here is a screenshot.

Like i told, example project.

0

Had the same problem on Xcode Version 13.0 (13A233). As Glenn Posadas mentioned, deleting the derived data rm -rf ~/Library/Developer/Xcode/DerivedData then closing and re-opening the project solved the problem for me.

0

I had the same problem, so I re-organized files in folders and it got fixed. If you have the file in a specific folder, please put it outside that folder.

ee.bt
  • 308
  • 1
  • 4
  • 9
0

Try this (XCode 13.2.1):

  1. In Storyboard, select the object whose class definition you want to bring up in the assistant editor.
  2. Delete the custom class in the Identity Inspector, being sure to press the return key to lock in the change.
  3. Quit XCode and reopen.
  4. Re-enter your custom class name in the Identity Inspector.

I tried all the suggestions above and this was the only thing that worked for me.

0

Xcode 13.3.1

None of these worked but I did a clean and shut everything down and reopened and it worked.

devjme
  • 684
  • 6
  • 12
0

One reason for this happening is moving the swift file to a different folder. If I move the swift file out of the folder, the assistant view works again. If I move the swift file back into a folder, it fails again.

After trying several tricks mentioned here, this seems to have finally worked for me:

  1. Close the project,
  2. Rename the project folder in Finder (i.e. the folder containing the .xcodeproj file)
  3. Double click the .xcodeproj file to open the project.

It seems that paths stored in local cache files can be stubborn about being updated.

GreenAnt
  • 1
  • 2
0

I recently had this issue and the resolution was to:

  1. Rename the class in your .xib file to anything other than what you have: [1]: https://i.stack.imgur.com/Xrbqc.png
  2. Close Xcode
  3. Reopen Xcode
  4. Open the Assistant editor

If the issue persists, close Xcode again after renaming your .xib class back to the correct name and open it again.

Hope this helps!

l1ght80x
  • 1
  • 1
0

I just took the current ViewController and copied its contents to another view controller and created a new File for the controls and connected it.

-1

There must be a bug in Xcode. I am learning how to use it and have noticed a few bugs. In order to fix this:

  1. Click the View Controller you are having issues with.

  2. Click on the ID card (The Identity Inspector) in the inspector pane.

  3. Under Custom Class, next to class, type in the class you want to connect it too.

  4. Then save your project and close it out.

  5. Reopen your project.

The assistant editor should pop up and be working. This happens every time I click it and click out of it. It's quite annoying.

-2

Just add your UIViewController in Identity Inspector just like this:

אורי orihpt
  • 2,358
  • 2
  • 16
  • 41
Gowtham Sooryaraj
  • 3,639
  • 3
  • 13
  • 22
-2

The problem for me was that I had unselected the Target Membership. Undoing (Cmd Z) didn't help.

Go to Source Control > Discard all changes.

Screenshot Source Control XCode

Hopefully you use source control and commit frequently. Otherwise this lesson will teach you do so...

Raphael Pinel
  • 2,352
  • 24
  • 26
-2

1- Select the broken ViewController on the StoryBoard

2- In Identity Inspector, change the item in Class to another class (any class)

3- Change the Class back to related class

4- Save and close the project

5- Reopen the project