4

So, I am trying to learn swift and writing code since about 3 months now. It seems that all of a sudden Xcode won't show the code for the selected UIViewController in the storyboard in the assistant editor. This happens very often. I clean the project - no help. I reset content and settings of the simulator - no help. I create new user on the computer and load up my project there and it works great... For a while. Then we are back to square one. Either I am doing something really weird and messing things up, or the Xcode is doing something really weird and messing me up.

Any quick fixes for this?

oyalhi
  • 3,834
  • 4
  • 40
  • 45
  • Do you mean Xcode doesn't autocomplete your code? What code are you trying to use? – Cesare Mar 08 '15 at 09:54
  • No. I open up the assistant editor where xcode shows two windows, the storyboard and the asistant editor. When I click on a label for example, the code for the view shows on the right. Then I can control drag for cratşng an outlet etc. The code window never shows on the right. I cannot create outlets. – oyalhi Mar 08 '15 at 10:05
  • Does this happen with all the projects you create? Can you please upload a demo project? Also did you try deleting all the subfolders of the Derived Data subfolder? – Cesare Mar 08 '15 at 10:07
  • I am working on a single project. It happens to this project. Not immediately but after a while. I don't know why. I try cleaning the project but no luck. I will try deleting the Derived Data subfolder. – oyalhi Mar 08 '15 at 18:21
  • Deleting the derived data worked!!! Thank you!!! – oyalhi Mar 08 '15 at 18:23
  • No problem! That fixes almost everything. – Cesare Mar 08 '15 at 18:52

3 Answers3

10

You can try deleting the project's Derive Data.

  1. Close the project. Note: do not quit the XCode.
  2. Window->Organizer (or, Window->Projects, depending on your version of Xcode)
  3. Find the project.
  4. Delete the Derived data using the "Delete..." button.
Michael Teper
  • 4,591
  • 2
  • 32
  • 49
zedtse
  • 116
  • 1
  • 3
1

The above didn't work for my case. I was similarly not able to view code/classes relating to the View Controller. In my particular case, it appears I might have caused the issue- I turned OFF Indexing because Xcode was running terribly slow and around that time I started getting the issue and the message “No assistant results”.

To resolve this in my case, I turned indexing back ON and set the Assistant editor to “Automatic”.

To turn Indexing On or Off, open up the Terminal using either of the below commands-

Turn Indexing OFF: defaults write com.apple.dt.XCode IDEIndexDisable 1

Turn Indexing ON : defaults write com.apple.dt.XCode IDEIndexDisable 0

From accepted answer regarding Indexing: Stopping xcode from indexing

Community
  • 1
  • 1
user4806509
  • 2,925
  • 5
  • 37
  • 72
0

This didn't work for me however. My assitant editor is still showing "no assiant results" when it's supposed to show the User Interface, even the small circle besides my IBOutlet seems not to be connected.

However, if I bring up the Storyboard in the main(left) window, the code will automatically shows up in the assistant(right) window, and the small circle besides the IBOutlet shows it's connected.

Bonan
  • 709
  • 4
  • 18
  • Same happens to me sometimes. I rebuild the code and the circles come to live. I think xcode is updating in the background and the UI is not updated. However, everything works as expected. Unlike my original question where it doesn't work, you cannot even create a new outlet etc. Deleting the derived data solved the problem. – oyalhi Apr 21 '15 at 06:07
  • I even re-created the project since it's been always like that from the start, didn't work either :( – Bonan Apr 21 '15 at 23:20
  • @Bonan did you manage to fix this problem? If so, how? Thanks – Jordan Aug 01 '16 at 19:11
  • @Jordan No, I couldn't find a solution...still suffering. – Bonan Aug 02 '16 at 04:01
  • @Bonan no problem. I have removed and reinstalled Xcode and copied my existing project into a new project and that has solo my problem. – Jordan Aug 02 '16 at 15:05
  • Sadly the only thing that worked for me was to discard all changes back to the last commit. I *think* it was some errant copy and pasting of a button in IB while my Assistant Editor was on manual and i tried some dragging to connect the button to an action. I *think* this caused the errant hook that essentially made my ViewController to no longer find the code-behind. – drew.. Jul 05 '17 at 00:02
  • If the problem started after renaming the ViewController, first check whether you've changed the *class* name inside the ViewController file as well. – 2apreety18 Aug 10 '20 at 12:30