Wraps a Xcode project.
コード例 #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);
            }
        }
コード例 #2
0
        public void TestProjectGeneration001()
        {
            // Create the main project
            string targetName = "MyApplication001";
            XcodeProject project = new XcodeProject(".", targetName);

            project.AddTarget(targetName, PBXProductType.Application);

            project.AddBuildConfigurationSettings("Release", null, "ARCHS", "$(ARCHS_STANDARD_32_64_BIT)");
            project.AddBuildConfigurationSettings("Release", null, "SDKROOT", "macosx");
            project.AddBuildConfigurationSettings("Release", null, "GCC_VERSION", "com.apple.compilers.llvm.clang.1_0");
            project.AddBuildConfigurationSettings("Release", null, "MACOSX_DEPLOYMENT_TARGET", "10.6");
            project.AddBuildConfigurationSettings("Release", null, "GCC_C_LANGUAGE_STANDARD", "gnu99");
            project.AddBuildConfigurationSettings("Release", null, "GCC_WARN_64_TO_32_BIT_CONVERSION", "YES");
            project.AddBuildConfigurationSettings("Release", null, "GCC_WARN_ABOUT_RETURN_TYPE", "YES");
            project.AddBuildConfigurationSettings("Release", null, "GCC_WARN_UNUSED_VARIABLE", "YES");

            project.AddBuildConfigurationSettings("Release", targetName, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym");
            project.AddBuildConfigurationSettings("Release", targetName, "COPY_PHASE_STRIP", "YES");
            project.AddBuildConfigurationSettings ("Release", targetName, "INFOPLIST_FILE", "../../Info.plist");
            project.AddBuildConfigurationSettings("Release", targetName, "PRODUCT_NAME", "$(TARGET_NAME)");
            project.AddBuildConfigurationSettings("Release", targetName, "WRAPPER_EXTENSION", "app");
            project.AddBuildConfigurationSettings("Release", targetName, "ALWAYS_SEARCH_USER_PATHS", "NO");
            project.AddBuildConfigurationSettings("Release", targetName, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

            project.AddFile("Files", "MyApplicationAppDelegate.h", targetName);

            project.AddFile("Files", "MyApplicationAppDelegate.m", targetName);

            project.AddFile("Files", "Wrong.h", targetName);

            project.RemoveFile("Files", "Wrong.h", targetName);

            project.AddFile("Files", "main.m", targetName);

            project.AddFile("Files", "MyApplication-Info.plist", targetName);

            project.AddFile("Files", "en.lproj/MainMenu.xib", targetName);

            project.AddFile("Files", "fr.lproj/MainMenu.xib", targetName);

            project.RemoveFile("Files", "fr.lproj/MainMenu.xib", targetName);

            project.AddFramework("Frameworks", "Cocoa", targetName);

            project.AddFramework("Frameworks", "AddressBook", targetName);

            project.RemoveFramework("Frameworks", "AddressBook", targetName);

            //var frameworks = project.GetFrameworks(targetName);

            project.Save();
        }
コード例 #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);
            }
        }
