Class XcodeProjectWriter

  • All Implemented Interfaces:
    ProjectWriter

    public final class XcodeProjectWriter
    extends java.lang.Object
    implements ProjectWriter
    Writes a Apple Xcode 2.1+ project directory. XCode stores project configuration as a PropertyList. Though it will always write the project as a Cocoa Old-Style ASCII property list, it will read projects stored using Cocoa's XML Property List format.
    • Constructor Detail

      • XcodeProjectWriter

        public XcodeProjectWriter()
        Constructor.
    • Method Detail

      • writeProject

        public void writeProject​(java.io.File fileName,
                                 CCTask task,
                                 ProjectDef projectDef,
                                 java.util.List sources,
                                 java.util.Hashtable targets,
                                 TargetInfo linkTarget)
                          throws java.io.IOException
        Writes a project definition file.
        Specified by:
        writeProject in interface ProjectWriter
        Parameters:
        fileName - File name base, writer may append appropriate extension
        task - cc task for which to write project
        projectDef - project element
        targets - compilation targets
        linkTarget - link target
        sources - source and header files
        Throws:
        java.io.IOException - if error writing project file
      • addDependency

        private XcodeProjectWriter.PBXObjectRef addDependency​(java.util.Map objects,
                                                              XcodeProjectWriter.PBXObjectRef project,
                                                              java.util.List mainGroupChildren,
                                                              java.lang.String baseDir,
                                                              DependencyDef dependency)
        Adds a dependency to the object graph.
        Parameters:
        objects -
        project -
        mainGroupChildren -
        baseDir -
        dependency -
        Returns:
        PBXBuildFile to add to PBXFrameworksBuildPhase.
      • addDocumentationGroup

        private XcodeProjectWriter.PBXObjectRef addDocumentationGroup​(java.util.Map objects,
                                                                      java.lang.String sourceTree)
        Add documentation group to map of objects.
        Parameters:
        objects - object map.
        sourceTree - source tree description.
        Returns:
        documentation group.
      • addProduct

        private XcodeProjectWriter.PBXObjectRef addProduct​(java.util.Map objects,
                                                           TargetInfo linkTarget)
        Add file reference of product to map of objects.
        Parameters:
        objects - object map.
        linkTarget - build description for executable or shared library.
        Returns:
        file reference to generated executable or shared library.
      • addSources

        private java.util.List addSources​(java.util.Map objects,
                                          java.lang.String sourceTree,
                                          java.lang.String basePath,
                                          java.util.Hashtable targets)
        Add file references for all source files to map of objects.
        Parameters:
        objects - map of objects.
        sourceTree - source tree.
        basePath - parent of XCode project dir
        targets - build targets.
        Returns:
        list containing file references of source files.
      • addNativeTargetConfigurationList

        private XcodeProjectWriter.PBXObjectRef addNativeTargetConfigurationList​(java.util.Map objects,
                                                                                 java.lang.String projectName)
        Add native target configuration list.
        Parameters:
        objects - map of objects.
        projectName - project name.
        Returns:
        build configurations for native target.
      • addNativeTarget

        private XcodeProjectWriter.PBXObjectRef addNativeTarget​(java.util.Map objects,
                                                                TargetInfo linkTarget,
                                                                XcodeProjectWriter.PBXObjectRef product,
                                                                java.lang.String projectName,
                                                                java.util.List sourceGroupChildren,
                                                                java.util.List frameworkBuildFiles)
        Add native target to map of objects.
        Parameters:
        objects - map of objects.
        linkTarget - description of executable or shared library.
        product - product.
        projectName - project name.
        sourceGroupChildren - source files needed to build product.
        Returns:
        native target.
      • getProductTypeIndex

        private int getProductTypeIndex​(TargetInfo linkTarget)
      • getProductType

        private java.lang.String getProductType​(TargetInfo linkTarget)
      • getFileType

        private java.lang.String getFileType​(TargetInfo linkTarget)
      • createPBXFileReference

        private static XcodeProjectWriter.PBXObjectRef createPBXFileReference​(java.lang.String sourceTree,
                                                                              java.lang.String baseDir,
                                                                              java.io.File file)
        Create PBXFileReference.
        Parameters:
        sourceTree - source tree.
        baseDir - base directory.
        file - file.
        Returns:
        PBXFileReference object.
      • createPBXGroup

        private static XcodeProjectWriter.PBXObjectRef createPBXGroup​(java.lang.String name,
                                                                      java.lang.String sourceTree,
                                                                      java.util.List children)
        Create PBXGroup.
        Parameters:
        name - group name.
        sourceTree - source tree.
        children - list of PBXFileReferences.
        Returns:
        group.
      • createPBXProject

        private static XcodeProjectWriter.PBXObjectRef createPBXProject​(XcodeProjectWriter.PBXObjectRef buildConfigurationList,
                                                                        XcodeProjectWriter.PBXObjectRef mainGroup,
                                                                        java.lang.String projectDirPath,
                                                                        java.lang.String projectRoot,
                                                                        java.util.List targets)
        Create PBXProject.
        Parameters:
        buildConfigurationList - build configuration list.
        mainGroup - main group.
        projectDirPath - project directory path.
        targets - targets.
        projectRoot - projectRoot directory relative to
        Returns:
        project.
      • createXCConfigurationList

        private static XcodeProjectWriter.PBXObjectRef createXCConfigurationList​(java.util.List buildConfigurations)
        Create XCConfigurationList.
        Parameters:
        buildConfigurations - build configurations.
        Returns:
        configuration list.
      • createXCBuildConfiguration

        private static XcodeProjectWriter.PBXObjectRef createXCBuildConfiguration​(java.lang.String name,
                                                                                  java.util.Map buildSettings)
        Create XCBuildConfiguration.
        Parameters:
        name - name.
        buildSettings - build settings.
        Returns:
        build configuration.
      • createPBXNativeTarget

        private static XcodeProjectWriter.PBXObjectRef createPBXNativeTarget​(java.lang.String name,
                                                                             XcodeProjectWriter.PBXObjectRef buildConfigurationList,
                                                                             java.util.List buildPhases,
                                                                             java.util.List buildRules,
                                                                             java.util.List dependencies,
                                                                             java.lang.String productInstallPath,
                                                                             java.lang.String productName,
                                                                             XcodeProjectWriter.PBXObjectRef productReference,
                                                                             java.lang.String productType)
        Create PBXNativeTarget.
        Parameters:
        name - name.
        buildConfigurationList - build configuration list.
        buildPhases - build phases.
        buildRules - build rules.
        dependencies - dependencies.
        productInstallPath - product install path.
        productName - product name.
        productReference - file reference for product.
        productType - product type.
        Returns:
        native target.
      • createPBXSourcesBuildPhase

        private static XcodeProjectWriter.PBXObjectRef createPBXSourcesBuildPhase​(int buildActionMask,
                                                                                  java.util.List files,
                                                                                  boolean runOnly)
        Create PBXSourcesBuildPhase.
        Parameters:
        buildActionMask - build action mask.
        files - source files.
        runOnly - if true, phase should only be run on deployment.
        Returns:
        PBXSourcesBuildPhase.
      • createPBXFrameworksBuildPhase

        private static XcodeProjectWriter.PBXObjectRef createPBXFrameworksBuildPhase​(int buildActionMask,
                                                                                     java.util.List files,
                                                                                     boolean runOnly)
        Create PBXFrameworksBuildPhase.
        Parameters:
        buildActionMask - build action mask.
        files - files.
        runOnly - if true, phase should only be run on deployment.
        Returns:
        PBXFrameworkBuildPhase.
      • createPBXCopyFilesBuildPhase

        private static XcodeProjectWriter.PBXObjectRef createPBXCopyFilesBuildPhase​(int buildActionMask,
                                                                                    java.lang.String dstPath,
                                                                                    java.lang.String dstSubfolderSpec,
                                                                                    java.util.List files,
                                                                                    boolean runOnly)
        Create a build phase that copies files to a destination.
        Parameters:
        buildActionMask - build action mask.
        dstPath - destination path.
        dstSubfolderSpec - subfolder spec.
        files - files.
        runOnly - if true, phase should only be run on deployment.
        Returns:
        PBXCopyFileBuildPhase.
      • createPBXContainerItemProxy

        private static XcodeProjectWriter.PBXObjectRef createPBXContainerItemProxy​(XcodeProjectWriter.PBXObjectRef containerPortal,
                                                                                   int proxyType,
                                                                                   java.lang.String remoteInfo)
        Create a proxy for a file in a different project.
        Parameters:
        containerPortal - XcodeProject containing file.
        proxyType - proxy type.
        Returns:
        PBXContainerItemProxy.
      • toString

        private static java.lang.String toString​(boolean b)
        Method returns "1" for true, "0" for false.
        Parameters:
        b - boolean value.
        Returns:
        "1" for true, "0" for false.
      • getBaseCompilerConfiguration

        private CommandLineCompilerConfiguration getBaseCompilerConfiguration​(java.util.Hashtable targets)
        Gets the first recognized compiler from the compilation targets.
        Parameters:
        targets - compilation targets
        Returns:
        representative (hopefully) compiler configuration