UnityEditor.XCodeEditor.XCProject.ApplyMod C# (CSharp) Method

ApplyMod() public method

public ApplyMod ( XCMod mod ) : void
mod XCMod
return void
        public void ApplyMod( XCMod mod )
        {
            PBXGroup modGroup = this.GetGroup( mod.group );

            Debug.Log( "Adding libraries..." );
            PBXGroup librariesGroup = this.GetGroup( "Libraries" );
            foreach( XCModFile libRef in mod.libs ) {
                string completeLibPath = System.IO.Path.Combine( "usr/lib", libRef.filePath );
                this.AddFile( completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak );
            }

            Debug.Log( "Adding frameworks..." );
            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 );
            }

            Debug.Log( "Adding files..." );
            foreach( string filePath in mod.files ) {
                string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath );

                if( filePath.EndsWith(".framework") )
                    this.AddFile( absoluteFilePath, frameworkGroup, "GROUP", true, false);
                else
                    this.AddFile( absoluteFilePath, modGroup );
            }

            Debug.Log( "Adding folders..." );
            foreach( string folderPath in mod.folders ) {
                string absoluteFolderPath = System.IO.Path.Combine( mod.path, folderPath );
                this.AddFolder( absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray( typeof(string) ) );
            }

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

            Debug.Log( "Configure build settings..." );
            Hashtable buildSettings = mod.buildSettings;
            if (mod.buildSettings != null)
            {
                if( buildSettings.ContainsKey("OTHER_LDFLAGS") )
                {
                    Debug.Log( "    Adding other linker flags..." );
                    ArrayList otherLinkerFlags = (ArrayList) buildSettings["OTHER_LDFLAGS"];
                    foreach( string linker in otherLinkerFlags )
                    {
                        string _linker = linker;
                        if( !_linker.StartsWith("-") )
                            _linker = "-" + _linker;
                        this.AddOtherLDFlags( _linker );
                    }
                }

                if( buildSettings.ContainsKey("GCC_ENABLE_CPP_EXCEPTIONS") )
                {
                    Debug.Log( "    GCC_ENABLE_CPP_EXCEPTIONS = " + buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"] );
                    this.GccEnableCppExceptions( (string) buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"] );
                }

                if( buildSettings.ContainsKey("GCC_ENABLE_OBJC_EXCEPTIONS") )
                {
                    Debug.Log( "    GCC_ENABLE_OBJC_EXCEPTIONS = " + buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"] );
                    this.GccEnableObjCExceptions( (string) buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"] );
                }
            }

            this.Consolidate();
        }

Same methods

XCProject::ApplyMod ( string pbxmod ) : void

Usage Example

コード例 #1
0
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            // If integrating with facebook on any platform, throw a warning if the app id is invalid
            if (!FBSettings.IsValidAppId)
            {
                Debug.LogWarning("You didn't specify a Facebook app ID.  Please add one using the Facebook menu in the main Unity editor.");
            }

            bool needsNewClassnames = IsVersion42OrLater ();

            if (target == BuildTarget.iPhone)
            {
                UnityEditor.XCodeEditor.XCProject project = new UnityEditor.XCodeEditor.XCProject (path);

                // Find and run through all projmods files to patch the project

                string projModPath = System.IO.Path.Combine (Application.dataPath, "Facebook/Editor/iOS");
                var files = System.IO.Directory.GetFiles (projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    project.ApplyMod (Application.dataPath, file);
                }
                project.Save ();

                PlistMod.UpdatePlist (path, FBSettings.AppId);
                FixupFiles.FixSimulator (path);

                if(needsNewClassnames)
                    FixupFiles.AddVersionDefine (path);
            }
        }
All Usage Examples Of UnityEditor.XCodeEditor.XCProject::ApplyMod