コード例 #4
0
        public void TestProjectGeneration004()
        {
            // Create the main project
            string targetName = "MyApplication004";
            XcodeProject project = new XcodeProject(".", targetName);

            project.AddTarget(targetName, PBXProductType.Application);

            project.AddBuildConfigurationSettings("Release", null, "ARCHS", "$(ARCHS_STANDARD_32_64_BIT)");
            project.AddBuildConfigurationSettings("Release", null, "SDKROOT", "macosx");

            project.AddBuildConfigurationSettings("Release", targetName, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym");
            project.AddBuildConfigurationSettings("Release", targetName, "COPY_PHASE_STRIP", "YES");
            project.AddBuildConfigurationSettings ("Release", targetName, "INFOPLIST_FILE", "../../Info.plist");
            project.AddBuildConfigurationSettings("Release", targetName, "PRODUCT_NAME", "$(TARGET_NAME)");
            project.AddBuildConfigurationSettings("Release", targetName, "WRAPPER_EXTENSION", "app");
            project.AddBuildConfigurationSettings("Release", targetName, "ALWAYS_SEARCH_USER_PATHS", "NO");
            project.AddBuildConfigurationSettings("Release", targetName, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

            project.BaseDir = "../..";

            project.AddFile("Files", "MyApplicationAppDelegate.h", targetName);
            project.AddFile("Files", "MyApplicationAppDelegate.m", targetName);
            project.AddFile("Files", "Wrong.h", targetName);
            project.RemoveFile("Files", "Wrong.h", targetName);

            project.AddFile("Files", "main.m", targetName);
            project.AddFile("Files", "MyApplication-Info.plist", targetName);

            project.AddFile("Files", "en.lproj/MainMenu.xib", targetName);
            project.AddFile("Files", "fr.lproj/MainMenu.xib", targetName);
            project.RemoveFile("Files", "fr.lproj/MainMenu.xib", targetName);

            project.AddFramework("Frameworks", "Cocoa", targetName);
            project.AddFramework("Frameworks", "AddressBook", targetName);
            project.RemoveFramework("Frameworks", "AddressBook", targetName);

            //var frameworks = project.GetFrameworks(targetName);

            project.Save();
        }
コード例 #5
0
        /// <summary>
        /// Builds the Xcode project and all its parts.
        /// </summary>
        private void BuildXcodeProject()
        {
            IDELogger.Log("XcodeHandler::BuildXcodeProject");

            String name = this.Project.Name;
            String targetName = this.TargetName;
            this.xcodeProject = new XcodeProject (this.OutputFolder, name);
            this.xcodeProject.BaseDir = "../..";

            // Add standard folders
            this.xcodeProject.AddGroup (Constants.GROUP_CLASSES);
            this.xcodeProject.AddGroup (Constants.GROUP_RESOURCES);
            this.xcodeProject.AddGroup (Constants.GROUP_FRAMEWORKS);

            // Set default settings
            foreach (KeyValuePair<String, String> pair in DEFAULT_SETTINGS) {
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, null, pair.Key, pair.Value);
            }

            // Set version setting
            String version;
            switch (this.Project.TargetOSVersion) {
            case MacOSVersion.MacOS105:
                version = "10.5";
                break;
            case MacOSVersion.MacOS106:
                version = "10.6";
                break;
            case MacOSVersion.MacOS107:
                version = "10.7";
                break;
            case MacOSVersion.MacOS108:
                version = "10.8";
                break;
            case MacOSVersion.MacOS109:
                version = "10.9";
                break;
            case MacOSVersion.MacOS1010:
                version = "10.10";
                break;
            default:
                version = "10.6";
                break;
            }
            this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, null, "MACOSX_DEPLOYMENT_TARGET", version);

            // Set project type settings
            switch (this.Project.ApplicationType) {
            case MonobjcProjectType.CocoaApplication:
            case MonobjcProjectType.ConsoleApplication:
                this.xcodeProject.AddTarget (targetName, PBXProductType.Application);
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, targetName, "PRODUCT_NAME", "$(TARGET_NAME)");
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, targetName, "INFOPLIST_FILE", "../../Info.plist");
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, targetName, "WRAPPER_EXTENSION", "app");
                break;
            case MonobjcProjectType.CocoaLibrary:
            default:
                this.xcodeProject.AddTarget (targetName, PBXProductType.LibraryDynamic);
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, targetName, "PRODUCT_NAME", "$(TARGET_NAME)");
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, targetName, "DYLIB_COMPATIBILITY_VERSION", "1");
                this.xcodeProject.AddBuildConfigurationSettings (Constants.CONFIGURATION_RELEASE, targetName, "DYLIB_CURRENT_VERSION", "1");
                break;
            }

            this.xcodeProject.Save ();

            ThreadPool.QueueUserWorkItem(delegate {
                this.AddClasses ();
                this.AddResources ();
                this.AddFrameworks ();
                this.AddProjectReferences ();
                this.xcodeProject.Save ();
            });
        }
コード例 #6
0
 /// <summary>
 /// Clears the Xcode project.
 /// </summary>
 public void ClearXcodeProject()
 {
     this.xcodeProject = null;
 }