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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in iOS 12.3 may break builds #2246

Closed
rajivshah3 opened this issue Feb 6, 2019 · 9 comments
Closed

Changes in iOS 12.3 may break builds #2246

rajivshah3 opened this issue Feb 6, 2019 · 9 comments

Comments

@rajivshah3
Copy link
Contributor

Description

(please don't kill me for not following the template 馃槃- this is more of a "heads up" than a bug report)

In iOS 12.3, it looks like Apple is introducing a new type called symbol to the JavaScriptCore API:
(from /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSValueRef.h)

/*!
@enum JSType
@abstract     A constant identifying the type of a JSValue.
@constant     kJSTypeUndefined  The unique undefined value.
@constant     kJSTypeNull       The unique null value.
@constant     kJSTypeBoolean    A primitive boolean value, one of true or false.
@constant     kJSTypeNumber     A primitive number value.
@constant     kJSTypeString     A primitive string value.
@constant     kJSTypeObject     An object value (meaning that this JSValueRef is a JSObjectRef).
@constant     kJSTypeSymbol     A primitive symbol value.
*/
typedef enum {
    kJSTypeUndefined,
    kJSTypeNull,
    kJSTypeBoolean,
    kJSTypeNumber,
    kJSTypeString,
    kJSTypeObject,
    kJSTypeSymbol API_AVAILABLE(macosx(10.14.4), ios(12.3))
} JSType;

This has certain consequences for Realm:

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";
}
}

Since the kJSTypeSymbol enum value is not handled in the above switch statement, builds on Xcode 10.2 Beta (10P82s) will fail with this error:
image

I was able to resolve the error by adding this:

case kJSTypeSymbol: return "symbol";

I'm not sure what side effects that change has so I haven't made a PR yet.

Version of Realm and Tooling

  • Realm JS SDK Version: 2.21.1
  • Node or React Native: React Native
  • Client OS & Version: Building for iOS 12.2 (so I'm not sure why this issue is occuring with API_AVAILABLE(macosx(10.14.4), ios(12.3)))
  • Which debugger for React Native: None
@kneth
Copy link
Member

kneth commented Feb 7, 2019

@rajivshah3 Thanks for the update. We are in the process of updating and preparing our CI system with the latest Apple releases (still waiting for next Xcode version).

@yurnery
Copy link

yurnery commented Mar 26, 2019

it builds failure after i upgrade to XCode 10.2, should i fix it myself?

@reyalpsirc
Copy link

Indeed, the builds are failing with latest XCode 10.2 with the error of "control may reach end of non-void function"

@majirosstefan
Copy link

majirosstefan commented Mar 26, 2019

same here, Enumeration value 'kJSTypeSymbol' not handled in switch ==> "control may reach end of non-void function" leads to Realm build fail

Quick workaround is to use xcode 10.1 (build is passing in 10.1), can be downloaded here https://developer.apple.com/downloads/more/

@APSRaphael
Copy link

Got the same problem, it looks like surely upgrade XCode to 10.2 cause the error.

@rajivshah3
Copy link
Contributor Author

rajivshah3 commented Mar 27, 2019

@kneth it looks like Xcode 10.2 was released to the public today. Should I do a PR adding case kJSTypeSymbol: return "symbol"; or a default case as suggested in #2305 (comment)?

Edit: Looks like someone beat me to it 馃槃 #2303

@rajivshah3
Copy link
Contributor Author

Fixed in #2303

@shivkrishnashah
Copy link

shivkrishnashah commented May 9, 2019

Fixed By Adding

case kJSTypeSymbol: return "symbol";

Example

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";
}

@quangcanh2975
Copy link

Fixed By Adding

case kJSTypeSymbol: return "symbol";

Example

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";
}

@shivkrishnashah Thank you so much! It worked for me

@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

10 participants