Xcode is too slow to edit on a large project - swift

Summary:
I have a large Xcode project 50 + scenes with some files with a large number of lines. I have separated the scenes into 15 different story boards. Currently it takes 5 minutes to switch to see the compiler errors/warnings. There are approximately 100 swift files in the project. When I am trying to edit a swift file , the editor hangs and the spinning "beachball" appears for minutes. I have deadlines to finish and editing is just impossible...I have tried clearing derived data and clearing caches...cleaning and restarting. This worked for a while but now makes no difference. I appreciate your help.
I have read that certain coding can affect the parsing during editing. How do I find which bit of my code is at fault?
it is taking me minutes to make a change to a parameter
Version/Build:
I have installed Xcode 9, although I was having similar problems with Xcode 8
Configuration:
I am using a MacBook pro model a1706. 8 gig of Ram, 2.9ghz processor.

The following resolved most Xcode 9 beachball issues for me, and perhaps it will help someone else...
Quit Xcode.
From the Finder, right-click your project (.xcodeproj) file.
Choose "Show Package Contents".
Right-click the "project.xcworkspace" item.
Choose "Show Package Contents".
Open the "xcuserdata" folder, then the ".xcuserdata" folder.
Drag the "UserInterfaceState.xcuserstate" item to the desktop (just in case).
Delete the "UserInterfaceState.xcuserstate" item.
Launch Xcode and open your project.
This resulted in a dramatic performance increase when opening and navigating my large objective-c project (which has 250 xib files, and over 100 source code files). Of course, YMMV.

For Xcode 13, in a project that uses Pods, open right click in .xcworkspace, and select "Show Package Contents". Open xcuserdata and then open .xcuserdatad. Find the file UserInterfaceState.xcuserstate and delete it.

Related

XCode buggily loading images that aren't in my project folder

For some reason, XCode is acting up really oddly. I have been testing XCode's ability to load images with the -hd suffix, and realized that Xcode will load a file "welcomeBackground.jpg" regardless of whether it is actually in my project folder.
See, this code below will not crash when compiled. And this is the first screen that is displayed when the app loads. I deleted the file "welcomeBackground.jpg" from my project folder, and XCode still loads the file as if it were there.
This is really freaking me out. Please help?
I am 200% sure I deleted the file from my project folder even and yet Xcode does not crash on line 35.
EDIT: To repeat, things I have tried/checked
- Cleaned project
- Deleted Derived Data
- Checked for hidden files in project folder
- Deleted app from iPhone and re-run from XCode
- Deleted the files from my project folder
- Loaded another image "sadhieia.png" and crashed Xcode
because Xcode couldn't find the file (as it does not
exist), and then tried "welcomeBackground.jpg" again
and Xcode somehow finds it.
And yet, the background still loads...
In Cocos2d, if the specified image is not in your folder, it'll not crash. Instead, it'll return nil to your CCSPrite *background.I suggest you Don't use Camelcase for images. Use lowercases or underscores. Try deleting Derived Data. See this for how to delete derived data.
Scroll the project navigator down to the bottom, to "Products," then click the disclosure arrow to show your application.
Right-click the application and choose "Show in Finder" from the contextual menu that appears. A Finder window is displayed containing your application.
Command-click the title of that window; another contextual menu appears. From that, choose the folder "Derived Data." The Finder then displays a window for that folder.
In this window, you'll see a folder whose name is that of your application, followed by a long string of letters. Trash it. If you see multiple folders bearing your application's name, trash them as well.
Rebuild your project. That should take care of the issue.
This might be a slash and burn approach, but it's solved a lot of quirky project-related issues I've experienced in Xcode after attempting to clean.
Clean your project; your image file is still cached in the build folder.

How to reset the Recent Files Only filter in Xcode 4?

