Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile-time Error: control may reach end of non-void function with Xcode 10.2 #2305

Closed
s1ro6 opened this issue Mar 26, 2019 · 21 comments
Closed

Comments

@s1ro6
Copy link

s1ro6 commented Mar 26, 2019

TL;DR

Thanks @AidenMontgomery.

  1. Open the source file at ${RN_PROJ}/node_modules/realm/src/jsc/jsc_value.hpp.
  2. Find the switch-case segment at THERE.
  3. 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

  1. Open the source code: ${RN_PROJ}/node_modules/realm/src/jsc/jsc_value.hpp;
  2. 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.

@HengCC
Copy link

HengCC commented Mar 26, 2019

@Joyreece
similar problem, Today i upgrade system version to 10.14.4 and xcode version to 10.2,
After that, it will not work properly.This problem has been wasted my half-day time, The error message is as follows:

The following build commands failed:
	CompileC /Users/xxx/workspace/yqplus_app/ios/build/Build/Intermediates.noindex/RealmJS.build/Debug-iphonesimulator/RealmJS.build/Objects-normal/x86_64/jsc_value.o jsc/jsc_value.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler

your solution doesn't work for me.

@HengCC
Copy link

HengCC commented Mar 26, 2019

temp solution :

add default: return "null"; between line 52 and 53,

template<>
inline const char *jsc::Value::typeof(JSContextRef ctx, const JSValueRef &value) {
    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";
        default: return "null";
    }
    
}

this working for me, waiting for the official solution

@AidenMontgomery
Copy link

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...

inline const char *jsc::Value::typeof(JSContextRef ctx, const JSValueRef &value) {
    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";
    }
}

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.

@sinhpn92
Copy link

I have same isssue :(

@ericschaal
Copy link

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...

inline const char *jsc::Value::typeof(JSContextRef ctx, const JSValueRef &value) {
    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";
    }
}

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.

makes sense

@ghost
Copy link

ghost commented Mar 26, 2019

Isn't it related to #2246 ?

@rajivshah3
Copy link
Contributor

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.

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.

@StevenMasini
Copy link

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.

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.

Same conclusion here.

Did someone make a Pull Request for this change ?

@mohammadalijf
Copy link
Contributor

@StevenMasini yeah i made the Pull Request #2303 but no luck so far. also if anyone can check if PR is working with Xcode version below 10.2 would be great.

@StevenMasini
Copy link

@mohammadalijf Ok let me check if that work on XCode 10.1.

@StevenMasini
Copy link

StevenMasini commented Mar 28, 2019

@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.

#if defined __IPHONE_12_2 || defined __MAC_10_14_4
     case kJSTypeSymbol: return "symbol";
#endif

@008v
Copy link

008v commented Mar 28, 2019

same problem

@mohammadalijf
Copy link
Contributor

@StevenMasini thank you steven 👍

@sercand
Copy link

sercand commented Mar 30, 2019

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.

@rajivshah3
Copy link
Contributor

@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

@nonewcode
Copy link

when can we expect a new release guys?

@iamawaisakram
Copy link

@Joyreece I do not have realm in my node_modules! Any alternatives?

@s1ro6
Copy link
Author

s1ro6 commented Apr 2, 2019

@Joyreece I do not have realm in my node_modules! Any alternatives?

Hi, bro.
You may have already installed it in the global environment.
Use the npm -g list | grep realm to check if it is in the global environment.

If it does, I still recommend that install into the project environment with following commands.

cd <PROJECT_PATH>
npm install --save realm

DO NOT miss the --save option~ :)

@edritech93
Copy link

same issue for me

@ValeriiKov
Copy link

so, WHEN can we expect a new release guys?

@rajivshah3
Copy link
Contributor

@ValeriiKov this was fixed in v2.26.1

@kneth I think this issue can be closed

@kneth kneth closed this as completed Apr 23, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests