Example #1
0
//		[MenuItem ("Build Tools/XCode Editor/DebugTest %t")]
        static void DebugTest()
        {
            string path  = "/Users/dvicente/sandbox/unity6.1.0";
            string plist = "<configs><key>SPNetworkName</key><string>Flurry</string><key>SPNetworkParameters</key>" +
                           "<dict><key>SPFlurryAdSpaceVideo</key><string>INTERSTITIAL_MAIN_VC</string>" +
                           "<key>SPFlurryApiKey</key><string>7TGX5C5S3XK633XSVMBB</string>" +
                           "</dict></configs>";

            PlistUpdater.UpdatePlist(path, plist);


//			string projectPath = Path.Combine( Directory.GetParent( Application.dataPath ).ToString(), "XCode" );
//			Debug.Log( "XcodePath: " + projectPath );

//			XCProject currentProject = new XCProject( projectPath );
//			XCProject.ApplyMod( projectPath, "/Users/Elyn/Projects/UnityPlugins/Unity Sandbox Project/Assets/Modules/GameCenter/Editor/iOS/GameCenter.projmods" );

            //Debug.Log(
//			PBXDictionary test = new PBXDictionary();
//			bool result = false;
//			if( test is Dictionary<string, object> )
//				result = true;
//
//			Debug.Log( result );

//			PBXType type = new PBXType();
//			Debug.Log( "TYPE: " + type["isa"] );
//
//			PBXBuildFile build = new PBXBuildFile( "" );
//			Debug.Log( "BUILDFILE: " + build["isa"] );

//			Debug.Log( PBXObject.GenerateGuid().ToUpper() );
//			PBXList testList = currentProject.GetObjectOfType( "XCBuildConfiguration" );
//			Debug.Log( testList.Count );
//			Debug.Log( currentProject.rootGroup.guid + " " + currentProject.rootGroup.name + " " + currentProject.rootGroup.path);
//			string path1 = "Data/mainData";

//			string path2 = "/Users/Elyn/Projects/UnityPlugins/Modules/GameCenter/Editor/iOS/";
//			Debug.Log( "Objects: " + currentProject._objects.Count );
//			Debug.Log( "Files: " + currentProject.buildFiles.Count );
//			Debug.Log( "Groups: " + currentProject.groups.Count );
//			string[] excludes = new string[] {"^.*\\.meta$", "^.*\\.mdown^", "^.*\\.pdf$"};
//			currentProject.AddFolder( path2, null, excludes );
//			currentProject.Consolidate();
//			Debug.Log( "Objects: " + currentProject._objects.Count );
//			currentProject.Save();

            //ALTRO
//			currentProject.AddOtherCFlags( "TEST_FLAG" );
//
//			foreach( KeyValuePair<string, XCBuildConfiguration> config in currentProject.buildConfigurations ) {
//				Debug.Log( "C: " + config.Value.buildSettings["OTHER_CFLAGS"] );
//				foreach( string keys in (PBXList)config.Value.buildSettings["OTHER_CFLAGS"]  )
//					Debug.Log( keys );
//			}

//			currentProject.Save();
        }
