xcode 8.1 xib editing hang, text editor workaround? - xcode8

So, since updating, the gui randomly hangs editing a xib file. The scenario goes like this:
click an object - i.e, array controller
expand a parameter, Filter Predicate here
Select target object in pull down
try to enter model key path - HANG
In different xib files, the hang comes when trying to enter the model key path textfield. I've also seen errors citing bogus fields like 'Hidden3' for some attribute bindings - only workaround was to remove them.
Has anyone ventured to editing the xml directly, but I guess I can do that in code :-(

Well, I know this is an old question, but I found an answer.
My situation was similar to the one described above: Xcode hanging whenever I edited the key path of any binding in Xcode 8.1. Nothing described here or elsewhere worked.
However, what did work was to edit the storyboard outside of the actual Xcode project: open the offending StoryBoard by itself, do not access it through the project.
This appears consistent with a Sample/Spindump through the Activity Monitor when Xcode hung that showed functions that appeared related to auto-completion/edition. Unchecking auto-completion did not work though (in Prefs).

Related

Why does Xcode autocomplete always put my custom code snippets above actual completions?

I am using some personal Xcode snippets for shortcuts for like dispatching on main queue, or a #synchronized code. They have never interfered with Xcode's autocomplete function with regular methods.
Some time ago I've formatted my Mac, installed Xcode, and re-created the shortcuts the same way I did before:
Ever since, my shortcuts are always before anything else when autocompleting methods containing spaces, as seen below:
The completion for methods should obviously come before my custom snippets.
It also occurs before anything else on property completions either:
They should get listed and highlighted as I type d or dm, or s, sy and so on, just like the default snippets. They shouldn't be at top of everything.
Why would have it changed after the format, and how do I correct this (mis)behavior?
(I am currently on Xcode 9.3 but the problem used to occur before 9.3 too)
UPDATE: The issue still persists on Xcode 9.4.
UPDATE 2: The issue still persists on Xcode 10.1.
Well, there is a new update Xcode 9.4, try with the update because I had the same problem, my solution was delete Xcode and reinstall the latest version, but I think only you need to clear the configuration to return like a first launch.
In the release note for Xcode 9.3 says:
Text in the Code Snippets library filter bar now includes code completion shortcuts. (8147546)
User-defined code snippets now appear at the top of the library, rather than the bottom. (8901028)
You can read full changes here Xcode Releases Notes

Changing class of object in XCode

I am trying to give an object in the interface builder a custom class. When typing in the class name in the Identity Inspector it automatically finishes the line as its already present in the dropdown list of available classes.
However after entering the class the page comes up with a padlock image and clears the class name.
What is the cause of this and how can I rectify it?
firstly, you must reload xcode
if it not work you must have subclass associate with it in IB
Create CustomClass:UITableViewCell then drop UITableViewCell to IB and then just type the name
If dropdown list not display, reload Xcode
Assuming you've specific the right IB object (e.g., a dynamic cell prototype, whose default class is UITableViewCell) and your custom class is defined correctly (as a subclass of UITableViewCell, itself), then I have a couple of thoughts of what you might try:
Sometimes exiting and restarting Xcode is often enough.
Also try selecting "Clean" from the "Build" menu (or press shift+command ⌘+K).
In the worst case scenario, sometimes you have to exit Xcode and delete the DerivedData folder and then restart Xcode. To find the derived data folder, press command ⌘+, (comma) and go to the last tab, "Locations", and click on the arrow next to the "Derived Data" folder:
Having pulled up that folder in Finder, quit Xcode, delete the contents of that DerivedData folder in Finder (after quitting Xcode), and then restart Xcode and try again.
I think I have found the solution (not sure if I have found a fix for the actual problem or just found a way around it)...
I changed the Lock dropdown setting to Nothing and it now allows me to set my own custom class to the Object in the file.
Whats strange is that the document lock was previously set to Inherit (Nothing) anyway so not sure what the difference is here.

xib reference IBOutlet / IBAction not refactored correctly by XCode

Ok, this is a pretty weird error. I have a UIViewController subclass and an associated Xib
It's part of an inherited project built originally by an outsourcer and a lot of properties and methods have badly spelled names, categorys instead of categories, merchantes instead of merchants, don instead of done and so on...
Mostly refactoring these has been straightforward, and XCode's symbol rename refactoring tool has handled them ok.
However with the xib and controller in question, after refactoring, there are some runtime errors, namely this class is not key value coding-compliant and unrecognised selector errors, which both name the old IBOutlet and IBAction names.
When grepping for the names, they don't appear, and searching specifically in the xib as XML source, they also don't show up.
I've worked around this by adding in the two offending symbols, while maintaining the references and all other calls to the corrected names. (ie. the old names don't link to any other code or xib references.)
The question is, why and where are these old symbol names being called?
(note: all IB references have been checked, and the project has been cleaned several times.)
Here's the references in question (correctly mapped in IB.)
And the connections showing in the source view...
Note the old references "navTitleLavel" and "donAction" are the throwing the errors if they're removed from the source, although they do not show as connected in the margin.
Now fixed
(without doing anything, assume a cache held the symbols)
See my answer below, it appears that the symbol references were being cached somewhere, and without additional action the errors are no longer being thrown (when removing the old name references.)
Note, this was resistant to cleaning the project.
I've run into such weird errors before and solved it by
Clean the project (Command + K).
Check every connection in IB so that they do not link to old stuff (don, categorys etc)
Restart xCode. (Really quit the application and restart it)
Hope it helps!
I ran into this problem as well, and a simple clean isn't always enough to get rid of the remaining references which may be in cached files on your device. Make sure to actually delete the app off the iOS device or reset the simulator if a simple clean doesn't solve the problem.
Despite numerous cleans and triple checking that grep, ack, ag and XCode's project wide text search could not find the references throwing the error. The error persisted.
However, this morning I tried again, and lo and behold the ghost references no longer throw the errors.
It appears that there is some sort of nib reference caching which persists after Project Clean, but expires after x time.
Note: the clean operation was run in excess of 10 times, without fixing the error.
I've also updated the question to provide some illustrative detail.

