Xcode 10.1 highlighting off by one (or more) lines in Version Editor for storyboard file - xcode10.1

When I use Version Editor to compare changes, or when committing changes, the changed lines are showing incorrectly (each one is showing offset by one or more lines). Typically I only experience this when opening my storyboard file, rather than code files. Does anyone know the cause and/or how to fix? Thanks
EDIT: This issue persists for me in Xcode 10.2

OK I discovered what had been causing this for me. I had been putting carriage returns into strings in interface builder using CTRL-RETURN, when I should have been using OPTION-RETURN to do so. Changing those removed the issue for me. Still I think this is something that could be handled in a more forgiving and user-friendly way by Xcode.

Related

Eclipse won't compile SWT file properly after SFTP transfer

I was coding earlier today using Textastic 9 on my iPhone today using files I had downloaded over SFTP. I sent them back to my computer (the whole project transferred to my phone), and now three of the four work. They compile correctly, and the colour coding works perfectly. The last one, however, only colour codes specific keywords and strings. It won't accept variable names and anything from a separate library/file, say org.eclipse.swt.SWT.
Here's a screenshot of that file:
Here's another file that also went through SFTP that's working perfectly:
I'm also getting the error Syntax error on tokens, SimpleName expected on a return; statement. I've also tried pasting the code in Notepad, deleting the file, and pasting it into a new file. That doesn't work.
Thanks to #Ros5292
It turns out the display() method had parameters with incorrect capitalisation. I fixed this, clicked on the Design tab, selected the root method, and it compiles. It still doesn't allow me to use other files, color code, etc.
Thanks to #Ros5292
It turns out the display() method had parameters with incorrect capitalisation. I fixed this, clicked on the Design tab, selected the root method, and it works. The colour coding and stuff were messed up due to a few errors because the file was technically new, and it hadn't compiled properly for the first time ever.

Strange behavior of Xcode

I am doing iOS project in Xcode . It was working properly but now it is giving me strange character in place of space.It is also reflecting in all Xcode projects.
why this is happening?
in xCode go to Menu->Editor->Hide invisible Characters
Why is this happening? because sometimes you need to know if your indentation or spacing is correct, or even you want to know if you are using spaces or tabs, then you will Show Invisibles, it maybe useful sometimes

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.

Problems with Xcode Syntax Highlighting

In Xcode 3.2.1 I have this problem where it stops highlighting Objects in purple, and such. For example:
In that example, NSAutoreleasePool, pool, img, size, width and height should be highlighted, however, they are not. Here is a screenshot of what that looks like.
Anyone know how to fix this?
Edit: Also, code sense isn't showing correct options.
Xcode is often glitchy for me in similar ways. Restarting xcode often clears up the issue. Also, sometimes a missing semi-colon or curly brace will keep codeSense and highlighting from working as you want it to. Try Opt-B (build) to see if you have any errors that could be causing this.
I noticed that opening projects from the XCode welcome screen causes this issue. If I dismis the welcome screen and then go file open (or file open recent) and open the project that way the syntax highlighting works

Interface Builder caching bad data (voodoo)

