Problem renaming xcode classes - objective-c

i'm trying to rename my classes in iOS project in xcode but i cant.
If i try to rename the file in navigator, or if i make refactor -> rename on class name in .h file, it replace all except .h and .m file, it say me:
"Unable to rename oldName to newName, oldName couldn't be moved to appName"
How can i solve this?
Thanks.

Type in the name of your project in the finder, and locate the class files and header files inside that. Try renaming it through that

Related

Xcode autocomplete broken for .mm files

Since there's no way to directly create .mm (Objective-C++) files in Xcode, I just create a CocoaTouch Class with Objective-C and rename the .m file to .mm file. However it seems the code autocomplete functionality is completely broken for .mm files, for example after I type "NS" I expect a list of "NSArray", "NSString", "NSLog", etc. etc. to show up, but now it only shows some code snippet shortcuts like "nsenum" and "nsoptions". If I rename the extension back to .m, the autocomplete works correctly again.
Now I wonder if there's some setting in Xcode to make the code autocomplete functionality work correctly for .mm files? So far I have not found any relevant setting, and keep renaming the extension back and forth between m and mm is really tedious after a while.

Accidentally deleted Bridging-Header.h file

I accidentally deleted Bridging-Header.h file from my project and move to trash. Now if i am running the app it is showing an error "Bridging-Header.h' does not exist"
Select the project in the project navigator
Select the target in the project window
Select Build Settings
Type bridg in the search field
In the line Objective-C Bridging Header memorize file name and path.
Press ⌘N
Create new Header File for the proper platform
Name it according to the memorized file name and save it to the memorized path.
And you are strongly encouraged to use Source Control. It's worth it ...

Is it possible write some code that forces xcode to save all or specific files?

I'm trying to make a plugin that writes something to the .h file with a key command (⌥ + c) while I'm coding in the .m file, e.g. I'm writing a method I want to be exposed, I press my key command at the end of the line, and it automatically writes it in the .h file without me having to copy and paste it over.
If I've just made a change in the .h file and go to my .m file and use my plugin directly after, I get an error popup saying that Xcode has changes that is not on the disk yet, and then asks which version I want to use, the one on the disk or the one in Xcode.
If I'm only coding in the .m file and adding the methods and properties to the .h file with my plugin it works fine (because I haven't made any changes to the .h file manually it seems), it's only when I've just made some changes myself to the .h file and go back to the .m file and use my plugin directly after that I get an error.
If I'm changing something in the .h file and then press ⌘+s and go over to my .m file and use my plugin it also works as intended because I force it to save whatever is in the .h file now. But pressing the ⌘+s command from the .m doesn't help my case, so it seems to only save the current file you're working on, be it the .h file or the .m file.
So my question is, is it possible to make some lines of code which forces Xcode to save all files (or just the .h file if that's possible, I have the, I have the filename and the path), so I'm sure Xcode and the data on hard disk matches up before the plugin makes any changes to what is already on the hard disk?

How do I make Xcode open .h first rather than .m files?

When creating a new class in Xcode the default behaviour is to open and display the implementation file (.m). How do I make Xcode open the header (.h) file first? I often find myself often needing to alter the .h file first to change things such as member variables, properties and inheritance.
As you add a new class, the first file that gets added is .h and last file is .m.
And XCode opens the latest file for you which is .m. Now you want to make it reverse, which is not possible unless some tweak or hack, but the best practice would be to use Ctrl+Cmd+Up or Down to switch between .h and .m

How to duplicate a .xib file?

I see there's no "duplicate" when I right click on a .xib. So is the way to do it: just to go to finder, copy the file to another name, and then drag it to my resources? Would that be all I'd need to do?
[Note: just wondering if there's other files or settings I need to bother with.]
The best way to do this is use cmd ⌘ ,shift, s on the xib or storyboard. Then save it with a new name or location.
Yes, that's most of what's needed. Make sure to open the nib file and verify that the connections are as you want them to be. It will act like any file you duplicate. Just give it an original name and make sure it's saved in the correct folder before you import it into the project.
yes , you can copy the the contents of the xib file by just (command+c) and paste it into another xib file by using (command +v) but by simply cop and pasting you won't get the references you need to go the properties in xib file there you need to give the class name for which you have created a new xib file and then it will give you the references.