@@ -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,6 +244,20 @@ 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+ }
252+
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+ }
242261
243262 public bool AddHeaderSearchPaths ( string path )
244263 {
@@ -268,6 +287,26 @@ public bool AddLibrarySearchPaths( PBXList paths )
268287 modified = true ;
269288 return modified ;
270289 }
290+
291+ public bool AddFrameworkSearchPaths ( string path )
292+ {
293+ return AddFrameworkSearchPaths ( new PBXList ( path ) ) ;
294+ }
295+
296+ public bool AddFrameworkSearchPaths ( PBXList paths )
297+ {
298+ foreach ( KeyValuePair < string , XCBuildConfiguration > buildConfig in buildConfigurations )
299+ {
300+ buildConfig . Value . AddFrameworkSearchPaths ( paths ) ;
301+ }
302+ modified = true ;
303+ return modified ;
304+ }
305+
306+ //FRAMEWORK_SEARCH_PATHS = (
307+ // "$(inherited)",
308+ // "\"$(SRCROOT)/../../../../../../../Documents/FacebookSDK\"",
309+ //);
271310
272311
273312// public PBXList GetObjectOfType( string type )
@@ -323,7 +362,7 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
323362 Debug . Log ( "Missing file: " + filePath ) ;
324363 return results ;
325364 }
326- else if ( tree . CompareTo ( "SOURCE_ROOT" ) == 0 ) {
365+ else if ( tree . CompareTo ( "SOURCE_ROOT" ) == 0 || tree . CompareTo ( "GROUP" ) == 0 ) {
327366 System . Uri fileURI = new System . Uri ( absPath ) ;
328367 System . Uri rootURI = new System . Uri ( ( projectRootPath + "/." ) ) ;
329368 filePath = rootURI . MakeRelativeUri ( fileURI ) . ToString ( ) ;
@@ -349,7 +388,7 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
349388 parent . AddChild ( fileReference ) ;
350389 fileReferences . Add ( fileReference ) ;
351390 results . Add ( fileReference . guid , fileReference ) ;
352-
391+
353392 //Create a build file for reference
354393 if ( ! string . IsNullOrEmpty ( fileReference . buildPhase ) && createBuildFiles ) {
355394// PBXDictionary<PBXBuildPhase> currentPhase = GetBuildPhase( fileReference.buildPhase );
@@ -361,9 +400,15 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
361400 buildFiles . Add ( buildFile ) ;
362401 currentObject . Value . AddBuildFile ( buildFile ) ;
363402 }
364- if ( ! string . IsNullOrEmpty ( absPath ) && ( tree . CompareTo ( "SOURCE_ROOT" ) == 0 ) && File . Exists ( absPath ) ) {
403+
404+ if ( ! string . IsNullOrEmpty ( absPath ) && File . Exists ( absPath ) && tree . CompareTo ( "SOURCE_ROOT" ) == 0 ) {
405+ Debug . LogError ( absPath ) ;
365406 string libraryPath = Path . Combine ( "$(SRCROOT)" , Path . GetDirectoryName ( filePath ) ) ;
366- this . AddLibrarySearchPaths ( new PBXList ( libraryPath ) ) ;
407+ this . AddLibrarySearchPaths ( new PBXList ( libraryPath ) ) ;
408+ }
409+ else if ( ! string . IsNullOrEmpty ( absPath ) && Directory . Exists ( absPath ) && absPath . EndsWith ( ".framework" ) && tree . CompareTo ( "GROUP" ) == 0 ) { // Annt: Add framework search path for FacebookSDK
410+ string frameworkPath = Path . Combine ( "$(SRCROOT)" , Path . GetDirectoryName ( filePath ) ) ;
411+ this . AddFrameworkSearchPaths ( new PBXList ( frameworkPath ) ) ;
367412 }
368413 break ;
369414 case "PBXResourcesBuildPhase" :
@@ -882,7 +927,12 @@ public void ApplyMod( XCMod mod )
882927 Debug . Log ( "Adding files..." ) ;
883928 foreach ( string filePath in mod . files ) {
884929 string absoluteFilePath = System . IO . Path . Combine ( mod . path , filePath ) ;
885- this . AddFile ( absoluteFilePath , modGroup ) ;
930+
931+
932+ if ( filePath . EndsWith ( ".framework" ) )
933+ this . AddFile ( absoluteFilePath , frameworkGroup , "GROUP" , true , false ) ;
934+ else
935+ this . AddFile ( absoluteFilePath , modGroup ) ;
886936 }
887937
888938 Debug . Log ( "Adding folders..." ) ;
@@ -896,6 +946,14 @@ public void ApplyMod( XCMod mod )
896946 string absoluteHeaderPath = System . IO . Path . Combine ( mod . path , headerpath ) ;
897947 this . AddHeaderSearchPaths ( absoluteHeaderPath ) ;
898948 }
949+
950+ Debug . Log ( "Adding other linker flags..." ) ;
951+ foreach ( string linker in mod . linkers ) {
952+ string _linker = linker ;
953+ if ( ! _linker . StartsWith ( "-" ) )
954+ _linker = "-" + _linker ;
955+ this . AddOtherLDFlags ( _linker ) ;
956+ }
899957
900958 this . Consolidate ( ) ;
901959 }
0 commit comments