Xcode automatically prefixing file names - ios

Since Xcode 6.2 it wants to prefix a filename with its type.
So a "Test" UIViewController now is named:
UIViewController+Test.h,
UIViewController+Test.m
rather than Test.h, Test.m.
I have tried 6.3 and 6.4 beta and they all exhibit this habit. How do you stop it?
Many thanks.

You created a category, not a class.
When you use the “Objective-C File” template, you can create an empty file, a category, a protocol, or a class extension. You cannot create a class using the “Objective-C File” template. Here's what it looks like when you create a category:
To create a class, you need to use the “Cocoa Class” template. Here's what it looks like when you create a class:

It will automatically add the class name as a prefix for categories, if that's what you mean:

Select IOS -> Source -> CocoaTouch Class and the select UIViewController then write your class name Test by removing UIViewController which is alrady present in class name. If you write your class name first then select UIViewController then it will appear attached with your class name

Related

How to add a prefix to a lot of existing swift files and classes in Xcode

I'm working on a project and I created a lot of swift classes. As you know with swift you do not need to add a prefix in front of the class or file name; and so I didn't.
Now I was required to add a prefix to them (let's say "KK" in front of each file and class)
I was wandering if someone managed to do this with a single command, I would like to avoid renaming and refactoring each class one by one.
example:
a file called FridgeView.swift containing a class FridgeView
should be renamed KKFridgeView.swift and the class KKFridgeView
P.S. I know we do not need prefix in swift but it is a requirement of my company I really have no choice :)
Step One Click the Project Name
]1
Then you can find Class Prefix on you right Side
Add your prefix and then Create all you viewController and Class
It can be set from file inspection menu but it will only new files added into project. it will not impact already added files.

Can't find custom controller class in custom class dropdown Xcode 8.3.2

I just started developing for iOS and WatchOS and have encountered a small issue that is probably very simple but I can't find any solution for it.
The issue I'm having is that I'm trying to structure my files in my own way but when creating new controllers, I cannot find them in the Custom Class dropdown on the Interface.storyboard
For example, I renamed InterfaceController.swift to Controllers/InitialViewController.swift to better match what I'm trying to do with my project structure.
For some reason InterfaceController still is showing up on there and if I type in the fullname of the new class, it won't show up. I'm unable to get that class here.
Any help at all would be great, thanks!
Renaming your file will not change the class name. You will have to modify the class declaration inside the file.
class InitialViewController: UIViewController {
/* code for your class */
}
Also, putting your files inside folders (blue folder icon) or Xcode groups (yellow folder icon) will not affect the class name.

How to add "Class Prefix" field while creating xcode project template

I am using a custom template that was defined already by some one. When I use that template, Xcode is not asking for "Class Prefix". Because of this, what ever the classes that are created using this template are having a class name as project name followed by the class name we are giving like "SampleProjectViewController.h" or "SampleProjectViewController.m".
Is there a way to add "Class Prefix" field and use this class prefix, while creating new classes, so that when I create a new class, expected class name would be SPViewController.h or SPViewController.m ?
Add com.apple.dt.unit.prefixable to the Ancestors, it will automatically add the dialog. Then, use ___VARIABLE_classPrefix:identifier___ as a replacement string. Eg. let's say you have a class called Foo:
#interface ___VARIABLE_classPrefix:identifier___Foo : NSObject
#end
#implementation ___VARIABLE_classPrefix:identifier___Foo
#end
Files don't need to have that long prefix, you can simply do that in your Definitions by using something like ___VARIABLE_classPrefix:identifier___Foo.m as the key and Foo.m as the Path (or however your naming works).

Change the Existing class name in xcode

I have xcode 4.5 and I want to add two project's file in my project.
But the problem is - In that two class both class's name are same.
I changed the Class prefix from file inspector but it is changing the newly added file's name.
not my existing class name.
How to change all the existing class name or single class name ?
Select your class name in .h/.m file
Goto Edit->Refactor->Rename
Enter the new name for the class

how to package UIViewController?

I have create a UIViewController, e.g DemoTableViewController, and want to reuse it in other project. Instead of copying source file of controller, I need to create a library to reuse it, however, after I create a static library containing DemoTableViewController, and set the class of a view controller in storyboard, there's a an error:
Unknown class DemoTableViewController in Interface Builder file.
what can I do?
In the custom class field on the right top, you can see that you have given it as DemoTableViewController instead of DemoViewController(Assuming that what you have mentioned in question as DemoViewController is the class name you have given to this custom class). Change that and then check. It should work.
If the above is not working, make sure you have copied the DemoTableViewController.h file to your current project and this library is added to target settings -> Linked frameworks and libraries.

Resources