Browse Source

Change prelink script for #223

Ben Hsieh 8 years ago
parent
commit
bd54a37d01

+ 10
- 9
src/ios/RNFetchBlob/RNFetchBlob.h View File

4
 //  Created by wkh237 on 2016/4/28.
4
 //  Created by wkh237 on 2016/4/28.
5
 //
5
 //
6
 
6
 
7
-// comment out this line if your RN project >= 0.40
8
-#define OLD_IMPORT
7
+//XXX: DO NO REMOVE THIS LINE IF YOU'RE USING IT ON RN > 0.40 PROJECT
8
+//#define RN040_IMPORT
9
+
9
 
10
 
10
 #ifndef RNFetchBlob_h
11
 #ifndef RNFetchBlob_h
11
 #define RNFetchBlob_h
12
 #define RNFetchBlob_h
12
 
13
 
13
 
14
 
14
-#ifdef OLD_IMPORT
15
-#import "RCTBridgeModule.h"
16
-#import "RCTLog.h"
17
-#import "RCTRootView.h"
18
-#import "RCTBridge.h"
19
-#import "RCTEventDispatcher.h"
20
-#else
15
+#ifdef RN040_IMPORT
21
 #import <React/RCTLog.h>
16
 #import <React/RCTLog.h>
22
 #import <React/RCTRootView.h>
17
 #import <React/RCTRootView.h>
23
 #import <React/RCTBridge.h>
18
 #import <React/RCTBridge.h>
24
 #import <React/RCTEventDispatcher.h>
19
 #import <React/RCTEventDispatcher.h>
25
 #import <React/RCTBridgeModule.h>
20
 #import <React/RCTBridgeModule.h>
21
+#else
22
+#import "RCTBridgeModule.h"
23
+#import "RCTLog.h"
24
+#import "RCTRootView.h"
25
+#import "RCTBridge.h"
26
+#import "RCTEventDispatcher.h"
26
 #endif
27
 #endif
27
 
28
 
28
 #import <UIKit/UIKit.h>
29
 #import <UIKit/UIKit.h>

+ 3
- 3
src/ios/RNFetchBlobFS.h View File

12
 #import "RNFetchBlob.h"
12
 #import "RNFetchBlob.h"
13
 
13
 
14
 #import <Foundation/Foundation.h>
14
 #import <Foundation/Foundation.h>
15
-#ifdef OLD_IMPORT
16
-#import "RCTBridgeModule.h"
17
-#else
15
+#ifdef RN040_IMPORT
18
 #import <React/RCTBridgeModule.h>
16
 #import <React/RCTBridgeModule.h>
17
+#else
18
+#import "RCTBridgeModule.h"
19
 #endif
19
 #endif
20
 
20
 
21
 @import AssetsLibrary;
21
 @import AssetsLibrary;

+ 4
- 4
src/ios/RNFetchBlobFS.m View File

13
 #import "IOS7Polyfill.h"
13
 #import "IOS7Polyfill.h"
14
 @import AssetsLibrary;
14
 @import AssetsLibrary;
15
 
15
 
16
-#ifdef OLD_IMPORT
17
-#import "RCTBridge.h"
18
-#import "RCTEventDispatcher.h"
19
-#else
16
+#ifdef RN040_IMPORT
20
 #import <React/RCTBridge.h>
17
 #import <React/RCTBridge.h>
21
 #import <React/RCTEventDispatcher.h>
18
 #import <React/RCTEventDispatcher.h>
19
+#else
20
+#import "RCTBridge.h"
21
+#import "RCTEventDispatcher.h"
22
 #endif
22
 #endif
23
 
23
 
24
 
24
 

+ 3
- 3
src/ios/RNFetchBlobNetwork.h View File

10
 #import "RNFetchBlobProgress.h"
10
 #import "RNFetchBlobProgress.h"
11
 #import "RNFetchBlobFS.h"
11
 #import "RNFetchBlobFS.h"
12
 
12
 
