Skip to content

Commit 6a0a5b2

Browse files
committed
fix ios reload
1 parent 7023ff5 commit 6a0a5b2

7 files changed

Lines changed: 51 additions & 49 deletions

File tree

Example/testHotUpdate/bun.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/testHotUpdate/ios/AwesomeProject/AppDelegate.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#import "RCTPushy.h"
33

44
#import <React/RCTBundleURLProvider.h>
5+
#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
56

67
@implementation AppDelegate
78

89
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
910
{
1011
self.moduleName = @"AwesomeProject";
12+
self.dependencyProvider = [RCTAppDependencyProvider new];
1113
// You can add your custom initial props in the dictionary below.
1214
// They will be passed down to the ViewController used by React Native.
1315
self.initialProps = @{};

Example/testHotUpdate/ios/Podfile.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ PODS:
13321332
- React-jsiexecutor
13331333
- React-RCTFBReactNativeSpec
13341334
- ReactCommon/turbomodule/core
1335-
- react-native-safe-area-context (5.4.1):
1335+
- react-native-safe-area-context (5.5.0):
13361336
- DoubleConversion
13371337
- glog
13381338
- hermes-engine
@@ -1347,8 +1347,8 @@ PODS:
13471347
- React-hermes
13481348
- React-ImageManager
13491349
- React-jsi
1350-
- react-native-safe-area-context/common (= 5.4.1)
1351-
- react-native-safe-area-context/fabric (= 5.4.1)
1350+
- react-native-safe-area-context/common (= 5.5.0)
1351+
- react-native-safe-area-context/fabric (= 5.5.0)
13521352
- React-NativeModulesApple
13531353
- React-RCTFabric
13541354
- React-renderercss
@@ -1358,7 +1358,7 @@ PODS:
13581358
- ReactCommon/turbomodule/bridging
13591359
- ReactCommon/turbomodule/core
13601360
- Yoga
1361-
- react-native-safe-area-context/common (5.4.1):
1361+
- react-native-safe-area-context/common (5.5.0):
13621362
- DoubleConversion
13631363
- glog
13641364
- hermes-engine
@@ -1382,7 +1382,7 @@ PODS:
13821382
- ReactCommon/turbomodule/bridging
13831383
- ReactCommon/turbomodule/core
13841384
- Yoga
1385-
- react-native-safe-area-context/fabric (5.4.1):
1385+
- react-native-safe-area-context/fabric (5.5.0):
13861386
- DoubleConversion
13871387
- glog
13881388
- hermes-engine
@@ -1407,7 +1407,7 @@ PODS:
14071407
- ReactCommon/turbomodule/bridging
14081408
- ReactCommon/turbomodule/core
14091409
- Yoga
1410-
- react-native-update (10.28.11):
1410+
- react-native-update (10.29.4):
14111411
- DoubleConversion
14121412
- glog
14131413
- hermes-engine
@@ -1423,8 +1423,8 @@ PODS:
14231423
- React-hermes
14241424
- React-ImageManager
14251425
- React-jsi
1426-
- react-native-update/HDiffPatch (= 10.28.11)
1427-
- react-native-update/RCTPushy (= 10.28.11)
1426+
- react-native-update/HDiffPatch (= 10.29.4)
1427+
- react-native-update/RCTPushy (= 10.29.4)
14281428
- React-NativeModulesApple
14291429
- React-RCTFabric
14301430
- React-renderercss
@@ -1435,7 +1435,7 @@ PODS:
14351435
- ReactCommon/turbomodule/core
14361436
- SSZipArchive
14371437
- Yoga
1438-
- react-native-update/HDiffPatch (10.28.11):
1438+
- react-native-update/HDiffPatch (10.29.4):
14391439
- DoubleConversion
14401440
- glog
14411441
- hermes-engine
@@ -1461,7 +1461,7 @@ PODS:
14611461
- ReactCommon/turbomodule/core
14621462
- SSZipArchive
14631463
- Yoga
1464-
- react-native-update/RCTPushy (10.28.11):
1464+
- react-native-update/RCTPushy (10.29.4):
14651465
- DoubleConversion
14661466
- glog
14671467
- hermes-engine
@@ -1809,7 +1809,7 @@ PODS:
18091809
- React-logger (= 0.79.2)
18101810
- React-perflogger (= 0.79.2)
18111811
- React-utils (= 0.79.2)
1812-
- ReactNativeCameraKit (15.0.1):
1812+
- ReactNativeCameraKit (15.1.0):
18131813
- DoubleConversion
18141814
- glog
18151815
- hermes-engine
@@ -2186,8 +2186,8 @@ SPEC CHECKSUMS:
21862186
React-logger: 8edfcedc100544791cd82692ca5a574240a16219
21872187
React-Mapbuffer: c3f4b608e4a59dd2f6a416ef4d47a14400194468
21882188
React-microtasksnativemodule: 054f34e9b82f02bd40f09cebd4083828b5b2beb6
2189-
react-native-safe-area-context: 5594ec631ede9c311c5c0efa244228eff845ce88
2190-
react-native-update: b4a6653129ac98d9cf5295d40b43ffb927114237
2189+
react-native-safe-area-context: 11d29ae675265669f498d7d9de2341087e8fe162
2190+
react-native-update: 6d3a3eb322cbc382ad78853cb52e44e8c93e8072
21912191
React-NativeModulesApple: 2c4377e139522c3d73f5df582e4f051a838ff25e
21922192
React-oscompat: ef5df1c734f19b8003e149317d041b8ce1f7d29c
21932193
React-perflogger: 9a151e0b4c933c9205fd648c246506a83f31395d
@@ -2219,7 +2219,7 @@ SPEC CHECKSUMS:
22192219
ReactAppDependencyProvider: 04d5eb15eb46be6720e17a4a7fa92940a776e584
22202220
ReactCodegen: c63eda03ba1d94353fb97b031fc84f75a0d125ba
22212221
ReactCommon: 76d2dc87136d0a667678668b86f0fca0c16fdeb0
2222-
ReactNativeCameraKit: caf4175d93930ac5267fb98c462f5f1b8d543830
2222+
ReactNativeCameraKit: e542035174335357fd7d747089f0e09a4ed27365
22232223
RNSVG: 8a1054afe490b5d63b9792d7ae3c1fde8c05cdd0
22242224
RNVectorIcons: 941a39b5d3b9d8cf8ac2e2fc09b07bfafbcf9796
22252225
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748

Example/testHotUpdate/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
"dev:harmony": "react-native bundle-harmony --dev"
1515
},
1616
"dependencies": {
17-
"form-data": "^4.0.2",
17+
"form-data": "^4.0.3",
1818
"patch-package": "^8.0.0",
1919
"react": "19.0.0",
2020
"react-native": "0.79.2",
21-
"react-native-camera-kit": "^15.0.1",
21+
"react-native-camera-kit": "^15.1.0",
2222
"react-native-paper": "^5.14.5",
23-
"react-native-safe-area-context": "^5.4.1",
23+
"react-native-safe-area-context": "^5.5.0",
2424
"react-native-svg": "^15.12.0",
25-
"react-native-update": "^10.29.0",
25+
"react-native-update": "^10.29.4",
2626
"react-native-vector-icons": "^10.2.0"
2727
},
2828
"devDependencies": {

Example/testHotUpdate/update.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ios": {
3-
"appId": 24794,
4-
"appKey": "SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T"
3+
"appId": 28943,
4+
"appKey": "d-OmPxIBivPrDfKhLHjxN-HS"
55
},
66
"android": {
77
"appId": 27509,

ios/RCTPushy/RCTPushy.mm

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ + (NSURL *)bundleURL
9393
BOOL needRollback = (!ignoreRollback && isFirstTime == NO && isFirstLoadOK == NO) || loadVersion.length<=0;
9494
if (needRollback) {
9595
loadVersion = [self rollback];
96-
}
97-
else if (isFirstTime && !ignoreRollback){
96+
} else if (isFirstTime && !ignoreRollback){
9897
// bundleURL may be called many times, ignore rollbacks before process restarted again.
9998
ignoreRollback = true;
10099

@@ -302,34 +301,35 @@ - (instancetype)init
302301

303302

304303
resolve(@true);
305-
}else{
304+
} else {
306305
reject(@"执行报错", nil, nil);
307306
}
308307
}
309308

