Realm-js: Changes in iOS 12.3 may break builds

Created on 6 Feb 2019  路  9Comments  路  Source: realm/realm-js

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:
https://github.com/realm/realm-js/blob/91d87fe0a94ae3101b6bb57f33c8d64ed96465d6/src/jsc/jsc_value.hpp#L44-L54

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
O-Community T-Bug

Most helpful comment

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

All 9 comments

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

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

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

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/

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

@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 https://github.com/realm/realm-js/issues/2305#issuecomment-476552419?

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

Fixed in #2303

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

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

Was this page helpful?
0 / 5 - 0 ratings