13
-#ifdef OLD_IMPORT
14
-#import "RCTBridgeModule.h"
15
-#else
13
+#ifdef RN040_IMPORT
16
 #import <React/RCTBridgeModule.h>
14
 #import <React/RCTBridgeModule.h>
15
+#else
16
+#import "RCTBridgeModule.h"
17
 #endif
17
 #endif
18
 
18
 
19
 #ifndef RNFetchBlobNetwork_h
19
 #ifndef RNFetchBlobNetwork_h

+ 6
- 6
src/ios/RNFetchBlobNetwork.m View File

17
 #import <CommonCrypto/CommonDigest.h>
17
 #import <CommonCrypto/CommonDigest.h>
18
 #import "RNFetchBlobProgress.h"
18
 #import "RNFetchBlobProgress.h"
19
 
19
 
20
-#ifdef OLD_IMPORT
21
-#import "RCTRootView.h"
22
-#import "RCTLog.h"
23
-#import "RCTEventDispatcher.h"
24
-#import "RCTBridge.h"
25
-#else
20
+#ifdef RN040_IMPORT
26
 #import <React/RCTRootView.h>
21
 #import <React/RCTRootView.h>
27
 #import <React/RCTLog.h>
22
 #import <React/RCTLog.h>
28
 #import <React/RCTEventDispatcher.h>
23
 #import <React/RCTEventDispatcher.h>
29
 #import <React/RCTBridge.h>
24
 #import <React/RCTBridge.h>
25
+#else
26
+#import "RCTRootView.h"
27
+#import "RCTLog.h"
28
+#import "RCTEventDispatcher.h"
29
+#import "RCTBridge.h"
30
 #endif
30
 #endif
31
 
31
 
32
 ////////////////////////////////////////
32
 ////////////////////////////////////////

+ 3
- 3
src/ios/RNFetchBlobReqBuilder.m View File

13
 #import "RNFetchBlobFS.h"
13
 #import "RNFetchBlobFS.h"
14
 #import "IOS7Polyfill.h"
14
 #import "IOS7Polyfill.h"
15
 
15
 
16
-#ifdef OLD_IMPORT
17
-#import "RCTLog.h"
18
-#else
16
+#ifdef RN040_IMPORT
19
 #import <React/RCTLog.h>
17
 #import <React/RCTLog.h>
18
+#else
19
+#import "RCTLog.h"
20
 #endif
20
 #endif
21
 
21
 
22
 @interface RNFetchBlobReqBuilder()
22
 @interface RNFetchBlobReqBuilder()

+ 2
- 2
src/scripts/prelink.js View File

21
     console.log('adding OkHttp3 dependency to pre 0.28 project .. ok')
21
     console.log('adding OkHttp3 dependency to pre 0.28 project .. ok')
22
   }
22
   }
23
   else if (VERSION >= 0.40) {
23
   else if (VERSION >= 0.40) {
24
-    console.log('Remove OLD_IMPORT for RN >= 0.40 project ..')
24
+    console.log('Adding RN040_IMPORT for RN >= 0.40 project ..')
25
     glob('**/RNFetchBlob.h',{}, function(err, files) {
25
     glob('**/RNFetchBlob.h',{}, function(err, files) {
26
       if(Array.isArray(files)) {
26
       if(Array.isArray(files)) {
27
         var target = process.cwd() + '/' + files[0];
27
         var target = process.cwd() + '/' + files[0];
28
         console.log('\033[92mPatching .. \033[97m' + target);
28
         console.log('\033[92mPatching .. \033[97m' + target);
29
         var data = fs.readFileSync(target);
29
         var data = fs.readFileSync(target);
30
-        fs.writeFileSync(target, String(data).replace(/#define OLD_IMPORT/, ''));
30
+        fs.writeFileSync(target, String(data).replace(/\/\/#define RN040_IMPORT/, '#define RN040_IMPORT'));
31
         console.log('done.')
31
         console.log('done.')
32
       }
32
       }
33
     })
33
     })