Xcode 4: how to customize File Templates and Project Templates? - xcode4

In Xcode 3, we worked out (by trial and error) that we could COPY the system templates to a new location (three possible locations, because Apple kept changing it), and customize them.
NB: while writing this question, I discovered most of the answers on StackOverflow on this topic are incorrect :(. Apple changed the locations, most answers give the old locations, which don't work any more.
At Xcode 4.3, Apple broke it all again, and now FILE TEMPLATES CANNOT BE CHANGED by the old method. From trial and error, I've found that you can create NEW file templates (see below), but the existing ones from Apple cannot be replaced.
How do we fix this? Apple's New File templates are simply appalling - they insert fake "copyright" lines, and they don't even follow Apple's own documentation standard, let alone anyone else's :(.

This is only a partial answer to the question, but for anyone else struggling (like me) to work out the "correct" way, here's a workaround that partially works.
Today, with Xcode 4.5.0, the following works:
Customize file/project templates:
Un-hide your Library folder (google if you don't know how, or else do this from Terminal)
Create a folder: ~/Library/Developer/Xcode/Templates (the parent folder should already exist - Xcode4 auto-creates it)
Find your copy of Xcode 4, and right click "Show Package Contents"
Navigate in there until you find the "Templates" sub folder
There are two folders, one for Mac, the other for iPhone
Mac location: [Xcode4.app]/Contents/Developer/Library/Xcode/Templates
iPhone location: [Xcode4.app]/Contents/Developer/Platforms/iPhoneOS.Platform/Developer/Library/Xcode/Templates
Copy/paste the contents into the "Templates" folder you created
CRITICAL: RENAME EVERY SUB-FOLDER OF "File Templates" OR ELSE APPLE WILL IGNORE/REMOVE YOUR TEMPLATES
NB: in step 2 above, you can also ALLEGEDLY create that folder at:
~/Library/Application Support/Shared/Xcode/Templates
...but that never works for me, and the parent folder doesn't exist with new installs of Xcode 4.5, so I suspect Apple is phasing this out? (since they refuse to document it, I'm just guessing)

It seems project templates can be in ~/Library/Developer/Xcode/Templates/Application/Project Templates.
source: https://github.com/AFNetworking/Xcode-Project-Templates

Related

Atom Editor - Open File and treeview works not as expected

I am using ubuntu 14.04 LTS and Atom Editor 1.5.3
If I and click on Open File I want that the dialog window shows the directory of the current file I am working on. However, it always shows the directory Recently Used and I have to click through the folders to get to my project folder. Where can I change this so that the dialog window starts in my project folder?
Also I noticed that the treeview doesnt change if I work on a specific file. So if I have two projects folders called Project 1 and Project 2 and I start with a file from folder Project 1 then I see the treeview of this folder. However, if I open a file from Project 2 and work on this file, the treeview of folder Project 1 remains. How can I make that the treeview always corresponds to the current file I am working on?
As for the first part of your question, this is a bug in atom for the linux version. Someone has suggested a patch but it seems it has not been accepted yet in the main atom version, even if it seems to work (see the discussion). The two commits are here, if you want to try something with them (what would imply something like recompiling atom yourself of course...).
About the second part of the question: I don't think it's possible to let atom switch automatically from a project to another when clicking on a file. But you can use the project manager package, what will allow you to define projects, and to set a root directory for each project and then switch from a project to another manually. The treeview will then fit with the current project.

Why Files misteriously disappear from xcode with this strange symptom?

I use time machine and drop box to synchronize stuffs.
Recently I found that some files are gone.
However, the project compiles just fine as if the file is there. My friend cannot compile though.
This is very frustating. I got to find the missing files and then restore it from time machine and then readd that to xcode. I don't even know what files are missing.
I used dropbox and time machine. Looks like file disappear, the file names becomes "red" in xcode for a while and then poof it's gone. Xcode automatically remove the files from the project. The project still compiles fine which is frustating. If the project doesn't compile, I will know ah this file is missing.
Looks like somehow xcode still have the file but doesn't show it. Files is not on finder either.
What could possibly be the explanation and how to fix that.
I have clean projects to make sure that my computer do not use cached files.
It still compile fines in my computer
The file is still missing in project navigator
My friends' computer that uses the EXACT same files (connected to drop box) cannot compile
For example, xcdatamodeld files are crucial. In my computer it still run fine without that file even though that file is obviously needed. Xcode behaves as if the file is there all along.
My friends' try to compile the project and crash.
Also there is a PNG file. In my computer it runs fine with the icons showing up. In my friends computer the icons doesn't show up at all.
For anyone who still have the problem, in my case Xcode6. It turns out somehow the "Show only files with source control status" and "Show recent file button" is enable. It located in the bottom of left sidebar.
This somehow happen after I update os to Yosemite.
Cheers
Go to the project navigator (top left folder symbol). Files that are not found by XCode are displayed in red. But since your project compiles fine, there should not be any that are required. Now click one of the "missing" files to activate it. Open the utility area on the right side, and show file inspector. Under "location" you find the full path of this file. Probably, your XCode project uses just references to these "missing" files that are stored somewhere else, and not in your project folder.
I had the same problem ..then I added the files explicitly into our project…which resulted into Duplicate Symbols error …we solved that by following….
In Your Project go to targets-
At the bottom Bar of your Targets there are three options..
1.Add Target
2. Validate Settings
3. Build RUle..
Click on validate Settings….it will ask for you to remove the Duplicated files from the project do it…ur project would run fine

iOS - Xcode 4 Missing Files in Project

At some point I must have moved files from one location to another using Finder (not Xcode). Now Xcode constantly complains that the files are missing from the original directory. In the Errors portion of Xcode, under "Project" it lists a dozen or so "Missing files" all labeled in red. How do I let Xcode know that the move was intentional and that these files aren't actually missing?
Just in case anyone else runs into this problem: My project was source controlled. Although I had never committed the project, Xcode was complaining about the non-existence of the moved files in the original directory (the directory I originally had the files in before they were moved). What frustrated the situation was that the files didn't even show up as red in the Project Navigator, Xcode would only complain about their non-existence in the Issue Navigator. To solve the problem, I had to go into my source control program (in my case, Cornerstone) and delete the files from the original directory there. The fact that the project was source controlled was the real issue.
just select the red-highlighted files in the navigator, and press delete. They will be removed instantly, not prompted for 'files or reference'.

Xcode 4 stuck on "Scanning for working copies"

I just archived and submitted a project. When I go back to open the project it hangs on "scanning for working copies." I can navigate around but am unable to view the project files.
It is really just a linking problem.
Select your project and make sure you have 'Identity and Type' open. This is in the right side Editor bar(toggle open and closed with 'View' button).
You can change your Location and Full Path there. You just need to check that your project is linked to the correct directories.
Hope this helps anyone.
Copy and delete the whole file and paste it in some other directory (or I guess you can put in same directory). Now open it again. I also had same problem. Actually my project was in SVN, so I deleted the directory and again checked out the entire file and opened it again. Now at least that error message is gone.
I am also new to xcode(4.3) .. sorry if my english is not good ...
Open up a more trusted Source Control App, like SourceTree, and refresh all of your working copies, then Xcode, will behave.
The problem seems to result from incorrect linking or damage to the version control repository. Other answers suggested deleting the repository or removing it from xcode under the Window -> Organise menu. I suggest you try these options and the suggestions in the other answers. However none of these worked for me and my xcode was still displaying the "scanning for working copies" message and intermittently locking up.
Deleting xcode from the Applications folder and reinstalling it from the app store then importing my project fixed the issue for me. I also suggest you dont use version control for your project unless you really need it.

SubSonic 3 Installation Doesn't Work?

Ok I have following the tutorial here as best I can
http://subsonicproject.com/docs/Setting_up_SubSonic_3.0
As the files you get in the download are nothing like what is shown in the video?? So I am literally just guessing which files to use??
Then I drag the files / folders into Visual studio (As the video shows) and NOTHING happens?? It just adds the files to my solution?? Or adds the folders to my solution as normal files... Nothing gets executed as shown in the video??
I realise Rob has spent a lot of time on this off his own back, and I am trying not to be a whining old women BUT... How are we expected to use it, if the installation video is completely different to the actual files you get in the download AND when you drag the files into VS2008 nothing happens - Which is completely different to the video? My VS does not recognise TT files as being anything special...
I really want to use this new version, as I loved v2.1 but I'm loosing faith
RANT OVER
OK a few places to start:
Are you using Visual Studio Express, if so unfortunately it doesn't support t4 and so won't work with SubSonic 3
Try right clicking on the tt files and clicking 'Run Custom Tool'
If your project is a Website rather than a Web Application Project t4 won't work and you won't see 'Run Custom Tool' in the right click menu. In this case either convert the project or you can use a separate class library project in your solution and add the templates to it, then reference this in your website.
Choose whether you want to use Simple, Linq or ActiveRecord templates. Have a look here to help you choose (you can always change your mind later)
Watch the video for whichever template you've chosen, the setup video you linked to is unfortunately a little dated and I think the template specific ones are much more helpful.

Resources