No Assistant Results - ios

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.

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.
Clear Derived Data. Go to Terminal and enter this: rm -rf ~/Library/Developer/Xcode/DerivedData
Quit the whole Xcode.
Close all tabs of Xcode and make sure to view some class files instead of Interface builder and go try again viewing assistant results.
Remove the assigned class to the View Controller nib you think causes the problem, then assign the class again. Boom! Solved!

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

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

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

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.
I hope this solves your issue.

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.

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

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.

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.

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

The same problem happened to me.
I only have to restart Xcode (12.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.

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.

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.

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.

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

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

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.

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.

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

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

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.

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.

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.

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.

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.

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.

Try this (XCode 13.2.1):
In Storyboard, select the object whose class definition you want to
bring up in the assistant editor.
Delete the custom class in the Identity Inspector, being sure to
press the return key to lock in the change.
Quit XCode and reopen.
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.

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

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:
Close the project,
Rename the project folder in Finder (i.e. the folder containing the .xcodeproj file)
Double click the .xcodeproj file to open the project.
It seems that paths stored in local cache files can be stubborn about being updated.

Related

Cannot preview in this file - active scheme does not build this file : SwiftUI on Xcode 11 in CatalinaOS

I opened Landmark App using SwiftUI on Xcode 11 in macOS Catalina(10.15) and while opening the Canvas Editor for .swift files containing SwiftUI is showing
Cannot preview in this file - active scheme does not build this file
Try Again, Diagonistics option or restarting Xcode not solving the problem.
If this is a new project coming from a copied folder and inside an iCloud folder, just close Xcode and relaunch it. The sync was not yet done.
Select the Scheme that has the current file to Preview
You should go through Xcode and Apple SDKs Agreement and you can do it by running the following in terminal in mac:
sudo xcodebuild -license
After doing that reopen your project.
I experienced the same issue. All I did was to copy the "StartingPoint" folder out of the downloaded folder and relaunched the project. It worked!!!
I bumped into this too, following the Landmarks tutorial. When I created the 'CircleImage.swift' it was not letting me preview it, with the above error message.
You can see the current Scheme you're using by going to Product > Scheme. I've got macOS selected.
Clicking on the CircleImage.swift file loads it, and in the rightmost sidebar it shows the Attributes inspector. A few buttons to the left of that is "Show the File inspector".
There, you can see this file's chosen "Target Membership". My problem was that "Landmarks (macOS)" was not checked. Checking this immediately got the Preview working.
I imagine I could also have changed my Product's Scheme to iOS and it would have worked, as that was already checked.
I encountered the same error for some of my SwiftUI View files when trying to preview on Canvas. What fixed the issue was I copied the code within the current file, deleted the file, created a new SwiftUI View file under the same name and pasted the original code. Hope that helps!
Creating a new folder in Documents/Desktop and copying the files over also resolves the issue.
This problem happened to me when I copied a folder into my project with the "Create folder reference" option instead of the "Create groups" option.
The problem was solved when I deleted the folder from project and copied the folder again with the latter option.
I just upgraded to both Monterey 12.3, and Xcode 13.3, and boom ran into this issue. Things were fine before the upgrade. Nothing above helped.
Creating a new project does help. So the only thing I found is to create a new project, and just add the files from the old project to the new one. Yuk.
EDIT: I hadn't rebooted the computer (mac mini), after reboot things were fine again.
In the schemes I was able to select, it contained only one scheme. Reopening the folder in a folder that's not in the Downloads directory made live editing work for me
Restarting my PC worked for me.
The described issue happened to me after cloning a project via git (no iCloud syncing as described in another answer - so I definitely know that the sync itself was completely done).
Funny enough restarting Xcode did the trick.
Just closing and opening the project isn't enough.
I found that the file I was trying to preview was not listed in Target -> Build Phases -> Compile Sources. Once I manually added the file, Preview worked. I had drag and dropped a directory into the project, and for some reason Xcode had not added those files to that list.
Try About this mac -> Storage -> Manage -> Developer, Then delete Xcode cache from here then restart Xcode...This worked out for me
Make sure the file you are trying to preview is in your app (the folder with the same name as your project).
I was able to fix newly created files not previewing by moving the file into my project.
Another solution:
Make sure you select file type Swift UI instead of Swift File when you create the file.

Xcode 8 can't open Model.xcdatamodeld

I am running macOS Sierra (Build 16A320), using Xcode 8.0 (8A218a) and have migrated all my code to Swift 3.
I can't open my Model.xcdatamodeld file anymore. Selecting it in the project navigator does not open up the "Core Data Model editor" view (not sure what it is called). I have tried restarting Xcode, but it does not work. I have tried deleting derived data, cleaning, does not work. I have tried double clicking, does not work.
Model.xcdatamodeld is visible in the Project navigator view, but it is not possible to interact with it (other than right clicking), nothing happens when I click or double click on it.
EDIT: Problem solved, see my answer below
Okay so I solved it... Hmm not sure why but seems like some part of the Swift Migration guide messed up the Model.
SOLUTION:
Remove the model from the project (was not even asked about trash or
reference, but delete reference if asked of course).
Re-add the file
This resulted in this Git change (screenshot from SourceTree):
As you can see, the Model.xcdatamodel (note difference vs Model.xcdatamodeld) file was missing! I guess it somehow got messed up during the -> Swift 3 migration?
Anyway, now it works! :)

Xcode 6.3 New File Issue

