globaloldDelimitersglobalvariablesglobalvariablesRefglobalbakefilesXMLglobalbakefilesXMLRefglobalosxBuildFolderpropertytest:false-- retrieves the files from the xml node including optional conditionsonparseEntry(theElement,theVariables,theConditions)setAppleScript's text item delimitersto" "settheNametovarofXMLattributesoftheElementsetallElementsto{}repeatwithcurrElementinXMLcontentsoftheElementifclassofcurrElementistextthensetallElementstoallElements&(everytextitemofcurrElement)elseifclassofcurrElementisXMLelementandXMLtagofcurrElementis"if"thenif(condofXMLattributesofcurrElementis intheConditions)thensetallElementstoallElements&(everytextitemof(item1ofXMLcontentsofcurrElement))endifendifendifendrepeatsetAppleScript's text item delimiterstooldDelimiterscopy{varname:theName,entries:allElements}toendoftheVariablesendparseEntry-- iterates through the entire xml tree and populates the variablesonparseFiles(theXML,theVariables,theConditions)ifclassoftheXMLisXMLelementorclassoftheXMLisXMLdocumentthenrepeatwithanElementinXMLcontentsoftheXMLtryifclassofanElementisXMLelementand¬
XMLtagofanElementis"set"thenparseEntry(anElement,theVariables,theConditions)endifonerrornumber-1728-- ignore this errorendtryendrepeatelseifclassoftheXMLislistthenrepeatwithanElementintheXMLtryifclassofanElementisXMLelementand¬
XMLtagofanElementis"set"and¬
varofXMLattributesofanElementistheNamethenparseEntry(anElement,theVariables,theConditions)endifonerrornumber-1728-- ignore this errorendtryendrepeatendifendparseFiles-- gets the entries of the variable named theNameongetVar(theName)repeatwithanElementinvariablesRefif(varnameofanElementistheName)thenreturnentriesofanElementendifendrepeatendgetVar-- adds sources from fileList to a group named containeronaddNode(theContainer,fileList)repeatwithlistIteminfileListif(listItemstarts with"$(")thensetAppleScript's text item delimitersto""setvariableNameto(characters3through((lengthoflistItem)-1)oflistItem)as textsetAppleScript's text item delimiterstooldDelimitersaddNode(theContainer,getVar(variableName))elsetellapplication"Xcode"tellproject1settheTargetstotargetssetAppleScript's text item delimitersto"/"setcurrPathtoeverytextiteminlistItemsetcurrFileto"../../"&listItemsetcurrFileNameto(item-1incurrPath)setcurrGroupto(items1through-2incurrPathas text)setAppleScript's text item delimiterstooldDelimiterstrysettheGrouptogrouptheContaineronerrortellrootgroupmakenewgroupwithproperties{name:theContainer}endtellendtrytellgrouptheContainertrysettheGrouptogroupnamedcurrGrouponerrormakenewgroupwithproperties{name:currGroup}endtrytellgroupcurrGroupsetnewFiletomakenewfilereferencewithproperties{name:currFileName,path:currFile,pathtype:projectrelative}repeatwiththeTargetintheTargetsaddnewFileto(getcompilesourcesphaseoftheTarget)endrepeatendtellendtellendtellendtellendifendrepeatendaddNode-- retrieves contents of file at posixFilePathonreadFile(posixFilePath)setfileReftoopen for accessPOSIXfileposixFilePathsettheDatatoreadfileRefclose accessfileRefreturntheDataendreadFileoninit()tellapplication"Xcode"quitendtellsetvariablesReftoareference tovariablessetbakefilesXMLReftoareference tobakefilesXMLsetoldDelimiterstoAppleScript's text item delimiterstellapplication"Finder"setosxBuildFoldertoPOSIXpathof((fold