11const  fs  =  require ( 'fs' ) , 
2-     path  =  require ( 'path' ) ; 
2+   path  =  require ( 'path' ) , 
3+   prepareHooksHelper  =  require ( "../prepare-hooks-helper" ) ; 
34
45// inject some code into main.m 
56function  patchUIApplicationMain ( iosProjectFolder )  { 
@@ -17,20 +18,20 @@ function patchUIApplicationMain(iosProjectFolder) {
1718    if  ( tnsAppSyncFileDestContents . indexOf ( "TNSAppSync" )  ===  - 1 )  { 
1819      // let's first inject a header we need 
1920      replaceInFile ( 
20-            appSyncFileDest , 
21-            '#include <NativeScript/NativeScript.h>' , 
22-            '#include <NativeScript/NativeScript.h>\n#include <AppSync/TNSAppSync.h>' 
21+         appSyncFileDest , 
22+         '#include <NativeScript/NativeScript.h>' , 
23+         '#include <NativeScript/NativeScript.h>\n#include <AppSync/TNSAppSync.h>' 
2324      ) ; 
2425
2526      // now inject the function call that determines the correct application path (either default or appsync'ed) 
2627      replaceInFile ( 
27-            appSyncFileDest , 
28-            'applicationPath = [NSBundle mainBundle].bundlePath;' , 
29-            'applicationPath = [TNSAppSync applicationPathWithDefault:[NSBundle mainBundle].bundlePath];' 
28+         appSyncFileDest , 
29+         'applicationPath = [NSBundle mainBundle].bundlePath;' , 
30+         'applicationPath = [TNSAppSync applicationPathWithDefault:[NSBundle mainBundle].bundlePath];' 
3031      ) ; 
3132    } 
3233
33-   }  catch ( e )  { 
34+   }  catch   ( e )  { 
3435    console . log ( "AppSync iOS hook error: "  +  e ) ; 
3536  } 
3637} 
@@ -41,11 +42,11 @@ function replaceInFile(theFile, what, by) {
4142  fs . writeFileSync ( theFile ,  result ,  'utf8' ) ; 
4243} 
4344
44- module . exports  =  function  ( logger ,   platformsData ,   projectData ,  hookArgs )  { 
45-   const  iosProjectFolder  =  path . join ( projectData . platformsDir ,   "ios" ) ; 
45+ module . exports  =  function  ( $injector ,  hookArgs )  { 
46+   const  platform  =  prepareHooksHelper . getPlatformFromPrepareHookArgs ( hookArgs ) ; 
4647
47-   return  new  Promise ( function  ( resolve ,  reject )  { 
48+   if  ( platform  ===  'ios' )  { 
49+     const  iosProjectFolder  =  prepareHooksHelper . getNativeProjectDir ( $injector ,  platform ,  hookArgs ) ; 
4850    patchUIApplicationMain ( iosProjectFolder ) ; 
49-     resolve ( ) ; 
50-   } ) ; 
51+   } 
5152} ; 
0 commit comments