Example #2
0
    private static void applyProjmodsToProject(XCProject project)
    {
        // Find and run through all projmods files to patch the project
        string mediationProjmodsRootDir = System.IO.Path.Combine(Application.dataPath, "Fyber/iOS");
        string SDKProjmodRootDir        = System.IO.Path.Combine(Application.dataPath, "Plugins/iOS");

        string[] SDKProjmodsFiles       = System.IO.Directory.GetFiles(SDKProjmodRootDir, "*.projmods", System.IO.SearchOption.AllDirectories);
        string[] mediationProjmodsFiles = System.IO.Directory.GetFiles(mediationProjmodsRootDir, "*.projmods", System.IO.SearchOption.AllDirectories);
        string[] projmodsFiles          = SDKProjmodsFiles.Concat(mediationProjmodsFiles).ToArray();

        foreach (var projmodFile in projmodsFiles)
        {
            Debug.Log("Applying Modification to Project from projmod file: " + projmodFile);
            project.ApplyMod(Application.dataPath, projmodFile);

            if (projmodFile.Contains("NativeX"))
            {
                string unityVersionPlist = "<plist><key>name</key><string>Nativex</string><key>settings</key><dict><key>FYBNativeXUnityBuildFlag</key><true /></dict></plist>";
                PlistUpdater.UpdatePlist(project.projectRootPath, unityVersionPlist);
            }
        }
    }
        public void ApplyMod(XCMod mod)
        {
            string[] groupsName = mod.group.Split('/');

            PBXGroup[] groups = new PBXGroup[groupsName.Length];

            groups[0] = GetGroup(groupsName[0]);
            for (int i = 1; i < groupsName.Length; i++)
            {
                groups[i] = this.GetGroup(groupsName[i], null, groups[i - 1]);
            }

            PBXGroup modGroup = groups[groups.Length - 1];

            foreach (XCModFile libRef in mod.libs)
            {
                string completeLibPath;
                if (libRef.sourceTree.Equals("SDKROOT"))
                {
                    completeLibPath = System.IO.Path.Combine("usr/lib/", libRef.filePath);
                    PBXGroup libraryGroup = GetGroup("Libraries");
                    this.AddFile(completeLibPath, libraryGroup, libRef.sourceTree, true, libRef.isWeak);
                }
                else
                {
                    completeLibPath = System.IO.Path.Combine(mod.path, libRef.filePath);
                    this.AddFile(completeLibPath, modGroup, libRef.sourceTree, true, libRef.isWeak);
                }
            }
            PBXGroup frameworkGroup = this.GetGroup("Frameworks");

            foreach (string framework in mod.frameworks)
            {
                string[] filename     = framework.Split(':');
                bool     isWeak       = (filename.Length > 1) ? true : false;
                string   completePath = System.IO.Path.Combine("System/Library/Frameworks/", filename[0]);
                this.AddFile(completePath, frameworkGroup, "SDKROOT", true, isWeak);
            }

            foreach (string file in mod.files)
            {
                string[] fileDesc      = file.Split(':');
                string[] compilerFlags = null;
                if (fileDesc.Length > 1)
                {
                    compilerFlags = fileDesc[1].Split(';');
                }
                string absoluteFilePath = System.IO.Path.Combine(mod.path, fileDesc[0]);
                //string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false
                this.AddFile(absoluteFilePath, modGroup, "SOURCE_ROOT", true, false, compilerFlags);
            }

            foreach (string folderPath in mod.folders)
            {
                string absoluteFolderPath = System.IO.Path.Combine(mod.path, folderPath);
                absoluteFolderPath = System.IO.Path.GetFullPath(absoluteFolderPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                this.AddFolder(absoluteFolderPath, mod.path, modGroup, mod.excludes.ToArray(), false /*recursive*/);
            }


            foreach (string headerpath in mod.headerpaths)
            {
                string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, headerpath));
                this.AddHeaderSearchPaths(absoluteHeaderPath);
            }

            foreach (string librarypath in mod.librarysearchpaths)
            {
                string absolutePath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, librarypath));
                this.AddLibrarySearchPaths(absolutePath);
            }

            if (mod.frameworksearchpath != null)
            {
                foreach (string frameworksearchpath in mod.frameworksearchpath)
                {
                    string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, frameworksearchpath));
                    this.AddFrameworkSearchPaths(absoluteHeaderPath);
                }
            }

            if (mod.linkers != null)
            {
                foreach (string linker in mod.linkers)
                {
                    string _linker = linker;
                    if (!_linker.StartsWith("-"))
                    {
                        _linker = "-" + _linker;
                    }
                    this.AddOtherLDFlags(_linker);
                }
            }

            this.Consolidate();

            foreach (string plistMod in mod.plist)
            {
                PlistUpdater.UpdatePlist(projectRootPath, plistMod);
            }
        }
Example #4
0
    public static void OnPostProcessBuild(BuildTarget target, string path)
    {
#if UNITY_IPHONE || UNITY_IOS
#if UNITY_5
        if (target == BuildTarget.iOS)
#else
        if (target == BuildTarget.iPhone)
#endif // UNITY_5
        {
            string folderPath = Path.Combine(Application.dataPath, "Fyber/iOS/fyber-sdk-compat-lib");
            if (Directory.Exists(folderPath))
            {
                Directory.Delete(folderPath, true);
            }

            XCProject project = new XCProject(path);

            string libPath = Path.Combine(project.projectRootPath, "Libraries/Fyber/iOS/fyber-sdk-compat-lib");

            if (Directory.Exists(libPath))
            {
                Directory.Delete(libPath, true);
            }

            // Find and run through all projmods files to patch the project
            string   projModPath = System.IO.Path.Combine(Application.dataPath, "Fyber/iOS");
            string[] files       = System.IO.Directory.GetFiles(projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);
            foreach (var file in files)
            {
                project.ApplyMod(Application.dataPath, file);

                if (file.Contains("NativeX"))
                {
                    string unityVersionPlist = "<plist><key>name</key><string>Nativex</string><key>settings</key><dict><key>FYBNativeXUnityBuildFlag</key><true /></dict></plist>";
                    PlistUpdater.UpdatePlist(project.projectRootPath, unityVersionPlist);
                }
            }
            project.Save();

#if UNITY_5
            var      compatGroup   = "Libraries/Fyber/iOS/fyber-sdk-compat-lib";
            string[] filesToRemove = { "FYBBannerSize.h", "FYBBannerView.h", "libFyberSDKCompat.a" };

            UnityEditor.iOS.Xcode.PBXProject pbxProject = new UnityEditor.iOS.Xcode.PBXProject();
            string pbxprojPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath(path);
            pbxProject.ReadFromFile(pbxprojPath);

            foreach (string file in filesToRemove)
            {
                var fileToRemove = compatGroup + "/" + file;
                if (pbxProject.ContainsFileByProjectPath(fileToRemove))
                {
                    string guid = pbxProject.FindFileGuidByProjectPath(fileToRemove);
                    pbxProject.RemoveFile(guid);
                }
            }

            pbxProject.WriteToFile(pbxprojPath);
#endif // UNITY_5
        }
#endif //UNITY_IPHONE || UNITY_IOS
    }