How can I remove Named Color Set in Xcode completely? - ios

I used named a color set at first and recently I removed it from my assets file. (Due to the lack of support of iOS 10)
But it seems they still exist in my project.
If I set a color with same value as the removed named color in Interface Builder, it notices me the named color is missing.
Does anyone have some solution for this kind of case?
Thanks!

I struggled with this for a while and there seems to be no easy way to delete a namedColour in XCode (yet). Here's how I solved it.
Go to your storyboard and open it as XML.
Scroll down the bottom of the document to see a resources tag.
Inside of that, you should see custom resources like images and namedColour. Simply just delete any namedColor elements that you don't want anymore, and save - you're good to go!
Note: You may also want to search in the XML for any references to that namedColor and delete tag. For example, I would search in my XML for name="Color" and delete any tag that has it.

I inherited a project that used named colors where we wanted to support iOS 10. You won't like this answer but the only way I found to fix it was to go into the xml of the storyboard and do a find/replace on all of my named colors.
You can easily see the xml of the storyboard if you open the Version Editor in the upper right of the project navigator.

This is a (very annoying) bug in Xcode. Here's how you can fix it:
Open the color dropdown and click on Other...
Navigate to Color Sliders (the second icon from the left).
Select RGB Sliders from the dropdown.
Click inside the Hex Color # text field and press Enter.

I just came across this in Xcode 13:
The color doesn't show up in Assets.xcassets but there's an entry in the regular color drop-down menu in the inspector and it's marked as "(Missing)":
This happens if there's a UI element that's still using a color that was deleted.
How to remove the missing color without changing the actual storyboard code manually:
Open the storyboard as source code (right-click -> "Open As") and search for the exact name of the color (without "missing"), in my example that would be "HIghlightColor".
Write down what UI elements are still using the color - it's easiest to just copy their ids.
Open the storyboard again but this time as "Interface Builder - Storyboard".
Go through all of the UI elements that are still using the missing color (you can use the id in the search/Find Navigator!) and change their color to something else.
Repeat step 1-4 for the remaining storyboards.
Once the missing color isn't used by anything anymore, it'll vanish from the list and the storyboards' code automatically, including the entry in the <Resources> tag.

Delete the Asset Catalog in your project:
AssetCatalog
This will delete the missing name, this works for me.

Related

How do you change the icon for an automator app?

I have created a simple application for my Mac using Automator. I am trying to change its icon from the default robot icon, but anything I try does not work. I have tried copy-pasting the image I want using the Get Info technique, but that didn't work. I also converted the image I want as my icon to a .icns file and put it in the resources folder inside the package contents folder for the app. I also renamed that icon to AutomatorApplet.icns. This technique did not work either. Are there any other techniques I can try, or am I simply doing something wrong?
The copy-paste technique actually works. The one thing I realized I missed is to select the image. You need to hit command-a to "select all" before you can copy the image you want to use as your icon. Then to paste the image onto the app/file you want to have the image as an icon for, just select the item and hit command-i. The get info panel opens and you will need to click on the icon on the top left. Hit command-v and your new image should be used as an icon.

Assistant editor(Xcode 7.3) always showing interface file in storyboard , even when I choose manually

