Beispiel #1
0
 //Copes a directory into the XCode project as a framework -- the directory is referenced directly
 //as a framework, its contents are not directly referenced.
 protected void AddFrameworkDirectory(DirectoryInfo srcDir, string destDir, XcodeObject parentGroup)
 {
     //Create XCode file ref
     XcodeObject fileRef = new XcodeObject(UniqueIds);
     fileRef.literals["isa"] = "PBXFileReference";
     fileRef.literals["name"] = "\""+Path.GetFileName(srcDir.Name)+"\"";
     fileRef.literals["path"] = "\""+srcDir.Name+"\"";
     fileRef.literals["sourceTree"] = "\"<group>\"";
     fileRef.literals["lastKnownFileType"] = "wrapper.framework";
     //Add to group
     string fileRefId = GetNewUniqueId(fileRef);
     parentGroup.AddLiteralListElement("children", fileRefId);
     //Create Xcode build file ref
     XcodeObject buildFile = new XcodeObject(UniqueIds);
     buildFile.literals["isa"] = "PBXBuildFile";
     buildFile.literals["fileRef"] = fileRefId;
     string buildFileId = GetNewUniqueId(buildFile);
     //Add build reference to resources phase
     MainTargetFrameworkPhase.AddLiteralListElement("files", buildFileId);
     //Copy framework contents
     DirectoryInfo frameworkDir = new DirectoryInfo(Path.Combine(destDir, srcDir.Name));
     ExternalProcesses.RunProcess("cp", "-a \"" + srcDir.FullName + "\" \"" + frameworkDir.FullName+ "\"");
     //Add path of framework's containing directory to search paths
     AddFrameworkSearchPath(frameworkDir.Parent.FullName);
 }
Beispiel #2
0
 //Copies a directory and its contents into the XCode project recursively and adds it to the main target.
 protected void AddDirectoryRecursively(string sourceDir, string destDir, XcodeObject parentGroup)
 {
     DirectoryInfo sourceDirInfo = new DirectoryInfo(sourceDir);
     //Create files
     foreach(FileInfo file in sourceDirInfo.GetFiles()){
         if(IsIgnored(file.Name)){
             continue;
         }
         else{
             AddFile(file, destDir, parentGroup);
         }
     }
     //Recurse
     foreach(DirectoryInfo subDir in sourceDirInfo.GetDirectories()){
         if(IsIgnored(subDir.Name)){
             // ...
         }
         else if(IsBundle(subDir.Name)){
             AddBundle(subDir, destDir, parentGroup);
         }
         else if(IsFrameworkDirectory(subDir.Name)){
             AddFrameworkDirectory(subDir, destDir, parentGroup);
         }
         else{
             XcodeObject groupObj = null;
             DirectoryInfo destSubDir = new DirectoryInfo(Path.Combine(destDir, subDir.Name));
             //Set up the dest directory
             if(!destSubDir.Exists || parentGroup.GetGroup(destSubDir.Name) == null){
                 destSubDir.Create();
                 //Make containing Xcode group
                 groupObj = new XcodeObject(UniqueIds);
                 groupObj.literals["isa"] = "PBXGroup";
                 groupObj.literals["sourceTree"] = "\"<group>\"";
                 groupObj.literals["children"] = "()";
                 groupObj.literals["path"] = "\""+destSubDir.Name+"\"";
                 string groupObjId = GetNewUniqueId(groupObj);
                 parentGroup.AddLiteralListElement("children", groupObjId);
             }
             else{
                 groupObj = parentGroup.GetGroup(destSubDir.Name);
             }
             AddDirectoryRecursively(subDir.FullName, Path.Combine(destDir, subDir.Name), groupObj);
         }
     }
 }
Beispiel #3
0
 protected void AddFile(FileInfo file, string destDir, XcodeObject parentGroup)
 {
     string filePath = Path.Combine(destDir, file.Name);
     if(!File.Exists(filePath)){
         //Create XCode file ref
         XcodeObject fileRef = new XcodeObject(UniqueIds);
         fileRef.literals["isa"] = "PBXFileReference";
         fileRef.literals["name"] = "\""+file.Name+"\"";
         fileRef.literals["path"] = "\""+file.Name+"\"";
         fileRef.literals["sourceTree"] = "\"<group>\"";
         //Add to group
         string fileRefId = GetNewUniqueId(fileRef);
         parentGroup.AddLiteralListElement("children", fileRefId);
         //Create Xcode build file ref
         XcodeObject buildFile = new XcodeObject(UniqueIds);
         buildFile.literals["isa"] = "PBXBuildFile";
         buildFile.literals["fileRef"] = fileRefId;
         string buildFileId = GetNewUniqueId(buildFile);
         //Add build reference to appropriate build phase
         if(IsSource(file.Name)){
             MainTargetSourcePhase.AddLiteralListElement("files", buildFileId);
         }
         else if(IsArchive(file.Name)){
             MainTargetFrameworkPhase.AddLiteralListElement("files", buildFileId);
             AddLibrarySearchPath(destDir);
         }
         else if(!IsHeader(file.Name)){
             MainTargetResourcePhase.AddLiteralListElement("files", buildFileId);
         }
         if(EnableBfgAutomaticReferenceCounting && UsesAutomaticReferenceCounting(file.FullName)){
             var settingsObj = new XcodeObject(UniqueIds);
             buildFile.children["settings"] = settingsObj;
             settingsObj.literals["COMPILER_FLAGS"] = kAutomaticReferenceCountingFlag;
         }
     }
     else{
         Console.WriteLine("Overwrote file " + filePath);
     }
     //Copy disk file
     file.CopyTo(filePath, true);
 }
Beispiel #4
0
 //Adds a directory to the XCode project as a bundle -- the directory is referenced directly as a file, its contents are copied unreferenced
 protected void AddBundle(DirectoryInfo srcDir, string destDir, XcodeObject parentGroup)
 {
     //Create XCode file ref
     XcodeObject fileRef = new XcodeObject(UniqueIds);
     fileRef.literals["isa"] = "PBXFileReference";
     fileRef.literals["name"] = "\""+srcDir.Name+"\"";
     fileRef.literals["path"] = "\""+srcDir.Name+"\"";
     fileRef.literals["sourceTree"] = "\"<group>\"";
     //Add to group
     string fileRefId = GetNewUniqueId(fileRef);
     parentGroup.AddLiteralListElement("children", fileRefId);
     //Create Xcode build file ref
     XcodeObject buildFile = new XcodeObject(UniqueIds);
     buildFile.literals["isa"] = "PBXBuildFile";
     buildFile.literals["fileRef"] = fileRefId;
     string buildFileId = GetNewUniqueId(buildFile);
     //Add build reference to resources phase
     MainTargetResourcePhase.AddLiteralListElement("files", buildFileId);
     DirectoryInfo bundleDir = new DirectoryInfo(Path.Combine(destDir, srcDir.Name));
     AddBundleContentsRecursively(srcDir, bundleDir);
 }