Skip to content

Commit 6a0a5b2

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

File tree

7 files changed

+51
-49
lines changed

7 files changed

+51
-49
lines changed

Example/testHotUpdate/bun.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"": {
55
"name": "testHotUpdate",
66
"dependencies": {
7-
"form-data": "^4.0.2",
7+
"form-data": "^4.0.3",
88
"patch-package": "^8.0.0",
99
"react": "19.0.0",
1010
"react-native": "0.79.2",
11-
"react-native-camera-kit": "^15.0.1",
11+
"react-native-camera-kit": "^15.1.0",
1212
"react-native-paper": "^5.14.5",
13-
"react-native-safe-area-context": "^5.4.1",
13+
"react-native-safe-area-context": "^5.5.0",
1414
"react-native-svg": "^15.12.0",
15-
"react-native-update": "^10.29.0",
15+
"react-native-update": "^10.29.4",
1616
"react-native-vector-icons": "^10.2.0",
1717
},
1818
"devDependencies": {
@@ -886,7 +886,7 @@
886886

887887
"for-each": ["[email protected]", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="],
888888

889-
"form-data": ["[email protected].2", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "mime-types": "^2.1.12" } }, "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w=="],
889+
"form-data": ["[email protected].3", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA=="],
890890

891891
"fresh": ["[email protected]", "", {}, "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="],
892892

@@ -1412,15 +1412,15 @@
14121412

14131413
"react-native": ["[email protected]", "", { "dependencies": { "@jest/create-cache-key-function": "^29.7.0", "@react-native/assets-registry": "0.79.2", "@react-native/codegen": "0.79.2", "@react-native/community-cli-plugin": "0.79.2", "@react-native/gradle-plugin": "0.79.2", "@react-native/js-polyfills": "0.79.2", "@react-native/normalize-colors": "0.79.2", "@react-native/virtualized-lists": "0.79.2", "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", "babel-jest": "^29.7.0", "babel-plugin-syntax-hermes-parser": "0.25.1", "base64-js": "^1.5.1", "chalk": "^4.0.0", "commander": "^12.0.0", "event-target-shim": "^5.0.1", "flow-enums-runtime": "^0.0.6", "glob": "^7.1.1", "invariant": "^2.2.4", "jest-environment-node": "^29.7.0", "memoize-one": "^5.0.0", "metro-runtime": "^0.82.0", "metro-source-map": "^0.82.0", "nullthrows": "^1.1.1", "pretty-format": "^29.7.0", "promise": "^8.3.0", "react-devtools-core": "^6.1.1", "react-refresh": "^0.14.0", "regenerator-runtime": "^0.13.2", "scheduler": "0.25.0", "semver": "^7.1.3", "stacktrace-parser": "^0.1.10", "whatwg-fetch": "^3.0.0", "ws": "^6.2.3", "yargs": "^17.6.2" }, "peerDependencies": { "@types/react": "^19.0.0", "react": "^19.0.0" }, "optionalPeers": ["@types/react"], "bin": { "react-native": "cli.js" } }, "sha512-AnGzb56JvU5YCL7cAwg10+ewDquzvmgrMddiBM0GAWLwQM/6DJfGd2ZKrMuKKehHerpDDZgG+EY64gk3x3dEkw=="],
14141414

1415-
"react-native-camera-kit": ["react-native-camera-kit@15.0.1", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-JAa/2m73vKRp9oJ6ynYDr2KIIbglUbXYmDmsUrxLdk820eMGfxlb2HukqmVrkwt9KgX5vlBWoDHys3dhmrqa/w=="],
1415+
"react-native-camera-kit": ["react-native-camera-kit@15.1.0", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-4gPOJAoWAj9WaiNxPgKFYa/+M79O/Ggvc271SGgH5TmetmtinctJFm2zxeg+bAxVS9TDIYcF3ojRD98n88+VEw=="],
14161416

14171417
"react-native-paper": ["[email protected]", "", { "dependencies": { "@callstack/react-theme-provider": "^3.0.9", "color": "^3.1.2", "use-latest-callback": "^0.2.3" }, "peerDependencies": { "react": "*", "react-native": "*", "react-native-safe-area-context": "*" } }, "sha512-eaIH5bUQjJ/mYm4AkI6caaiyc7BcHDwX6CqNDi6RIxfxfWxROsHpll1oBuwn/cFvknvA8uEAkqLk/vzVihI3AQ=="],
14181418

1419-
"react-native-safe-area-context": ["react-native-safe-area-context@5.4.1", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-x+g3NblZ9jof8y+XkVvaGlpMrSlixhrJJ33BRzhTAKUKctQVecO1heSXmzxc5UdjvGYBKS6kPZVUw2b8NxHcPg=="],
1419+
"react-native-safe-area-context": ["react-native-safe-area-context@5.5.0", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-BQcSvVEJj3T4zBQH9YrnlfcLGHiVOsmeiE10PSBsmI/xyzULSZdJISFOH0HLcLU7/nePC+HsaaVzIsEa1CVBYw=="],
14201420

14211421
"react-native-svg": ["[email protected]", "", { "dependencies": { "css-select": "^5.1.0", "css-tree": "^1.1.3", "warn-once": "0.1.1" }, "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-iE25PxIJ6V0C6krReLquVw6R0QTsRTmEQc4K2Co3P6zsimU/jltcDBKYDy1h/5j9S/fqmMeXnpM+9LEWKJKI6A=="],
14221422

1423-
"react-native-update": ["[email protected].0", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-TFGwJxI62OHPJimxMnI8PDvUBhZio1alsgIvXHYh1oYAZYYejkUvwl+Ojdbm58IKoZzxAaT7RvD1qGdvlg/oKg=="],
1423+
"react-native-update": ["[email protected].4", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-leQX3dq4yBi/oFn0l06nXd7OOFnZnlcMIrAXH7vgTRsqXCdYLoSsZXXkcSYxncn8tBqzh02w4880mlqouve6Sg=="],
14241424

14251425
"react-native-url-polyfill": ["[email protected]", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="],
14261426

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)