Modifying window style by editing binary?

CyLog’s WildRename is a good program for performing batch-renames on files. The problem with it is that while the main window is resizable, it does not have the maximize box which makes it a little frustrating to size and use. Moreover, they have not made any updates in a long time, so the program is essentially discontinued.
I ran WildRename and used WinSpy++ to modify the style of its window to manually include the WS_MINIMIZEBOX style and bam!, it was now functioning as expected.
The question now is how to make this permanent.
My first instinct was to fire up ResHacker, but the problem is that the style that needs to be modified is that of the main window of a non-dialog application, so ResHacker has no way of doing this.
The next thing I tried was to open it in a hex-editor, to find the address(es) of the string corresponding to the titlebar. I then opened the file in W32Dasm and located the address of the code that references the address of the titlebar string. I did all this in an attempt to find the location of where the main dialog is created so that I can modify the style passed to CreateWindow(). Unfortunately, I cannot find a call to CreateWindow anywhere near the reference to the titelbar string and none of the calls to CreateWindowEx that I can find seem to be (obviously) the ones used to create the main window.
Is there an easy/automated way of modifying the style of the main window (assuming a non-dialog application)?
You could use a debugger like OllyDBG to dump the exe memory after the edit with WinSpy++, then use that exe or compare the files to see where the change is if you want to see what you've missed
There has to be a call to CreateWindow/Ex(), especially if it not a dialog from a resource. You just need to look harder. I would use IDA instead of WinDasm. It will decompile the assembly into more understandable code, and it has a built-in debugger. You can put a breakpoint on the title string and see in real-time which code actually touches it, and then follow it back to the accessing code.

Custom control disappears from object browser

My question is on how custom controls should be updated.
I downloaded this owner drawn custom control, which I built, then copied the DLL to the Debug folder of the project and loaded it into the toolbox from there.
I decided to use this button on another project. I was mildly surprised to see the control was still in the toolbox but it seemed to work just fine. I decided to change this custom button's behavior. The button in the toolbox referenced the old version number. So I deleted it and loaded the newly rebuilt DLL.
Now come the problems. The first application--the one where the DLL was added to the toolbox from--still runs okay, but the second application is throwing errors, saying, Type 'CButtonLib.CButton' is not defined. When I add the button to a form, it appears okay. I can change its properties and it shows up in the code windows and in the object browser. But as soon as I try to run it and it throws the errors, it no longer appears in the object browser. References in the code window lose their intellisense.
Things I've tried include:
Copying the DLL to the project's debug and release folders and loading them into the toolbox from there.
Removing it from the toolbox altogether and just adding a reference then copying and pasting a button directly from the first project.
Copying in a form with a CButton on it from the first project.
Scouring the internet for answers
Swearing at the computer.
Nothing seems to work and I've now spent over a day trying to solve this.
I never did get to the bottom of this. In the end I simply had to recreate the entire custom control project using a different name. I suspect the way I added the original project to the toolbox of a different program – as opposed to adding it within the test project it came with – may have had something to do with it, but that's just a guess. Anyway, I can amend and update the new control without problem now, so all's well that ends well. :-)