The Project Navigator has this nifty filter at the bottom (icon with a clock). When you click it, it only shows the files which have been edited recently.
Problem: There seems to be no way to reset this. My project has nearly 200 source files and I use a lot of them from day to day. So this list is getting bigger and bigger, and therefore less useful over time.
Often I am just done with something and then I'd just want to get rid of these files in the recents filter.
Is there a secret way to reset the filter? Xcode4 must store this information somewhere.
Navigate into the .xcproject or .xcworkspace package using the terminal or open package in Finder. Clear the contents of the <username>.xcuserdata folder.
I had this problem today, and apparently Apple fixed the bug. Just click on the clock icon again to toggle.
For me, restarting Xcode (I'm using 7.2) reduces the number of files shown when the "recent files" filter is on. But I don't know how the files that still remain are determined.

Why is my XIB modified every time I open it in IB?

I click on the XIB via the project navigator. It opens up and immediately changes the icon to gray showing I have unsaved changes. If I save changes, click on a different file and click back to re-open it, more changes. Always modifies on open.
It happens with one XIB file in this project and a couple in another project. I'd love to know why it's happening and what I can do to fix it now and prevent it in the future.
Note: using Xcode 3.2 Build 4C199 with Snow Leopard
Edit: I've added a couple sections which got removed from the XML on one of these open/modifications
<key>outlets</key>
<dict>
<key>addEventTabBarController</key>
<string>UITabBarController</string>
<key>window</key>
<string>UIWindow</string>
</dict>
<key>superclass</key>
<string>NSObject</string>
and
<key>outlets</key>
<dict>
<key>courseTableCell</key>
<string>UITableViewCell</string>
</dict>
<key>superclass</key>
<string>UITableViewController</string>
I wound up submitting this issue to Apple. Their response was unenlightening, and talking about possible optimizations, updating meta data for new version of Xcode and the like.
I tracked 100 versions from clicking off and on the file. As Apple said, it was "optimizing" every time, but each time it simply moved some XML tags around. Never happy with it's own optimizations it moved them around the next time they were opened. I'd consider it a bug with Xcode, annoying, but mostly harmless.
This only happened with old XIBs and either moving the contents into a new XIB file or (what really happened) Storyboards got rid of the issue.
I did not want to use storyboards as suggested in one of the other answers.
Here is an alternative simple/quick fix.
Go to the Interface Builder Document Properties on the inspector when selecting the xib view file.
Then you need to
change "Deployment" to something different from Project SDK, in my case I set it to the latest iOS version (iOS 6 currently).
change the development to something different from "Previous version", in my case I set it to the latest Xcode version 4.5
I run Xcode 4.5.2 on Lion.
Hope this helps.
basic Idea...
XCode stores lots of version numbers of all different sorts of things. If you look at the XML representation of the XIB, you should find that the vast majority of these little changes are in these version numbers.
How it happens...
Whenever you do an update of Xcode, many different things within Xcode (and often inside the SDK) get updated. If you make a change to a XIB file, those version changes get stood in the XIB. So, if you happen to open a XIB file, the version changes get put into that file. As soon as you build or run the app, those changed get saved to the file.
But I haven't update Xcode in a while!
Well, whenever you did your last update, the XIB files will be updated with the new version numbers as you open them, one-by-one over time.
Edit XCode 4 is better now, (maybe), if you're tempted to vote this down then ask yourself, "Have I migrated from XCode 3 to XCode 4 using Versioning?" If no, then you have no idea what you're doing, and please don't vote on this. If you have, you know how bad you suffered, but yes this question is otherwise dead. If you do find yourself opening a legacy project, just recreate it and copy the files.
I don't know the exact answer, but I do know these things will help you find it:
XCode 4 is notorious for screwing things up.
If you put your directory into a Versioning system, (Git), then grab GitBox and save your project to give it a state and create a git repo out of it. The git repo will save the state. Gitbox will visually show you the changes.
After opening it, you'll be able to right-click on that file in GitBox and hit "see difference" or "view changes" or whatnot.
You will be auto-scrolled to the lines. If you can relate the XML to the Xib, you can figure out what changes.
I went from Lion to Snow Leopard, so I don't deal with this anymore.

Xcode 4 no code completion

I have been using Xcode 4 for 2 weeks and I noticed that I don't get code completion macros for if-else and switch statements.
Like this article describes: http://macdevelopertips.com/xcode/xcode-code-completion-macros.html
I had it working in the beginning, but it suddenly stopped.
Have you tried deleting the project's derived data (which contains the project index used by Code Sense)?
To do so, open the organizer (Window -> Organizer), then the Projects tab. Select your project then hit the delete button next to the derived data path (to the right). Confirm and let it re-index your project.

Netbeans does not show my code

I have worked in project for long time but after electricity has cut off and my PC shutdown.
The code in one of my frames not shown correctly, it's showing like this :
I have GUI and its shape is fine. When I run the frame from main interface it works, but as I said the code is corrupted. I don't know why. If any one has any solution for this problem it would be much appreciated.
In your Netbeans IDE,
Open Projects window (Ctrl+1) ,select file-> right click on list select Local History-> Select Local History. It will show all your last edits. you can restore the last updates from there.
In Latest netbeans releases you can directly access this from toolbar, check the below screenshot.I took this from Netbeans 7.3