Sometimes IB will hold onto old or bad references, and I cannot seem to remove or edit them.
EDIT I have made this a wiki question with the intention of gathering more data on the phenomenon. Answers involving situations where other coders have encountered this are welcome.
This happened to me again last night with a table controller. When I created a spike project to try and reproduce the error, the system worked the way I anticipated. Then back in the actual project the bad behavior continued, even if I remove the xib file and all controllers involved.
Creating a whole new project with none of the original (problematic) xib and nib files worked correctly.
This question is not about the specifics of this incident but about this type of incident in IB.
Does anyone know more about this type of bad IB behaviour, and possibly a more stylish way to to eliminate it than nuking the project?
Note, removing the offending IB files and recreating them in the same project has not solved this for me in the past, only whole new projects.
Answers regarding examples of when/how this glitch has been observed/created are welcome as well.
I fixed this type of caching problem by clicking File > Read Class Files ... and pointing IB to my class files. Bingo, it read them fine, and everything worked. :-)
The only real suggestion I have is to file a bug report at http://bugreporter.apple.com/ with a reproducible project as the attachment; in my experience Apple do look at these things. That said, you say that re-creating the XIB in the same project didn't fix the bug. What about replacing the other end of the link; i.e. re-create the header file and use that new header with the existing XIB? Perhaps that's sufficient to prod IB into updating its model.
I just had a project where this happened and I was banging my head trying to get it to update properly in IB 3.2 (732). I really did not want to redo the xib from scratch. I tried drag/drop of the *.h files, restarting, reloading everything and it didn't work. I also tried File->Read Class Files which didn't work. Strangely though, File->Reload All Class Files worked like a charm.
I find that File > Read Class Files fixes it for a single nib file, however the nib doesn't remain in Sync with any future changes and the fix doesn't apply to any other files in the project either.
Restarting and/or clean building didn't help either, but new projects are fine. This has been happening to me in Xcode/IB ver 3.2.2 - so far the only solution has been rebuilding the code in a new project.
Maybe not the answer you want, but here it is: Do not use IB! :-)
I had troubles using it too, even when reproducing exactly the steps as described in some Apple docs, trying multiple times from scratch. So after 3 days I just gave up and started doing everything programmatically, implementing my program in half a day. I have never looked back since. I only launch IB occasionally to look at sizes, so I can feed them into my code.
It will probably be less easy to update my GUI over time, but if your story is a real recurrent problem, I'm glad I parted ways with the beast!
When you say old or bad references, do you mean it is trying to link UI elements to outlets or actions in a class that no longer exist? If that is the case then go to the connections panel (cmd-5) and select the object in your nib file. It should show you all the connections. Any where the text is greyed out and have an exclamation mark should be deleted (hover over and click the x).
In IB, you are only connecting to a "promise" of what your class will be like when the app launches. IB normally only lets you connect stuff that can fulfil that promise, but if you change the header in Xcode there's nothing IB can do about it besides warn you.
Try making a clean build of the code and then see if the old references remain in the xib
You don't say if the problem has persisted across restarts, so I think it might be this issue: There is a rare bug in Xcode's build process where sometimes old versions of output files are stuck in the /tmp folder and won't get updated. IIRC, the easiest solution is to clean the target and reboot your computer.
Are you saving the header files? Interface Builder parses the content of your header files on disk, not the unsaved files in Xcode's editor. If you add an outlet to a header file, and switch back to IB without saving first, IB won't see the new outlet.
I had exactly the same problem with IB when I created a new project out of an old one.
I can synchronize IB with the new .h files but IB still gave the removed references (from the old project) when I right-clicked the object ( the class name "MainController" was the same from the old to the new ) even though those references did not exist in the updated code at all.
"You don't say if the problem has persisted across restarts, so I think it might be this issue: There is a rare bug in Xcode's build process where sometimes old versions of output files are stuck in the /tmp folder and won't get updated. IIRC, the easiest solution is to clean the target and reboot your computer." I tried to clean the target but it did not work.
However, once I deleted the MainManu.xib and created a new one (there would be a bit work to design the interface by hand), the old references were gone.
I experienced the same problem. It happens when I open a project made with old Xcode version. Interface Builder does not sync correctly with Xcode. Yes, I can manually update the IB cache with the 'File->Read Class Files...', but even with this method garbage remains. I mean old IBOutlet and IBAction still shows up.
Just had this type of incident and fixed it by using XCode's refactoring to rename classes to different names. Seemed to get stuff restarted.
Reading the problematic class file again has solved this problem for me.
QUICK EASY SOLUTION: - no computer restart, no new project required . . .
Unfortunately none of the suggestions in this post have fixed this issue for me (aside from restarting my computer and then starting a whole new xcode project)
MY SOLUTION...
Anyway, the only other quick fix (that works for me with Perfoce at least), is to back out (revert) my changes in my revision control system. We are using Perforce, and this seems to work just fine.
I didn't have to create a whole new xcode project, no restarting the computer, no restarting xcode even, no manual deleting of files or references, no re-references classes, no click and drag garbage to deal with, no manual settings changes, etc.
DOWNFALL...
If you are walking all around xcode and the IB for a while, and have made a lot of changes, and then all of a sudden the issue occurs... you will then of course lose everything in the files you revert... QQ
glhf
-eric
SIDE NOTE...
this is a pretty bad bug, and definitely consumes a lot of time, especially if its your first time coming across this issue (and I'm sure everyone here realizes, that time is essential to a developer). This is the first time I've ever been disappointed with apple/obj c/xcode (started 2 months ago), and i sense this won't be the last : /