I've done my custom Xcode template. It creates 2 implementation and 3 header files.
I input only 1 name and others are chosen automatically. But when I save these files "Save as" dialog appears. When I create usual Obj-C class using Xcode template there is no such dialog. I want to remove it from my custom template also.
I finally have found an answer.
http://meandmark.com/blog/2011/11/creating-custom-xcode-4-file-templates/
The 5th comment:
This a pretty random find I had, but if you want the save dialog to
only ask WHERE to save the file and not WHAT and WHERE, you must name
one of the fields productName. Hope this saves someone the hours it
took me.
Related
I have a stand alone SPM (local) in my project. When ever I add any new files to this package Xcode does not show the prompt to specify the name. Usually when adding files in a project it requests the location which allows to specify a name. But when adding in a SPM it straight away creates a file with File.swift always.
I don't mind renaming but its just that the header is also having a generic File.swift
//
// File.swift
//
//
// Created by McDuck, Scrooge on 02/06/89.
//
Any work arounds ?
I have tried on Xcode 13.4 as well
#user5381191 I had the same problem. I did some searching and found this answer.
The file you want to edit is located in:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source/Package Swift File.xctemplate. Edit the TemplateInfo.plist.
As a test I just copied the TemplateInfo.plist file from the Multiplatform/Source/Swift File.xctemplate and it worked. EDIT: For some reason it worked, and then stopped working?
Copy the suggested plist text from the link above into your template file and it works!
Once I did that, I get a new file type "Package Swift File" in the New File dialog.
Instead of the standard file dialog, it gives a dialog for entering the file name. Better than before!
Make sure to save your old template file before making your changes, just in case you need to revert.
It doesn't insert the package name in the header. That might be a nice thing to try and get working, but I'm happy with this for now.
Actually it works as promised (according to Apple guidelines).
In this scenario (as shown on demo) a menu command without ellipsis (...), so no dialog expected.
Once file created Xcode enters edit-name mode, so we can specify a file name which we need.
The file hat is different question and can be edited in templates if needed, or not. Usually depends on project and might even not include file name at all, but for default template - yes we need to change it to align.
Tested with Xcode 13.4
I followed this tutorial "Advanced Xcode 9 File Template" to create a more advanced template for XCode. It is explained that you need to create a folder with a specific name for every option variation there is. In the tutorial, there was a dropdown menu and a checkbox.
But what if I only have a checkbox? Following the tutorial, I'd need to create a folder without a name. That's not possible. Thus, I tried it without a folder for that variation (the checkbox identifier is CreateModelAttributeInSection):
When I uncheck the checkbox though, there are no files being generated. It works when I do check the checkbox, however.
What folder do I need to create for the variation "checkbox not ticked"? I can't find a solution.
thank you
After diving in to the default Xcode templates I found one of theirs that also just used a single checkbox, which is the C file template:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/C\ File.xctemplate
Looking at their structure, with nothing selected it reads the template files from the Default directory. With the checkbox checked it'll read from the directory named the same as the Identifier value of the checkbox option.
I have now >45 different versions of xcdatamodel in Xcode, of which 44 of them are no longer required, as I've eseentially gone for the drop/create approach of the entire database. How can I clear these out, without Xcode kicking up a fuss?
See the linked image:
https://www.dropbox.com/s/1bpdhf9bax6iicb/Screenshot%202014-05-23%2013.24.45.png
Note: this approach is waaaaayyyy simpler: https://stackoverflow.com/a/6712191/84783, but if you wanna get up to your elbows with project files, try my steps below.
I think they keep these around for current installations to do model migrations. Sadly I think you have some manual project file hacking.
Make sure you have the model you want set as the current model
Close Xcode
Right click on "Model.xcdatamodeld" in Finder
Choose Show Package Contents
Delete the models you no longer want
Right click on "MyProject.xcodeproj"
Choose Show Package Contents
Open project.pbxproj in a text editor
Search for ".xcdatamodel" and delete entries (Model.xcdatamodel and "Model X.xcdatamodel") no longer in use
Careful not to delete ".xcdatamodeld" files
Hope this helps, Rob
Am a new bie to IOS development. While working with some sample apps, my mac restarted and after opening xcode i found one interface builder file .xib marked as red. Double click on it shows no content at all. I tried deleting and adding it back from xcode but its not working.
I dont see the file in the project directory too, but when i replace it with old file, it says
an item with same name exists
but its not visible in finder.
Any help would be appreciated.
I am not sure what is a clean solution for this but a quick fix/workaround which worked for me is this:
Along with the error message 'an item with same name exists' you must be getting an id/number which is duplicated.
Open the xib file in any text editor (TextWrangler etc.). It is just an xml file.
Search for that number in the xib. You'll find multiple occurrences of that id.
Replace one of the occurrences with another number and make sure the new number you've added is not a duplicate.
Save this file and open in xcode. The error should be resolved.
Right click on one file in the project and it displays the showinfinder . Then it opens project folder in the finder. Check your file whether it is existing in that or not.
I know one can rename a project by slowly double clicking the project name but I was wondering if it's possible to automate that through the command line (any language, possibly Apple Script) ?
Renaming an Xcode4 project is quite easy.
Click on Show the Project Manager to see the top level project file on the left side.
Click on the project name (here DeeTeeSaver will be changed to DeeTeeSaver2) in order to edit it and enter the new name.
It takes a second to let Xcode4 find out which parts have to be changed.
It then displays a dialog which parts will be changed. Simply click on Rename.
That´s it. No need to fondle around with AppleScript.
You might miss important parts inside the bundle.
Greetings from Switzerland, Ronald Hofmann
You will have to manipulate the .xcodeproj file, which is in XML format.
In my build process I have placeholder names that I simply search & replace with a command line app. If you need a generic solution you will have to parse the XML format (which is undocumented but not that hard to grasp).