Просмотр исходного кода

#223 Change prelink script to solve IOS 0.40 #import issue

Ben Hsieh 7 лет назад
Родитель
Сommit
1332bd195c
2 измененных файлов: 13 добавлений и 0 удалений
  1. 1
    0
      src/ios/RNFetchBlob/RNFetchBlob.h
  2. 12
    0
      src/scripts/prelink.js

+ 1
- 0
src/ios/RNFetchBlob/RNFetchBlob.h Просмотреть файл

@@ -4,6 +4,7 @@
4 4
 //  Created by wkh237 on 2016/4/28.
5 5
 //
6 6
 
7
+// comment out this line if your RN project >= 0.40
7 8
 #define OLD_IMPORT
8 9
 
9 10
 #ifndef RNFetchBlob_h

+ 12
- 0
src/scripts/prelink.js Просмотреть файл

@@ -20,6 +20,18 @@ try {
20 20
     fs.writeFileSync(PACKAGE_GRADLE, main);
21 21
     console.log('adding OkHttp3 dependency to pre 0.28 project .. ok')
22 22
   }
23
+  else if (VERSION >= 0.40) {
24
+    console.log('Remove OLD_IMPORT for RN >= 0.40 project ..')
25
+    glob('**/RNFetchBlob.h',{}, function(err, files) {
26
+      if(Array.isArray(files)) {
27
+        var target = process.cwd() + '/' + files[0];
28
+        console.log('\033[92mPatching .. \033[97m' + target);
29
+        var data = fs.readFileSync(target);
30
+        fs.writeFileSync(target, String(data).replace(/^#define OLD_IMPORT$/, '// #define OLD_IMPORT'));
31
+        console.log('done.')
32
+      }
33
+    })
34
+  }
23 35
 
24 36
   console.log('Add Android permissions => ' + (addAndroidPermissions == "true"))
25 37