From cd49cd2b530896fbca1a02f11825a2118233fc5e Mon Sep 17 00:00:00 2001 From: Brenton Bartel Date: Wed, 13 Apr 2016 15:36:56 -0700 Subject: [PATCH] Put guards on Mods in case they are null due to missing from projmods --- XCProject.cs | 102 +++++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/XCProject.cs b/XCProject.cs index 256de11..95a3e91 100755 --- a/XCProject.cs +++ b/XCProject.cs @@ -705,37 +705,41 @@ public void ApplyMod( string pbxmod ) } ApplyMod( mod ); } - + public void ApplyMod( XCMod mod ) { PBXGroup modGroup = this.GetGroup( mod.group ); - Debug.Log( "Adding libraries..." ); - - foreach( XCModFile libRef in mod.libs ) { - string completeLibPath = System.IO.Path.Combine( "usr/lib", libRef.filePath ); - Debug.Log ("Adding library " + completeLibPath); - this.AddFile( completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak ); + if (mod.libs != null) { + Debug.Log( "Adding libraries..." ); + foreach( XCModFile libRef in mod.libs ) { + string completeLibPath = System.IO.Path.Combine( "usr/lib", libRef.filePath ); + Debug.Log ("Adding library " + completeLibPath); + 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 ); + if (mod.frameworks != null) { + 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 ); - this.AddFile( absoluteFilePath, modGroup ); + if (mod.files != null) { + Debug.Log( "Adding files..." ); + foreach( string filePath in mod.files ) { + string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath ); + this.AddFile( absoluteFilePath, modGroup ); + } } - Debug.Log( "Adding embed binaries..." ); - if (mod.embed_binaries != null) - { + if (mod.embed_binaries != null) { + Debug.Log( "Adding embed binaries..." ); //1. Add LD_RUNPATH_SEARCH_PATHS for embed framework this.overwriteBuildSetting("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks", "Release"); this.overwriteBuildSetting("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks", "Debug"); @@ -746,38 +750,48 @@ public void ApplyMod( XCMod mod ) } } - Debug.Log( "Adding folders..." ); - foreach( string folderPath in mod.folders ) { - string absoluteFolderPath = System.IO.Path.Combine( Application.dataPath, folderPath ); - Debug.Log ("Adding folder " + absoluteFolderPath); - this.AddFolder( absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray( typeof(string) ) ); + if (mod.folders != null) { + Debug.Log( "Adding folders..." ); + foreach( string folderPath in mod.folders ) { + string absoluteFolderPath = System.IO.Path.Combine( Application.dataPath, folderPath ); + Debug.Log ("Adding folder " + absoluteFolderPath); + this.AddFolder( absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray( typeof(string) ) ); + } } - Debug.Log( "Adding headerpaths..." ); - foreach( string headerpath in mod.headerpaths ) { - if (headerpath.Contains("$(inherited)")) { - Debug.Log ("not prepending a path to " + headerpath); - this.AddHeaderSearchPaths( headerpath ); - } else { - string absoluteHeaderPath = System.IO.Path.Combine( mod.path, headerpath ); - this.AddHeaderSearchPaths( absoluteHeaderPath ); + if (mod.headerpaths != null) { + Debug.Log( "Adding headerpaths..." ); + foreach( string headerpath in mod.headerpaths ) { + if (headerpath.Contains("$(inherited)")) { + Debug.Log ("not prepending a path to " + headerpath); + this.AddHeaderSearchPaths( headerpath ); + } else { + string absoluteHeaderPath = System.IO.Path.Combine( mod.path, headerpath ); + this.AddHeaderSearchPaths( absoluteHeaderPath ); + } } } - Debug.Log( "Adding compiler flags..." ); - foreach( string flag in mod.compiler_flags ) { - this.AddOtherCFlags( flag ); + if (mod.compiler_flags != null) { + Debug.Log( "Adding compiler flags..." ); + foreach( string flag in mod.compiler_flags ) { + this.AddOtherCFlags( flag ); + } } - Debug.Log( "Adding linker flags..." ); - foreach( string flag in mod.linker_flags ) { - this.AddOtherLinkerFlags( flag ); + if (mod.linker_flags != null) { + Debug.Log( "Adding linker flags..." ); + foreach( string flag in mod.linker_flags ) { + this.AddOtherLinkerFlags( flag ); + } } - Debug.Log ("Adding plist items..."); - string plistPath = this.projectRootPath + "/Info.plist"; - XCPlist plist = new XCPlist (plistPath); - plist.Process(mod.plist); + if (mod.plist != null) { + Debug.Log ("Adding plist items..."); + string plistPath = this.projectRootPath + "/Info.plist"; + XCPlist plist = new XCPlist (plistPath); + plist.Process(mod.plist); + } this.Consolidate(); }