Пример #1
0
    private static void AddFolderBuild(PBXProject proj, string xcodePath, string root)
    {
        //获得源文件下所有目录文件
        string currDir = Path.Combine(xcodePath, root);

        if (root.EndsWith(".framework") || root.EndsWith(".xcframework") || root.EndsWith(".bundle"))
        {
            string target   = proj.GetTargetGuid();
            string fileGuid = proj.AddFile(root, root, PBXSourceTree.Source);
            proj.AddFileToBuild(target, fileGuid);
            SetEmbedFrameworks(proj, root, fileGuid);
            Console.WriteLine(string.Format("add framework or bundle to build:{0}->{1}", currDir, root));
            return;
        }
        List <string> folders = new List <string>(Directory.GetDirectories(currDir));

        foreach (string folder in folders)
        {
            string name       = Path.GetFileName(folder);
            string t_path     = Path.Combine(currDir, name);
            string t_projPath = Path.Combine(root, name);
            if (folder.EndsWith(".framework") || folder.EndsWith(".xcframework") || folder.EndsWith(".bundle"))
            {
                string target   = proj.GetTargetGuid();
                string fileGuid = proj.AddFile(t_projPath, t_projPath, PBXSourceTree.Source);
                proj.AddFileToBuild(target, fileGuid);
                AutoAddSearchPath(proj, xcodePath, t_path);
                SetEmbedFrameworks(proj, t_projPath, fileGuid);
                Console.WriteLine(string.Format("add framework or bundle to build:{0}->{1}", t_path, t_projPath));
            }
            else
            {
                AddFolderBuild(proj, xcodePath, t_projPath);
            }
        }
        List <string> files = new List <string>(Directory.GetFiles(currDir));

        foreach (string file in files)
        {
            if (NeedCopy(file))
            {
                string name       = Path.GetFileName(file);
                string t_path     = Path.Combine(currDir, name);
                string t_projPath = Path.Combine(root, name);
                string target     = proj.GetTargetGuid();
                string fileGuid   = proj.AddFile(t_projPath, t_projPath, PBXSourceTree.Source);
                proj.AddFileToBuild(target, fileGuid);
                AutoAddSearchPath(proj, xcodePath, t_path);
                SetEmbedFrameworks(proj, t_projPath, fileGuid);
                Console.WriteLine("add file to build:" + Path.Combine(root, file));
            }
        }
    }
Пример #2
0
    private static void SetFilesCompileFlag(PBXProject proj, Hashtable arg)
    {
        if (arg == null)
        {
            return;
        }
        string target = proj.GetTargetGuid();

        foreach (DictionaryEntry i in arg)
        {
            string fileProjPath = i.Key.ToString();
            string fguid        = proj.FindFileGuidByProjectPath(fileProjPath);
            if (fguid == null)
            {
                continue;
            }
            ArrayList     des  = i.Value as ArrayList;
            List <string> list = new List <string>();
            foreach (var flag in des)
            {
                list.Add(flag.ToString());
            }
            proj.SetCompileFlagsForFile(target, fguid, list);
        }
    }
Пример #3
0
 //设置编译属性
 private static void SetBuildProperties(PBXProject proj, Hashtable table)
 {
     if (table != null)
     {
         string    target   = proj.GetTargetGuid();
         Hashtable setTable = table.SGet <Hashtable>("=");
         foreach (DictionaryEntry i in setTable)
         {
             proj.SetBuildProperty(target, i.Key.ToString(), i.Value.ToString());
         }
         Hashtable addTable = table.SGet <Hashtable>("+");
         foreach (DictionaryEntry i in addTable)
         {
             ArrayList     array = i.Value as ArrayList;
             List <string> list  = new List <string>();
             foreach (var flag in array)
             {
                 list.Add(flag.ToString());
             }
             proj.UpdateBuildProperty(target, i.Key.ToString(), list, null);
         }
         Hashtable removeTable = table.SGet <Hashtable>("-");
         foreach (DictionaryEntry i in removeTable)
         {
             ArrayList     array = i.Value as ArrayList;
             List <string> list  = new List <string>();
             foreach (var flag in array)
             {
                 list.Add(flag.ToString());
             }
             proj.UpdateBuildProperty(target, i.Key.ToString(), null, list);
         }
     }
 }
Пример #4
0
    private static void CopyFile(PBXProject proj, string xcodePath, string src, string des)
    {
        bool needCopy = NeedCopy(src);

        if (needCopy)
        {
            File.Copy(src, des);
            string target = proj.GetTargetGuid();
            // The path is relative to the source folder
            string relativePath = des.Replace(xcodePath + "/", "");
            string fileGuid     = proj.AddFile(relativePath, relativePath, PBXSourceTree.Source);
            proj.AddFileToBuild(target, fileGuid);
            AutoAddSearchPath(proj, xcodePath, des);
            SetEmbedFrameworks(proj, src, fileGuid);
            Console.WriteLine("copy file " + src + " -> " + des);
        }
    }
Пример #5
0
 private static void SetEmbedFrameworks(PBXProject proj, string filePath, string fileGuid)
 {
     if (embedFrameworksTable != null)
     {
         string    fileName = Path.GetFileName(filePath);
         string    target   = proj.GetTargetGuid();
         ArrayList addList  = embedFrameworksTable["+"] as ArrayList;
         if (addList != null)
         {
             foreach (string i in addList)
             {
                 if (fileName == i)
                 {
                     PBXProjectExtensions.AddFileToEmbedFrameworks(proj, target, fileGuid);
                 }
             }
         }
     }
 }
Пример #6
0
 //设置frameworks
 private static void SetFrameworks(PBXProject proj, Hashtable table)
 {
     if (table != null)
     {
         string    target  = proj.GetTargetGuid();
         ArrayList addList = table["+"] as ArrayList;
         if (addList != null)
         {
             foreach (string i in addList)
             {
                 proj.AddFrameworkToProject(target, i, false);
             }
         }
         ArrayList removeList = table["-"] as ArrayList;
         if (removeList != null)
         {
             foreach (string i in removeList)
             {
                 proj.RemoveFrameworkFromProject(target, i);
             }
         }
     }
 }
Пример #7
0
 //设置libs
 private static void SetLibs(PBXProject proj, Hashtable table)
 {
     if (table != null)
     {
         string    target  = proj.GetTargetGuid();
         ArrayList addList = table["+"] as ArrayList;
         if (addList != null)
         {
             foreach (string i in addList)
             {
                 AddLibToProject(proj, target, i);
             }
         }
         ArrayList removeList = table["-"] as ArrayList;
         if (removeList != null)
         {
             foreach (string i in removeList)
             {
                 RemoveLibFromProject(proj, target, i);
             }
         }
     }
 }