コード例 #1
0
ファイル: PBXBuildPhase.cs プロジェクト: 408794550/871AR
        public bool AddBuildFile(PBXBuildFile file)
        {
            if (!ContainsKey(FILES_KEY))
            {
                this.Add(FILES_KEY, new PBXList());
            }
            ((PBXList)_data[FILES_KEY]).Add(file.guid);

            return(true);
        }
コード例 #2
0
ファイル: XCProject.cs プロジェクト: 408794550/871AR
        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false)
        {
            PBXDictionary results = new PBXDictionary();
            string        absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
                absPath = filePath;
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                absPath = Path.Combine(Application.dataPath, filePath);
            }

            if (tree.CompareTo("SOURCE_ROOT") == 0)
            {
                System.Uri fileURI = new System.Uri(absPath);
                System.Uri rootURI = new System.Uri((projectRootPath + "/."));
                filePath = rootURI.MakeRelativeUri(fileURI).ToString();
            }

            if (parent == null)
            {
                parent = _rootGroup;
            }

            // TODO: Aggiungere controllo se file già presente
            PBXFileReference fileReference = GetFile(System.IO.Path.GetFileName(filePath));

            if (fileReference != null)
            {
                return(null);
            }

            fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            // Find test target
            PBXNativeTarget nativeTestTarget = null;

            foreach (KeyValuePair <string, PBXNativeTarget> currentObject in nativeTargets)
            {
                PBXNativeTarget nativeTargetObj = currentObject.Value;

                if (nativeTargetObj != null && nativeTargetObj.data.ContainsKey("name"))
                {
                    string name = (string)nativeTargetObj.data["name"];

                    if (name != null && name.Contains("Unity-iPhone Tests"))
                    {
                        nativeTestTarget = nativeTargetObj;
                        break;
                    }
                }
            }

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
                PBXBuildFile buildFile;
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        if (nativeTestTarget == null || !nativeTestTarget.HasBuildphase(currentObject.Key.Split(' ')[0]))
                        {
                            buildFile = new PBXBuildFile(fileReference, weak);
                            buildFiles.Add(buildFile);
                            currentObject.Value.AddBuildFile(buildFile);
                        }
                    }
                    if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0) && File.Exists(absPath))
                    {
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddLibrarySearchPaths(new PBXList(libraryPath));
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        if (nativeTestTarget == null || !nativeTestTarget.HasBuildphase(currentObject.Key.Split(' ')[0]))
                        {
                            buildFile = new PBXBuildFile(fileReference, weak);
                            buildFiles.Add(buildFile);
                            currentObject.Value.AddBuildFile(buildFile);
                        }
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
                        if (nativeTestTarget == null || !nativeTestTarget.HasBuildphase(currentObject.Key.Split(' ')[0]))
                        {
                            buildFile = new PBXBuildFile(fileReference, weak);
                            buildFiles.Add(buildFile);
                            currentObject.Value.AddBuildFile(buildFile);
                        }
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
                        if (nativeTestTarget == null || !nativeTestTarget.HasBuildphase(currentObject.Key.Split(' ')[0]))
                        {
                            buildFile = new PBXBuildFile(fileReference, weak);
                            buildFiles.Add(buildFile);
                            currentObject.Value.AddBuildFile(buildFile);
                        }
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
                        if (nativeTestTarget == null || !nativeTestTarget.HasBuildphase(currentObject.Key.Split(' ')[0]))
                        {
                            buildFile = new PBXBuildFile(fileReference, weak);
                            buildFiles.Add(buildFile);
                            currentObject.Value.AddBuildFile(buildFile);
                        }
                    }
                    break;

                case null:
                    Debug.LogWarning("fase non supportata null");
                    break;

                default:
                    Debug.LogWarning("fase non supportata def");
                    return(null);
                }
            }

            return(results);
        }