Esempio n. 1
0
        //@since 3.9.2
        private void AddLocalization(string folderPath, PBXGroup parent)
        {
            PBXFileReference fileReference;
            PBXVariantGroup  newGroup = GetVariantGroup("Localizable.strings", null, parent);

            foreach (string directory in Directory.GetDirectories(folderPath))
            {
                if (directory.EndsWith(".lproj"))
                {
                    DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(directory);
                    string        language            = sourceDirectoryInfo.Name.Split('.') [0];

                    fileReference = GetFile(language);
                    if (fileReference != null)
                    {
                        if (newGroup.HasChild(fileReference.guid))
                        {
                            newGroup.RemoveChild(fileReference.guid);
                        }
                        fileReferences.Remove(fileReference);
                    }
                    fileReference = new PBXFileReference(sourceDirectoryInfo.Name + "/Localizable.strings", language, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), "GROUP"));
                    newGroup.AddChild(fileReference);
                    fileReferences.Add(fileReference);
                }
            }

            foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
            {
                PBXBuildFile buildFile = new PBXBuildFile(newGroup.guid);
                buildFiles.Add(buildFile);
                currentObject.Value.AddBuildFile(buildFile);
            }
        }
Esempio n. 2
0
        public bool AddBuildFile(PBXBuildFile file)
        {
//			if( ((string)file[ ISA_KEY ]).CompareTo( "PBXBuildFile" ) != 0 )
//				return false;
//			Debug.Log( "--> buildphase " + (string)_data[ ISA_KEY ] );


            if (!ContainsKey(FILES_KEY))
            {
//				Debug.Log( "key not present" );
                this.Add(FILES_KEY, new PBXList());
            }
//			Debug.Log( "key: " + _data[ FILES_KEY ] );
//			Debug.Log( "Adding: " + file.guid );
            ((PBXList)_data [FILES_KEY]).Add(file.guid);
//			if( ((PBXList)_data[ FILES_KEY ]).Contains( file.guid ) ) {
//				Debug.Log( "AGGIUNTO" );
//			}
//			else {
//				Debug.Log( "MANCA" );
//			}

            return(true);
        }
Esempio n. 3
0
        public PBXDictionary AddFile(string filePath, string fileName = null, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string flag = null)
        {
            PBXDictionary results = new PBXDictionary();
            string        absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
                absPath = filePath;
//				Debug.Log( "Is rooted: " + absPath );
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                absPath = Path.Combine(Application.dataPath.Replace("Assets", ""), filePath);
//				Debug.Log( "RElative: " + absPath );
            }

            if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0)
            {
                Debug.Log("Missing file: " + absPath + " > " + filePath);
                return(results);
            }
            else if (tree.CompareTo("SOURCE_ROOT") == 0 || tree.CompareTo("GROUP") == 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;
            }

            //@since 3.9.2 Unity에서 lastKnownFileType를 text로 변경해버리는 이슈 해결
            PBXFileReference fileReference = GetFile(fileName == null ? System.IO.Path.GetFileName(filePath) : fileName);

            if (fileReference != null)
            {
//				Debug.Log( "File già presente." );
                string name = fileReference.name;
                string lastKnownFileType = fileReference.LastKnownFileType;
                string extension         = System.IO.Path.GetExtension(name);

                if (name.Equals("UIKit.framework"))
                {
                    Debug.Log("UIKit.framework");
                }

                if (extension.Equals(".tbd"))
                {
                    if (!lastKnownFileType.Equals("sourcecode.text-based-dylib-definition"))
                    {
                        Debug.Log(name + " LastKnownFileType changed");
                        fileReference.LastKnownFileType = "sourcecode.text-based-dylib-definition";
                    }
                }
                else if (extension.Equals(".mp3"))
                {
                    if (!lastKnownFileType.Equals("audio.mp3"))
                    {
                        Debug.Log(name + " LastKnownFileType changed");
                        fileReference.LastKnownFileType = "audio.mp3";
                    }
                }
                return(null);
            }

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

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
//				PBXDictionary<PBXBuildPhase> currentPhase = GetBuildPhase( fileReference.buildPhase );
                PBXBuildFile buildFile;
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }

                    if (!string.IsNullOrEmpty(absPath) && File.Exists(absPath) && tree.CompareTo("SOURCE_ROOT") == 0)
                    {
                        //Debug.LogError(absPath);
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddLibrarySearchPaths(new PBXList(libraryPath));
                    }
                    else if (!string.IsNullOrEmpty(absPath) && Directory.Exists(absPath) && absPath.EndsWith(".framework") && tree.CompareTo("GROUP") == 0)
                    {     // Annt: Add framework search path for FacebookSDK
                        string frameworkPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        this.AddFrameworkSearchPaths(new PBXList(frameworkPath));
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
                        buildFile = new PBXBuildFile(fileReference, weak, flag);
                        buildFiles.Add(buildFile);
                        currentObject.Value.AddBuildFile(buildFile);
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
                        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);
        }