310309
RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options
311310
resolver:(RCTPromiseResolveBlock)resolve
312-
rejecter:(RCTPromiseRejectBlock)reject)
311+
rejecter:(RCTPromiseRejectBlock)reject)
313312
{
314313
@try {
315314
NSString *hash = options[@"hash"];
316315
if (hash.length) {
317-
[self setNeedUpdate:options resolver:resolve rejecter:reject];
318-
319-
// reload in earlier version
320-
dispatch_async(dispatch_get_main_queue(), ^{
321-
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
322-
[self.bridge reload];
323-
});
324-
325-
#if __has_include("RCTReloadCommand.h")
326-
// reload 0.62+
327-
RCTReloadCommandSetBundleURL([[self class] bundleURL]);
328-
RCTTriggerReloadCommandListeners(@"pushy reload");
329-
#endif
330-
331-
resolve(@true);
332-
}else{
316+
// 只在 setNeedUpdate 成功后 resolve
317+
[self setNeedUpdate:options resolver:^(id result) {
318+
// reload in earlier version
319+
dispatch_async(dispatch_get_main_queue(), ^{
320+
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
321+
[self.bridge reload];
322+
});
323+
#if __has_include("RCTReloadCommand.h")
324+
// reload 0.62+
325+
RCTReloadCommandSetBundleURL([[self class] bundleURL]);
326+
RCTTriggerReloadCommandListeners(@"pushy reload");
327+
#endif
328+
resolve(@true);
329+
} rejecter:^(NSString *code, NSString *message, NSError *error) {
330+
reject(code, message, error);
331+
}];
332+
} else {
333333
reject(@"执行报错", nil, nil);
334334
}
335335
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.29.4",
3+
"version": "10.29.5",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

0 commit comments

Comments
 (0)