avishayil / react-native-restart

React Native Package With One Purpose: To Restart Your React Native Project
MIT License
941 stars 149 forks source link

iOS Compilation error in 0.0.18 #151

Closed beetlebum closed 3 years ago

beetlebum commented 3 years ago

After upgrading to 0.0.18 I'm getting the following error when compiling my app for iOS:


/ios/Restart.m:9:38: error: too few arguments to function call, single argument 'reason' was not specified
    RCTTriggerReloadCommandListeners();
csantos1113 commented 3 years ago

Same issue here.

XCode: 12 RN: 0.63

avishayil commented 3 years ago

Publish v0.0.19

aminhdev commented 3 years ago

After upgrading to 0.0.19 I'm getting the following error when compiling my app for iOS:

/node_modules/react-native-restart/ios/Restart.m:9:38: error: too many arguments to function call, expected 0, have 1 RCTTriggerReloadCommandListeners(@"react-native-restart: Restart");

"react": "16.9.0" "react-native": "0.61.5" "react-native-restart": "0.0.17"

Xcode: 12.3

Note: Downgrade to 0.0.17 fixed my problem

avishayil commented 3 years ago

In my tests removing the reason solved the problem, but for others it didn't. I deprecated 0.0.19 in the meanwhile

beetlebum commented 3 years ago

The reason is necessary in the latest versions of React Native: void RCTTriggerReloadCommandListeners(NSString *reason) The changes was introduced in October 2019, https://github.com/facebook/react-native/commit/2a13f121060b9aeda96ed424901156c617bfe6ce#diff-6949450901d2737f9bdbc690d57bab78ac0d966243fa63e0bc6a8425c418ebec

The user above is using React Native 0.61, there should be two versions of this library for 0.62 and above and below.

avishayil commented 3 years ago

@beetlebum thanks. Got an idea how to detect the RN version on the native code?

beetlebum commented 3 years ago

@beetlebum thanks. Got an idea how to detect the RN version on the native code?

I think you could just leave 0.18 for users on 0.61 and below and re release 0.19 with a warning on the README

avishayil commented 3 years ago

I prefer creating a solution with backwards compatibility, but if I won't find one I'll fall back to README

csantos1113 commented 3 years ago

~I wonder if we can do something like this: https://github.com/tessus/react-native-version-info/blob/9593b559f8a325a18c3e1ffa834fba915c8e09e1/ios/RNVersionInfo.m#L19~ nvm, this is not what I thought it was

UPDATE: After researching about this, I'm not sure how can we have this backwards compatible if the function's typedef has changed?

RCT_EXTERN void RCTTriggerReloadCommandListeners(void);

vs

RCT_EXTERN void RCTTriggerReloadCommandListeners(NSString *reason);

Even if we're able to identify the RN version (I'm not sure how), we'll still have build-time errors, won't we?

csantos1113 commented 3 years ago

I prefer creating a solution with backwards compatibility, but if I won't find one I'll fall back to README

we should probably update react-native version in the package.json to 0.62 though

jpmc3630 commented 3 years ago

I have a bit of a legacy app running react-native: 0.60.3

Ran into the iOS build error with react-native-restart: 0.0.22 /node_modules/react-native-restart/ios/Restart.m:9:38: error: too many arguments to function call, expected 0, have 1 RCTTriggerReloadCommandListeners(@"react-native-restart: Restart");

is downgrading to react-native-restart: 0.0.18 still the recommended approach?

jpmc3630 commented 3 years ago

Seems with react-native-restart: 0.0.18
iOS isn't restarting in production release, not throwing error, just not restarting. It is working in dev/debug build. Android version is working in both as expected.