You don't need an alias; Xcode does indeed want a file reference. Here's the deal:
The short story:
The correct statement is:
add aFile to aCopy
The long story:
The add command takes a file reference. aFile is a file reference, so you can pass that in. Alternatively, you can say something like:
tell aProject
add file reference "main.m" to aCopy
end tell
or, equivalently:
add file reference "main.m" of aProject to aCopy
When you do that, the command isn't "(add file reference) 'main.m'...", it's "add (file reference 'main.m')...". Saying "file reference 'main.m' of aProject" will find the file reference with that name in the project; you can also find file references by ID (file reference id '29B97324FDCFA39411CA2CEA' of aProject), position (file reference 1 of aProject), filter (every file reference of aProject whose path is "/System/Library/Frameworks/AppKit.framework"), and a number of other ways. What you did was try to find a file reference using a file reference instead of a name, id, filter, etc. If 'aFile' is currently 'file reference 1 of aProject', then 'add file reference aFile to aCopy' really means 'add (file reference (file reference 1 of a Project) of aProject) to aCopy'.
When AppleScript says that it couldn't "make file reference (item 2 of every file reference of project "Test") into type reference", it meant that trying to specify a file reference using another file reference didn't return something it could use as a reference.
This shouldn't do anything. Are you sure this actually made any change to your project?
To finish off, here's a script that should do what you've described. Note that this uses the "file kind" property of a file reference, which currently does not appear in Xcode's scripting dictionary due to a known bug. The "file kind" property is the same value you see in the "file type" popup in Xcode's file inspector.
tell application "Xcode"
set aProject to project 1
set aCopy to copy files phase 1 of target 1 of aProject
repeat with aFile in every file reference of aProject
if (file kind of aFile is "sourcecode.c.h") or (file kind of aFile is "sourcecode.cpp.h") then
add aFile to aCopy
end if
end repeat
end tell
I hope this helps.
- Rick