Beispiel #1
0
        /// <summary>
        ///   Removes the dependant project.
        /// </summary>
        /// <param name = "project">The project.</param>
        /// <param name = "targetName">Name of the target.</param>
        public void RemoveDependantProject(XcodeProject project, String targetName)
        {
            lock (this.syncRoot) {
                // Get the native target
                PBXNativeTarget target = project.GetDefaultTarget() as PBXNativeTarget;
                if (target == null)
                {
                    return;
                }

                // Get the product reference
                PBXFileReference productReference = target.ProductReference;

                // Add a dummy group for references
                PBXGroup referenceGroup = this.AddGroup("References");

                // Find the reference proxy
                String            path           = Path.GetFileName(productReference.Path);
                PBXReferenceProxy referenceProxy = referenceGroup.Children.OfType <PBXReferenceProxy>().FirstOrDefault(r => r.Path == path);
                if (referenceProxy == null)
                {
                    return;
                }

                this.RemoveDependantProject(referenceProxy);
            }
        }
Beispiel #2
0
        /// <summary>
        ///   Removes the target.
        /// </summary>
        /// <param name = "targetName">Name of the target.</param>
        public void RemoveTarget(String targetName)
        {
            lock (this.syncRoot) {
                PBXTarget target = this.GetTarget(targetName);
                if (target != null)
                {
                    this.Project.RemoveTarget(target);
                    PBXNativeTarget nativeTarget = target as PBXNativeTarget;
                    if (nativeTarget != null)
                    {
                        switch (nativeTarget.ProductType)
                        {
                        case PBXProductType.Application:
                            this.RemoveFile("Products", targetName + ".app");
                            break;

                        case PBXProductType.LibraryDynamic:
                            this.RemoveFile("Products", targetName + ".dylib");
                            break;

                        default:
                            throw new NotSupportedException();
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///   Adds the dependant project.
        /// </summary>
        /// <param name = "project">The project.</param>
        /// <param name = "targetName">Name of the target.</param>
        public void AddDependantProject(XcodeProject project, String targetName)
        {
            lock (this.syncRoot) {
                // Get the native target
                PBXNativeTarget target = project.GetDefaultTarget() as PBXNativeTarget;
                if (target == null)
                {
                    return;
                }

                // Get the product reference
                PBXFileReference productReference = target.ProductReference;

                // Add a dummy group for references
                PBXGroup referecenGroup = this.AddGroup("References");

                // Add file reference
                PBXFileReference fileReference = this.AddFile(String.Empty, project.ProjectFolder) as PBXFileReference;

                // Add proxy
                PBXContainerItemProxy itemProxy = new PBXContainerItemProxy();
                itemProxy.ContainerPortal      = fileReference;
                itemProxy.ProxyType            = 2;      // TODO: Find other values
                itemProxy.RemoteInfo           = Path.GetFileNameWithoutExtension(fileReference.Name);
                itemProxy.RemoteGlobalIDString = project.Document.Mapping [productReference];

                // Add reference proxy
                PBXReferenceProxy referenceProxy = new PBXReferenceProxy();
                referenceProxy.RemoteRef  = itemProxy;
                referenceProxy.SourceTree = PBXSourceTree.BuildProductDir;
                referenceProxy.FileType   = productReference.ExplicitFileType;
                referenceProxy.Path       = Path.GetFileName(productReference.Path);

                // Add reference proxy
                referecenGroup.AddChild(referenceProxy);

                // Add association
                this.Project.AddProjectReference(referecenGroup, fileReference);
            }
        }
Beispiel #4
0
        /// <summary>
        ///   Adds the target.
        /// </summary>
        /// <param name = "targetName">Name of the target.</param>
        /// <param name = "type">The type.</param>
        /// <returns></returns>
        public PBXTarget AddTarget(String targetName, PBXProductType type)
        {
            lock (this.syncRoot) {
                PBXTarget target = this.GetTarget(targetName);
                if (target == null)
                {
                    switch (type)
                    {
                    case PBXProductType.Application:
                    {
                        this.Project.ProductRefGroup = this.AddGroup("Products");

                        PBXFileReference fileReference = new PBXFileReference();
                        fileReference.ExplicitFileType = PBXFileType.WrapperApplication;
                        fileReference.IncludeInIndex   = 0;
                        fileReference.Path             = targetName + ".app";
                        fileReference.SourceTree       = PBXSourceTree.BuildProductDir;
                        this.Project.ProductRefGroup.AddChild(fileReference);

                        PBXNativeTarget nativeTarget = new PBXNativeTarget();
                        nativeTarget.AddBuildPhase(new PBXResourcesBuildPhase());
                        nativeTarget.AddBuildPhase(new PBXSourcesBuildPhase());
                        nativeTarget.AddBuildPhase(new PBXFrameworksBuildPhase());
                        nativeTarget.Name = targetName;
                        nativeTarget.ProductInstallPath = "$(HOME)/Applications";
                        nativeTarget.ProductName        = targetName;
                        nativeTarget.ProductReference   = fileReference;
                        nativeTarget.ProductType        = type;
                        target = nativeTarget;

                        break;
                    }

                    case PBXProductType.LibraryDynamic:
                    {
                        this.Project.ProductRefGroup = this.AddGroup("Products");

                        PBXFileReference fileReference = new PBXFileReference();
                        fileReference.ExplicitFileType = PBXFileType.CompiledMachODylib;
                        fileReference.IncludeInIndex   = 0;
                        fileReference.Path             = targetName + ".dylib";
                        fileReference.SourceTree       = PBXSourceTree.BuildProductDir;
                        this.Project.ProductRefGroup.AddChild(fileReference);

                        PBXNativeTarget nativeTarget = new PBXNativeTarget();
                        nativeTarget.AddBuildPhase(new PBXHeadersBuildPhase());
                        nativeTarget.AddBuildPhase(new PBXResourcesBuildPhase());
                        nativeTarget.AddBuildPhase(new PBXSourcesBuildPhase());
                        nativeTarget.AddBuildPhase(new PBXFrameworksBuildPhase());
                        nativeTarget.Name = targetName;
                        nativeTarget.ProductInstallPath = "/usr/lib";
                        nativeTarget.ProductName        = targetName;
                        nativeTarget.ProductReference   = fileReference;
                        nativeTarget.ProductType        = type;
                        target = nativeTarget;
                        break;
                    }

                    default:
                        throw new NotSupportedException();
                    }
                    this.Project.AddTarget(target);
                }
                return(target);
            }
        }