globaloldDelimitersglobalvariablesglobalvariablesRefglobalbakefilesXMLglobalbakefilesXMLRefglobalprojectFileglobalosxBuildFolderpropertytest:false-- retrieves the files from the xml node including optional conditionsonparseSources(theName,theElement,theVariables,theConditions)setAppleScript's text item delimitersto" "setallElementsto{}repeatwithcurrElementinXMLcontentsoftheElementifclassofcurrElementistextthensetallElementstoallElements&(everytextitemofcurrElement)elseifclassofcurrElementisXMLelementandXMLtagofcurrElementis"if"thenif(condofXMLattributesofcurrElementis intheConditions)thensetallElementstoallElements&(everytextitemof(item1ofXMLcontentsofcurrElement))endifendifendifendrepeatsetAppleScript's text item delimiterstooldDelimiterscopy{varname:theName,entries:allElements}toendoftheVariablesendparseSourcesonparseEntry(theElement,theVariables,theConditions)settheNametovarofXMLattributesoftheElementparseSources(theName,theElement,theVariables,theConditions)endparseEntryonparseLib(theElement,theVariables,theConditions)settheNameto|id|ofXMLattributesoftheElementrepeatwithcurrElementinXMLcontentsoftheElementifclassofcurrElementisXMLelementandXMLtagofcurrElementis"sources"thenparseSources(theName,currElement,theVariables,theConditions)endifendrepeatendparseLibonparseNode(anElement,theVariables,theConditions)ifclassofanElementisXMLelementand¬
XMLtagofanElementis"set"thenparseEntry(anElement,theVariables,theConditions)elseifclassofanElementisXMLelementand¬
XMLtagofanElementis"lib"thenparseLib(anElement,theVariables,theConditions)endifendifendparseNode-- iterates through the entire xml tree and populates the variablesonparseFiles(theXML,theVariables,theConditions)ifclassoftheXMLisXMLelementorclassoftheXMLisXMLdocumentthenrepeatwithanElementinXMLcontentsoftheXMLtryparseNode(anElement,theVariables,theConditions)onerrornumber-1728-- ignore this errorendtryendrepeatelseifclassoftheXMLislistthenrepeatwithanElementintheXMLtryparseNode(anElement,theVariables,theConditions)onerrornumber-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)tellapplication"Xcode"tellproject1settheTargetstotargetsrepeatwithlistIteminfileListif(listItemstarts with"$(")thensetAppleScript's text item delimitersto""setvariableNameto(characters3through((lengthoflistItem)-1)oflistItem)as textsetAppleScript's text item delimiterstooldDelimitersmyaddNode(theContainer,mygetVar(variableName))elsesetAppleScript'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(getc