@@ -76,8 +76,13 @@ public XCProject( string filePath ) : this()
7676 this . filePath = projects [ 0 ] ;
7777 }
7878
79+ // Convert to absolute
80+ this . projectRootPath = Path . GetFullPath ( this . projectRootPath ) ;
81+
7982 projectFileInfo = new FileInfo ( Path . Combine ( this . filePath , "project.pbxproj" ) ) ;
80- string contents = projectFileInfo . OpenText ( ) . ReadToEnd ( ) ;
83+ StreamReader sr = projectFileInfo . OpenText ( ) ;
84+ string contents = sr . ReadToEnd ( ) ;
85+ sr . Close ( ) ;
8186
8287 PBXParser parser = new PBXParser ( ) ;
8388 _datastore = parser . Decode ( contents ) ;
@@ -239,7 +244,39 @@ public bool AddOtherCFlags( PBXList flags )
239244 modified = true ;
240245 return modified ;
241246 }
247+
248+ public bool AddOtherLDFlags ( string flag )
249+ {
250+ return AddOtherLDFlags ( new PBXList ( flag ) ) ;
251+ }
242252
253+ public bool AddOtherLDFlags ( PBXList flags )
254+ {
255+ foreach ( KeyValuePair < string , XCBuildConfiguration > buildConfig in buildConfigurations ) {
256+ buildConfig . Value . AddOtherLDFlags ( flags ) ;
257+ }
258+ modified = true ;
259+ return modified ;
260+ }
261+
262+ public bool GccEnableCppExceptions ( string value )
263+ {
264+ foreach ( KeyValuePair < string , XCBuildConfiguration > buildConfig in buildConfigurations ) {
265+ buildConfig . Value . GccEnableCppExceptions ( value ) ;
266+ }
267+ modified = true ;
268+ return modified ;
269+ }
270+
271+ public bool GccEnableObjCExceptions ( string value )
272+ {
273+ foreach ( KeyValuePair < string , XCBuildConfiguration > buildConfig in buildConfigurations ) {
274+ buildConfig . Value . GccEnableObjCExceptions ( value ) ;
275+ }
276+ modified = true ;
277+ return modified ;
278+ }
279+
243280 public bool AddHeaderSearchPaths ( string path )
244281 {
245282 return AddHeaderSearchPaths ( new PBXList ( path ) ) ;
@@ -268,6 +305,26 @@ public bool AddLibrarySearchPaths( PBXList paths )
268305 modified = true ;
269306 return modified ;
270307 }
308+
309+ public bool AddFrameworkSearchPaths ( string path )
310+ {
311+ return AddFrameworkSearchPaths ( new PBXList ( path ) ) ;
312+ }
313+
314+ public bool AddFrameworkSearchPaths ( PBXList paths )
315+ {
316+ foreach ( KeyValuePair < string , XCBuildConfiguration > buildConfig in buildConfigurations )
317+ {
318+ buildConfig . Value . AddFrameworkSearchPaths ( paths ) ;
319+ }
320+ modified = true ;
321+ return modified ;
322+ }
323+
324+ //FRAMEWORK_SEARCH_PATHS = (
325+ // "$(inherited)",
326+ // "\"$(SRCROOT)/../../../../../../../Documents/FacebookSDK\"",
327+ //);
271328
272329
273330// public PBXList GetObjectOfType( string type )
@@ -315,15 +372,15 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
315372// Debug.Log( "Is rooted: " + absPath );
316373 }
317374 else if ( tree . CompareTo ( "SDKROOT" ) != 0 ) {
318- absPath = Path . Combine ( Application . dataPath , filePath ) ;
375+ absPath = Path . Combine ( Application . dataPath . Replace ( "Assets" , "" ) , filePath ) ;
319376// Debug.Log( "RElative: " + absPath );
320377 }
321378
322379 if ( ! ( File . Exists ( absPath ) || Directory . Exists ( absPath ) ) && tree . CompareTo ( "SDKROOT" ) != 0 ) {
323- Debug . Log ( "Missing file: " + filePath ) ;
380+ Debug . Log ( "Missing file: " + absPath + " > " + filePath ) ;
324381 return results ;
325382 }
326- else if ( tree . CompareTo ( "SOURCE_ROOT" ) == 0 ) {
383+ else if ( tree . CompareTo ( "SOURCE_ROOT" ) == 0 || tree . CompareTo ( "GROUP" ) == 0 ) {
327384 System . Uri fileURI = new System . Uri ( absPath ) ;
328385 System . Uri rootURI = new System . Uri ( ( projectRootPath + "/." ) ) ;
329386 filePath = rootURI . MakeRelativeUri ( fileURI ) . ToString ( ) ;
@@ -349,7 +406,7 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
349406 parent . AddChild ( fileReference ) ;
350407 fileReferences . Add ( fileReference ) ;
351408 results . Add ( fileReference . guid , fileReference ) ;
352-
409+
353410 //Create a build file for reference
354411 if ( ! string . IsNullOrEmpty ( fileReference . buildPhase ) && createBuildFiles ) {
355412// PBXDictionary<PBXBuildPhase> currentPhase = GetBuildPhase( fileReference.buildPhase );
@@ -361,9 +418,15 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
361418 buildFiles . Add ( buildFile ) ;
362419 currentObject . Value . AddBuildFile ( buildFile ) ;
363420 }
364- if ( ! string . IsNullOrEmpty ( absPath ) && ( tree . CompareTo ( "SOURCE_ROOT" ) == 0 ) && File . Exists ( absPath ) ) {
421+
422+ if ( ! string . IsNullOrEmpty ( absPath ) && File . Exists ( absPath ) && tree . CompareTo ( "SOURCE_ROOT" ) == 0 ) {
423+ //Debug.LogError(absPath);
365424 string libraryPath = Path . Combine ( "$(SRCROOT)" , Path . GetDirectoryName ( filePath ) ) ;
366- this . AddLibrarySearchPaths ( new PBXList ( libraryPath ) ) ;
425+ this . AddLibrarySearchPaths ( new PBXList ( libraryPath ) ) ;
426+ }
427+ else if ( ! string . IsNullOrEmpty ( absPath ) && Directory . Exists ( absPath ) && absPath . EndsWith ( ".framework" ) && tree . CompareTo ( "GROUP" ) == 0 ) { // Annt: Add framework search path for FacebookSDK
428+ string frameworkPath = Path . Combine ( "$(SRCROOT)" , Path . GetDirectoryName ( filePath ) ) ;
429+ this . AddFrameworkSearchPaths ( new PBXList ( frameworkPath ) ) ;
367430 }
368431 break ;
369432 case "PBXResourcesBuildPhase" :
@@ -464,9 +527,10 @@ public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclu
464527 if ( ! Directory . Exists ( folderPath ) )
465528 return false ;
466529 DirectoryInfo sourceDirectoryInfo = new DirectoryInfo ( folderPath ) ;
467-
530+
468531 if ( exclude == null )
469532 exclude = new string [ ] { } ;
533+ string regexExclude = string . Format ( @"{0}" , string . Join ( "|" , exclude ) ) ;
470534
471535 PBXDictionary results = new PBXDictionary ( ) ;
472536
@@ -479,6 +543,10 @@ public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclu
479543
480544 foreach ( string directory in Directory . GetDirectories ( folderPath ) )
481545 {
546+ if ( Regex . IsMatch ( directory , regexExclude ) ) {
547+ continue ;
548+ }
549+
482550// special_folders = ['.bundle', '.framework', '.xcodeproj']
483551 Debug . Log ( "DIR: " + directory ) ;
484552 if ( directory . EndsWith ( ".bundle" ) ) {
@@ -494,18 +562,15 @@ public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclu
494562 AddFolder ( directory , newGroup , exclude , recursive , createBuildFile ) ;
495563 }
496564 }
497-
498565 // Adding files.
499- string regexExclude = string . Format ( @"{0}" , string . Join ( "|" , exclude ) ) ;
500566 foreach ( string file in Directory . GetFiles ( folderPath ) ) {
501567 if ( Regex . IsMatch ( file , regexExclude ) ) {
502568 continue ;
503569 }
504- // Debug.Log( "--> " + file + ", " + newGroup );
570+ // Debug.Log( "--> " + file + ", " + newGroup );
505571 AddFile ( file , newGroup , "SOURCE_ROOT" , createBuildFile ) ;
506572 }
507-
508-
573+
509574 modified = true ;
510575 return modified ;
511576// def add_folder(self, os_path, parent=None, excludes=None, recursive=True, create_build_files=True):
@@ -882,7 +947,12 @@ public void ApplyMod( XCMod mod )
882947 Debug . Log ( "Adding files..." ) ;
883948 foreach ( string filePath in mod . files ) {
884949 string absoluteFilePath = System . IO . Path . Combine ( mod . path , filePath ) ;
885- this . AddFile ( absoluteFilePath , modGroup ) ;
950+
951+
952+ if ( filePath . EndsWith ( ".framework" ) )
953+ this . AddFile ( absoluteFilePath , frameworkGroup , "GROUP" , true , false ) ;
954+ else
955+ this . AddFile ( absoluteFilePath , modGroup ) ;
886956 }
887957
888958 Debug . Log ( "Adding folders..." ) ;
@@ -896,7 +966,34 @@ public void ApplyMod( XCMod mod )
896966 string absoluteHeaderPath = System . IO . Path . Combine ( mod . path , headerpath ) ;
897967 this . AddHeaderSearchPaths ( absoluteHeaderPath ) ;
898968 }
899-
969+
970+ Debug . Log ( "Configure build settings..." ) ;
971+ Hashtable buildSettings = mod . buildSettings ;
972+ if ( buildSettings . ContainsKey ( "OTHER_LDFLAGS" ) )
973+ {
974+ Debug . Log ( " Adding other linker flags..." ) ;
975+ ArrayList otherLinkerFlags = ( ArrayList ) buildSettings [ "OTHER_LDFLAGS" ] ;
976+ foreach ( string linker in otherLinkerFlags )
977+ {
978+ string _linker = linker ;
979+ if ( ! _linker . StartsWith ( "-" ) )
980+ _linker = "-" + _linker ;
981+ this . AddOtherLDFlags ( _linker ) ;
982+ }
983+ }
984+
985+ if ( buildSettings . ContainsKey ( "GCC_ENABLE_CPP_EXCEPTIONS" ) )
986+ {
987+ Debug . Log ( " GCC_ENABLE_CPP_EXCEPTIONS = " + buildSettings [ "GCC_ENABLE_CPP_EXCEPTIONS" ] ) ;
988+ this . GccEnableCppExceptions ( ( string ) buildSettings [ "GCC_ENABLE_CPP_EXCEPTIONS" ] ) ;
989+ }
990+
991+ if ( buildSettings . ContainsKey ( "GCC_ENABLE_OBJC_EXCEPTIONS" ) )
992+ {
993+ Debug . Log ( " GCC_ENABLE_OBJC_EXCEPTIONS = " + buildSettings [ "GCC_ENABLE_OBJC_EXCEPTIONS" ] ) ;
994+ this . GccEnableObjCExceptions ( ( string ) buildSettings [ "GCC_ENABLE_OBJC_EXCEPTIONS" ] ) ;
995+ }
996+
900997 this . Consolidate ( ) ;
901998 }
902999
0 commit comments