I recently updated my Xcode to 6.3 stable version. When I try to add a new folder (Right Click ViewControllers -> Add Files to ... -> New Folder) it appears in blue color, instead of the default yellow color. And when i Right click the TestFolder -> New File, a blank file is created with out the option to choose a template for the file.
What's causing this problem? Thanks.
Yup, found the reason for this. By default, XCode was selecting "Create folder references" which was causing the problem. I selected the "Create groups" radio button instead as shown in the image below and I got the expected result. Cheers.
I believe this is a bug on xcode 6.3. It doesn't happen to the previous version. And if I may add, drag-dropping a folder to the project also produces a blue folder, inside are files which I can't properly call inside my classes. It doesn't even appear on the New File -> Cocoa Touch -> Subclass if you intend to subclass it.
Edit: Figured out the solution. Select "NEW GROUPS" on the dialog when adding. I didn't noticed it at first since previous xcodes have "NEW GROUPS" selected as default.
This error comes when you update Xcode to new version, When you add a new file or folder,from dragging or add from EDIT option,
the default selected option will be Create folder reference radio which add only reference to that file or folder but not the actual. This problem can be solve by selecting Create Group radio when adding file/folder.
This can solve your problem.
For people wondering how to get Copy Folder Dialog box , Just Drag and drop folders into XCode7 and the popup will appear where you can select either folder reference or create group option.
How do you get "New Folder"?
All I see is
I think this looks like a simple bug. Deinstall and Reinstall Xcode if restarting Xcode and your Mac does not help. Maybe that solves your problem.
Hope that helps :)
Since you are doing add folder it will create folder so that u will see blue and if you do add group you will see default yellow color.It does occurs in previous version too you mightn't have realized at that time

Xcode 6.1 keeps telling me some PartialInfo.plist couldn't be opened

After I upgraded to Xcode 6.1, it kept throwing this exception when I tried to build my existing application. I tried to remove 'MyController' and add back again. But it would throw the same exception with different controller.
could not read data from '/Users/macbookpro/Library/Developer/Xcode/DerivedData/MyApp-
dmhwkhbfbxprhycwjeunwtbbtsxj/Build/Intermediates/MyApp.build/DEV-iphoneos/MyApp.build/MyController-
PartialInfo.plist': The file “MyController-PartialInfo.plist” couldn’t be opened because there is no
such file.
I found the answer. I have to replace all xib files' IBCocoaTouchPlugin to newer version.
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
You can solve it by deleting the content in the DerivedData folder. If you're worried about deleting too many folders, then delete only the folders that start with the name of your current project that you're trying to problem-solve for.
Remember to close XCode before you delete the data
Library/Developer/Xcode/DerivedData/
For me (with Xcode 6.3) this was happening with a file that happened to end in ~iPhone.xib. I changed it end in the all lower-case ~iphone.xib, and problem solved.
This is generally happens when you open old version xibs
nothing to do only click on the xib in file panel its version will automatically changed/updated with newer version.
so also you not need to remember it.
I encountered this problem when I moved my .plist file to a new folder. You have to go into the Targets list (select the top bar on the left vertical menu of Xcode, the one that has the name of your project, and then select Targets on the vertical menu second from the left) and find the Identity section. From there, select the button that lets you specify the new path of the .plist file.
If that doesn't work, then try deleting your project's folder in ~/Library/Developer/Xcode/DerivedData/ and building again.
Several of you have come up with the partial answer.
I believe this issue is related to Apple's "fix" for when XIBs were loading slowly when they referenced custom fonts. They now store the custom font info in a xibnamePartialInfo.plist file in your derivedData folder.
Now if your app contains xibname~iPhone.xib AND xibname.xib, only the PartialInfo.plist file for xibname~iPhone.xib gets created and you see the error. Opening the xib in InterfaceBuilder had the side-effect of creating this file which is why the problem appeared to go away (until the next clean).
So the solution is to rename all ~iPhone files to something else (dash works as a replacement for tilde). Apparently its the tilde that is hindering the creation of the PartialInfo.plist file for the root XIB
Common answer for most of question... Restart Xcode. It works for me.

Xcode lost it's code sense?

For some reason my Xcode project doesn't recognize (autocorrect) my code. It doesn't color-code text except for NSStrings (in red). It doesn't autofill things like it used to (e.g. if I would type "CGR" it would put in "CGRectMake:(x,y,width,height)" but not anymore. I don't remember at what point this started happening but it does work in my other projects. Any ideas?
BTW, deleting the derived data doesn't fix it. Nor does creating a new project and importing the files.
this issue has happened to me, I give you 3 sulutions, you can try them.
Solution 1:
Open xcode;
Open Organizer (Xcode-> Window-> Organizer-> Projects)
Select your project and right click, then remove from Organize...
Close xcode and reopen your project.
Solution 2:
Open your project.
Targets -> Building Settings, set Precompile Prefix Header = NO;
repeat solution 1 (Sometimes the Precompile Prefix Header occurs a issue).
Solution 3:
Using commandline.
cd YourProject.xcode
Delete items except project.pbxproj
Good luck.
Hah, figured it out! For some reason my project was split up in different folders. I.E. it was one folder with all the images, another with ViewController.h and another with ViewController.m. Moved all the files to the highest folder in the hierarchy and everything works great :) Thanks for all your help though!
I suppose it would be too easy for your text editing preferences to be wrong? Command-comma -> text editing.

Resources