Get rid of file icon shadow when file is not saved in Xcode - swift

When a file was just edited and not saved in the Xcode editor the icon of the file in the right pane is darkened a little, and because I have OCD this drives me absolutely crazy and I end up having to click Ctrl+S every time I do anything as simple as commenting a line of code or moving a button 1 pixel in storyboard.
I am using Xcode 10.1 Beta 2, but this happens in all versions of Xcode.
How do you make it so the file is never darkened?

I have the same problem in Xcode and I always command s everything as well. I have looked for a way to disable this, but for now I don’t think there is a way... Maybe they’ll add a way to turn this off in another update soon :)

Related

Why in Xcode 6 doesn't work Assistant Preview?

Sometimes in Xcode 6 Assistant Editor -> Preview stops working.
Showing just "No selection" even if no errors and Storyboard is ok.
Why does this happen?
The reason is "?" (questionmark) in Project's name (maybe there is a bug with other symbols – didn't check it).
You can try to rename Project or just create new one with name without "?" in it.
You must to Kill Xcode from processes for complete and then open it again. You can do it with Activity Monitor o CLI. Voila! - Preview is working again.
Don't just close Xcode keeping the app working. Sometimes also works closing with CMD + Q.
I had similar problem, but fixed it
You must open the xib or storyboard file in both assistant editors. Click the navigation button in the second editor (either the bottom or the right editor, depending on how you stack the assistant editors) and choose Preview to get the preview to appear.
thanks to
http://meandmark.com/blog/2014/09/xcode-6-no-simulate-document-in-interface-builder/comment-page-1/#comment-2883
I have played with Xcode 6 for a while and I encountered similar problems occasionally. I never used special characters in project or class names but the problem sometimes happens.
Now I have to test all ViewControllers at starting point to see if the Assistant Editor work. If not, I will just delete the class file and recreate the same one, it usually fix the problem.
Hope this can be fixed soon.

My recent changes in NIB file is not displayed in ios simulator-closed

I've applied changes in interface builder for my app which has labels in it. I just changed the name and position of a label and in addition to that I changed the font of a text view in my app. When I started to run my app, the font remains the same as previous one and none of the labels are displayed in it.
Can anyone help it pls?
in Xcode try this: main menu:product:Clean
if not enough: main menu:Xcode:preferences: -> click over locations icon:
click over the little gray right arrow for derived data:
that will show you the finder folder "DerivedData": delete it.
one other thing to try: in simulator, delete your app.
quite your xcode and then again open your project . Clear your build then run your code.
You should also make sure, that the interfacebuilder file is linked to the target you are starting in simulator.
To do this, select your xib and open the File inspector. There you should see a dropdown named "Target Membership" where you can link the xib to the targets you want.
Also be sure to have the labels defined as IBOutlets in your header file and link them correctly in your xib. Easiest way to do this is using the Assistant Editor and drag the outlet to the header file.
I had the same problem - but only on the iPhone non-retina in the simulator. Cleaning the code did not help. Restarting and rebooting did not help. But removing the app from the simulator worked. Now changes to my UI show up next time I run.
To remove the app from the simulator I did it just like on a real phone. I select the app icon with the mouse and hold it down the mouse button for a few seconds. Then the icon displays a small delete icon that you can select (the app icons shakes too).

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.

nslog stopped working in xcode

I have a strange issue and possibly a bug. My NSLog statements have stopped working completely, they do not print even in view did load, application didfinishlaunching etc. The have all turned a brown colour (the same colour as a pragma mark in xcode) and they all have a warning saying 'expression result unused'. Has anyone ever seen this before or know what to do? Am i running in some kind of weird mode? Im running xcode 4.0.2.
Many thanks
Jules
for completeness, I had the same problem and the answer was different, hope it helps someone else who bumps into this post:
I had a framework (an Amazon one) redefining NSLog, went there (Cmd+Click on the Brown NSLog) and commented out the redefinition...
The actual problem was the release_build set to 1. So it wasn't recognizing nslog, as you said it was set for a release build.
I had the same issue :
what worked for me is given below:
Remove the derived data folder
After removing derived data perform the clean action (You can see this option in the product menu)
Quit the Xcode and start it again.
And this did the trick all my NSLog were working fine.
Hoep this helps
Ensure that scheme chosen corresponds to Debug mode because sometimes the pch file might have some definitions such that logging is done only in the debug mode
(Scheme is on to the left of the place where you select iPhone Simulator / iOS Device)
In the view select Debug Area
(There are 3 view buttons, on the top right hand corner of Xcode, press the center button)
Select "Show variables view and the console"
(In the debug area (bottom) there are ther 3 buttons, press the center button)
I had the same issue and the problem was that I was building an Ad Hoc version (schema was for Ad Hoc build). The warnings disappeared when I built for debug.
Try changing the dropdown menu at the bottom of the console to 'All Output'.
if you are using libraries like 'KScan' or 'iKEA' or 'kdc-scan', so it can happens that, they will call methods like this one 'redirectNSLogToDocuments'.
in my case the object of 'iKEA' call the method 'CheckIfDeviceConnected' and this one redirect all nslog outputs to documents. after commenting out, all nslogs works again :)
hope this will be useful for some one.
some steps :-
1) "Clean all targets" or delete your build and rebuild again.
2) If step 1 doesnt work , reinstall xcode

Xcode's Refactor menu is always disabled

For some reason Xcode's Refactor is always disabled. I used to be able to activate it via selecting a class name and right clicking in the editor to select it. But now no matter what I do, it remains disabled. Any idea what's going on?
Working with Xcode 5, I kept getting "Can't refactor during indexing" when trying to refactor. Rebuilding the index seemed to hang at "Indexing - Waiting for make" forever.
I then noticed that make was already used by another process on my machine (not by Xcode). Shutting this process down enabled Xcode to finally finish indexing
Your project's index might be out of date/corrupt. In the General tab of the Project Settings window, click Rebuild Code Index and wait until it's done.
You can check the progress of the rebuild in the Activity window (Window > Activity).
I just ran into a similar problem in Xcode. I could not refactor anything in the class's .m (implementation file). The only explanation I could come up with is that it was not indexing the file for some reason, and I could not force it to reindex. The only hack that I found that worked was to copy the file to temporary location, remove it from my Xcode project, copy the file from the temp location back to my project's location, and then re-add the file via Xcode.
None of these suggestions work for Xcode 3.2 - the ONLY way is to select the file you want to rename in the left Groups & Files column. THEN highlight the name of the .m or .h in the right code view, then you can right click and select Refactor!
For instance if you're changing the DetailViewController name, highlight the actual DetailViewController.h word in code.
Note, you should also always make sure you've selected the .h file, not the .m
I faced the same thing in Xcode 11. and this worked for me:
I changed iPhone 8 simulator to generic iOS Device and it worked when it is on Generic
I'm new in iOS development,I have met this similar problem.
Xcode:Version 7.1 (7B91b),it looks like Refactor not working:
But when I put my mouse on the red circle point in the following picture,and then the Refactor working.
I think this is a low level mistake,but may be a reference for someone.