コード例 #1
0
        // We support neither recursing into nor bundles contained inside loc folders
        public bool AddLocFolder(string folderPath, string compilerFlags, PBXGroup parent = null, string[] exclude = null, bool createBuildFile = true)
        {
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(folderPath);

            if (exclude == null)
            {
                exclude = new string[] {}
            }
            ;

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

            // Create group as needed
            System.Uri projectFolderURI = new System.Uri(projectFileInfo.DirectoryName);
            System.Uri locFolderURI     = new System.Uri(folderPath);
            var        relativePath     = projectFolderURI.MakeRelativeUri(locFolderURI).ToString();
            PBXGroup   newGroup         = GetGroup(sourceDirectoryInfo.Name, relativePath, parent);

            // Add loc region to project
            string nom    = sourceDirectoryInfo.Name;
            string region = nom.Substring(0, nom.Length - ".lproj".Length);

            project.AddRegion(region);

            // Adding files.
            string regexExclude = string.Format(@"{0}", string.Join("|", exclude));

            foreach (string file in Directory.GetFiles(folderPath))
            {
                if (Regex.IsMatch(file, regexExclude))
                {
                    continue;
                }

                // Add a variant group for the language as well
                var variant = new PBXVariantGroup(System.IO.Path.GetFileName(file), null, "GROUP");
                variantGroups.Add(variant);

                // The group gets a reference to the variant, not to the file itself
                newGroup.AddChild(variant);

                //AddFile(file, variant, "GROUP", createBuildFile);
                AddFile(file, compilerFlags, variant, "GROUP", createBuildFile);
            }

            modified = true;
            return(modified);
        }
コード例 #2
0
        // We support neither recursing into nor bundles contained inside loc folders
        public bool AddLocFolder( string folderPath, string compilerFlags, PBXGroup parent = null, string[] exclude = null, bool createBuildFile = true)
        {
            DirectoryInfo sourceDirectoryInfo = new DirectoryInfo( folderPath );

            if( exclude == null )
                exclude = new string[] {};

            if( parent == null )
                parent = rootGroup;

            // Create group as needed
            System.Uri projectFolderURI = new System.Uri( projectFileInfo.DirectoryName );
            System.Uri locFolderURI = new System.Uri( folderPath );
            var relativePath = projectFolderURI.MakeRelativeUri( locFolderURI ).ToString();
            PBXGroup newGroup = GetGroup( sourceDirectoryInfo.Name, relativePath, parent );

            // Add loc region to project
            string nom = sourceDirectoryInfo.Name;
            string region = nom.Substring(0, nom.Length - ".lproj".Length);
            project.AddRegion(region);

            // Adding files.
            string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
            foreach( string file in Directory.GetFiles( folderPath ) ) {
                if( Regex.IsMatch( file, regexExclude ) ) {
                    continue;
                }

                // Add a variant group for the language as well
                var variant = new PBXVariantGroup(System.IO.Path.GetFileName( file ), null, "GROUP");
                variantGroups.Add(variant);

                // The group gets a reference to the variant, not to the file itself
                newGroup.AddChild(variant);

                //AddFile(file, variant, "GROUP", createBuildFile);
                AddFile(file, compilerFlags, variant, "GROUP", createBuildFile);
            }

            modified = true;
            return modified;
        }