Even after deleting derived data many times, and trying other things, I am still facing this problem. Can you help me?
You can try using the shortcut key instead, to open up the assistant editor.
Shortcut key: -
option + click on the file which you want to open up in the assistant editor
Guys I just stop dealing with this problem by changing the settings in xcode 9.2. And now i use Navigation Pane.
Here is how it works :
Ok now if you go to xcode -> preferences -> navigation
and Choose the "Uses Focused Editor" as in the picture below.
Now you can manually select inside the Navigation Pane.
Just click whichever page you would like to change and select in the Navigation Pane.
Here is a few screenshots :
Pictures shows code files but it works with everything you can click in the Navigation Pane.
Try to drag and drop file from the Project Navigator into the path of the Assistant Editor as temporary fix.
You also can click on this icon to bring recent files.
Try to clean your project, clean Build Folder, restart Xcode.
Make sure the view controller in your Storyboard has correct custom class name.
I think I know the problem you're having. I experience it too, but it's intermittent. Sometimes clicking Manual shows me the entire project folder and I can select the editable classes, but other times it only shows the interface versions of them, which aren't editable and cannot have IBOutlets dragged to them (you can tell b/c it'll say internal class and has less code). I have noticed that if I toggle back and forth between Automatic and Manual, I can usually get the editable class to appear. I also will toggle the assistant editor off, select a different View Controller or two on the storyboard, then go back to my original one, turn the Assistant Editor back on, and it starts working again.
There are other discussions of it here, here, and here. This suggestion of turning off indexing sounds intriguing and worth a try if the problem keeps reappearing. UPDATE: This trick with hitting the + and opening a 2nd file, then closing the interface file, worked great when I tried it just now.
Here are pics of how the Automatic side shows the actual file when the Manual side only shows the interface, which says internal next to class:

How i can see in-brower version of XCode reference? Wanna see list of methods

I'm very like lists of methods in web version of reference.
But in Xcode I can't (at least by default) see this beautiful lists.
Can I change style of Xcode built-in reference? Make it show me in-browser version?
in-browser
in-xcode
Well you can't make "it show me in-browser version", but you can get a list down the side:
Note that the fourth icon in the title bar is selected to get the contents.
To open all the subsections you click on the first disclosure triangle, the NSWindowCntroller line, that will collapse everything. Then option-click on it and everything will be expanded.
The divider between the contents list and the content can be dragged, so you can widen the contents list to see the full method names if you wish.
You can click on any entry to jump to that section, but it might not be smooth or fast – you will probably see the Xcode viewer re-parsing the source file! Older versions of Xcode were better, it's since been "improved"...
HTH

How to localize images in iOS if they are set up in a storyboard?

I know how to localize storyboard elements like label, buttons etc. However, I faced a problem where I need to localize the images that were setup in a storyboard in the attribute inspector for the Image View.
Is there a way to localize those without setting those images up in the code, in the viewDidLoad method and calling setImage:[UIImage imageNamed: NSLocalizedString(...)]; ?
Any kind of help is highly appreciated!
I guess I figured it out...maybe not the ideal way of doing it but works for me...
Open image folder in your Project Navigator (panel).
When you click one of the images, on the right (Inspector panel) you'll see the button "Localize".
Clicking on that button gives you a pop-up asking if you want it to be the base (in my case I say yes).
So now in the inspector there're check boxes: Base, language 1, language 2 etc (language n - is the languages you added to your project in the localization settings).
So now if you put a check mark into one of the language check boxes, your image file will have a drop down arrow showing that it has some content inside. If you click that, you'll see how it expands showing the localized files with the name of the language in the () brackets.
However, at this point those files are all the same as the base. So now you need to substitute the base files with the localized ones.
If you right click on the file that needs to be localized, say myImage.png(German), open it in Finder, and replace that file with the right one. Important! The name of the file should stay the same!
I'll post the screenshots later, so it's all clear how to do it.
Using Xcode 9.2
you can achieve it easily like the following
1- From Assets
2- Then you will need to change the Direction option AND CHOOSE BOTH
xcode will allow you to add 3 more image for other language resource
3- add your needed image and use it in story board or from code as well

how to find references to a method in xcode 5

I am reading through a very large and complex ios app project, I want to find the places in the code when a certain function (or method) is called.
I've seen some answers for older xcodes where you can filter your search results to only show you references. But I dont see this option in xcode 5.
so possibly 2 questions:
1- is there a way to enable these search options?
2- are there any other ways to search for all references to a method (or any symbol).
If you click the search icon and the click where it says "In workspace". It should bring across a menu that will allow you to select specific groups and folders. You can also create a "new scope" to use for searching more complex rules.
In Xcode 6, you can open the Find Navigator (⌘-3) then where it says Find > Text > Containing, these items are clickable and you can change it to Find > References > Containing.
Alternatively, with your cursor inside a method you can click the icon in the top left corner of the editor (it looks like four squares) and choose Callers.

Resources