realm-js: Compile-time Error: control may reach end of non-void function with Xcode 10.2
TL;DR
Thanks @AidenMontgomery.
- Open the source file at
${RN_PROJ}/node_modules/realm/src/jsc/jsc_value.hpp
. - Find the switch-case segment at THERE.
- Replace the whole switch-case segment with the following code.
switch (JSValueGetType(ctx, value)) {
case kJSTypeNull: return "null";
case kJSTypeNumber: return "number";
case kJSTypeObject: return "object";
case kJSTypeString: return "string";
case kJSTypeBoolean: return "boolean";
case kJSTypeUndefined: return "undefined";
case kJSTypeSymbol: return "symbol";
}
Goals
When I were compiling the React Native Project with Xcode, the compiler prompts an error.
Expected Results
No error.
Actual Results
/Users/***/***/***/node_modules/realm/src/jsc/jsc_value.hpp:54:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
Version of Realm and Tooling
- Realm JS SDK Version: 2.25.0
- React Native: 0.58.6
- Node: 10.15.2
- Client OS & Version: iOS 12.2.0
Temp Solution
- Open the source code:
${RN_PROJ}/node_modules/realm/src/jsc/jsc_value.hpp
; - Add
return "null";
between line 33 and 34.
I know this is not a good solution. So I am looking forward to the official solution.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 31
- Comments: 21 (5 by maintainers)
temp solution :
add
default: return "null";
between line 52 and 53,this working for me, waiting for the official solution
From what I can tell, and I’m probably wrong, there is a new entry in the JSType Enum kJSTypeSymbol which is not being handled in the switch statement. Therefore the switch is not handling all of the possible values returned by JSValueGetType
I don’t know what the effect of doing this will be, but I think that the solution is as follows…
This does mean that when/if a new value is added to the Enum again we will see the same issue, unless there is a default added, I just don’t know what that should do.
@mohammadalijf
I succeed to compile on XCode 10.1 with the fix you made in #2303
Indeed
kJSTypeSymbol
isn’t defined in JavaScriptCore in the iOS SDK 12.1.@ValeriiKov this was fixed in v2.26.1
@kneth I think this issue can be closed
when can we expect a new release guys?
Thanks to this issue and 2221, 2282 issues we switched to SQLite which was a longtime dream of our team. It is clear that realm can’t move fast enough to catch the ecosystem.
@sercand to be fair, the only way this would have been caught before the Xcode 10.2 public release is if someone noticed this in one of the Xcode 10.2 betas (I did notice this, and probably should have made a PR a long time ago). This was not documented in any SDK or Xcode release notes, at least from what I’ve seen. It was basically “out of the blue” since it was only added to the JavaScriptCore docs and no other documentation/release notes
same problem
Nope, I think you’re correct @AidenMontgomery . This change was introduced in iOS 12.3 (see #2246), which was included in the Xcode update that was released today.
Isn’t it related to https://github.com/realm/realm-js/issues/2246 ?