When I add a new file in Xcode 6.3.2 I see templates for the .m and .h file but how do you add both at once?
I'm sure there used to be a way of adding both at once.
The option has been moved into the more generic "Cocoa Touch Class" template, which allows you to make the class in either Objective-C or Swift.
Complete the name of your pair of files with the default prefix filled-in for you. Choose the superclass such as NSObject. Choose the Objective-C language. Click the Next button, then choose the folder location where to save your pair of new .h and .m files.
You can do this by add new file and "Cocoa Class"
Related
I'm trying to follow the tips in Apple's I18N and L10N Guide. I have a pre-existing project from which I have (long ago) deleted the Base.lproj folder. Why? Because I have no Main.storyboard or LaunchScreen.xib. Both of those things are handled programmatically.
However I do have a large number of subsidiary storyboards, including a WatchKit Interface.storyboard. When I click the + in the Project (not target) Localizations section, Xcode presents a dialog that lists only the Interface.storyboard file. Not any of the many others.
How can I persuade Xcode to help me localize the other storyboards? Can I do this all manually? As usual, I am sure it is my mental model that needs refinement.
This is an example where configuration yields convention. That is, if you customize your folder hierarchy, Xcode can adapt and implement its naming conventions.
Select storyboard file in left pane (Project navigator)
Click Doc icon (File inspector) in right pane
Click Localize...
This will create a new Base.proj folder inside whatever folder holds the storyboard. If you are like me, you have done lots of folder-factoring. Xcode goes along with this.
Then you go back to the Project Localizations section and click + to add locales. Xcode creates extracts the strings from your storyboard and creates new folders for the corresponding .strings files.
I wanted to create a Constants.h and Constants.m file. I have created the .h file by right clicking on the File Inspector and then creating a new header file for the Constants.h. But how can I create another file, Constants.m?
Instead of creating a .h file by itself, go to File > New > File, and select "Cocoa Touch Class".
This will create a .h and .m file with the same name, the .h file will have the UIKit framework imported (since its a Cocoa Touch class) and the .m file will have the .h file imported automatically.
To create just the .m file
In the status bar, go to File --> New
Choose Source in the left panel
Choose Objective-C FileClick Next on the bottom right
Enter a file name and click Next on the bottom right
Choose a location and click Create on the bottom right
Recently, some revision was done to one of my projects and the project had to be re-imported from SVN. All of the files are there, but I get weird issues when trying to use some of the project files.
For example, when selecting a view in IB, the assistant view would automatically show the associated header file for that view. Now, there is nothing under the 'Automatic' tab in the assistant view.
Also, when trying to #import certain files and create instances of them, xcode returns the error Unknown type name
I seemed to have resolve the issue. I had to create a new .h and .m file and copy the contents of the old .h and .m into the new one. Once I set the view in storyboard to use this file I no longer received any errors.
When I am editing an XIB in XCode I don't get the associated .h file to show up in the assistant editor window. Other XIB's work fine.
This is a problem as it's the way I create outlets by dragging onto the assistant window. If I open the .h file manually in another window I can't associate an outlet this way either. The .h file exists.
Also, my project is MonoTouch and therefore I invoke the opening of the file from MonoTouch. I assume it's a problem originating in MonoTouch and not Xcode.
Someone please help, or I will be forced to learn Objective C soon and quit with this MonoTouch business.
Sometimes there is a different solution, such as when the controller file is RENAMED.
When this happens, edit the .XIB file with the Source Control Editor (right click on .xib, Open With->Source Control Editor), and make sure that all references to the name of the controller are correct and that the path and name of the .h file are correct.
Look in the "IBClassDescriber" element specifically. The "className" under the "IBPartialClassDescription" element and the "minorKey" under the "IBClassDescriptionSource" element must be correct. MT will generate a .h file with the same name as the controller.
After making the changes, save the file, choose Build->Clean All, then double-click the .XIB file to open it in XCode.
It may or may not work for you, but it worked for me when everything else failed.
As Stuart mentioned in his comment, deleting the /obj folder under the project which contains the .xib files, force MT to regenerate .h files
Came across the same issue and removing the /obj directory and restarting did the trick.
MonoDevelop 3.0.3.5 with XCode 4.4.
Was rather confusing as I am came across issue whilst on first MonoDevelop iOS Helloworld tutorial.
In my case, this issue has appeared when I change a namespace in .cs view controller file according to the file location. But after that, I caught this issue. When I have returned namespace to incorrect variant I got back my .h file.
Update:
You need to change the namespace in view.cs and in view.designer.cs, then Xcode .h file will be generated correctly.
I have added a normal file, and in the .h file I've added the following code:
-(IBAction)PushButton;
My problem is, the action doesn't appear in the xib file when I go into "File's Owner".
I only have the problem with my "A" files. It works perfectly fine in the "M" files.
Any ideas?
May you have not set the class name in the xib