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

After Upgrade to SDK 33: undefined is not an object (evaluating '_expo Localization.Localization.locale') #5735

Closed
tinyGoldfish opened this issue Sep 22, 2019 · 42 comments 路 Fixed by #5740
Assignees

Comments

@tinyGoldfish
Copy link

馃悰 Bug Report

Hello,

after Upgrading to SDK 33 I got the following error: "undefined is not an object (evaluating '_expo2.default.registerRootComponent), but before upgrade everything was fine. I got the below errors,

it first popped up this error:
IMG_6665

then 3 seconds later changed to this:
IMG_E57C0E26D1E7-1

Environment

Expo CLI 3.1.0 environment info:
System:
OS: macOS 10.14.6
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - /usr/local/bin/node
Yarn: 1.17.0 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
expo: ^33.0.0 => 33.0.7
react: 16.8.3 => 16.8.3
react-native: https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz => 0.59.8
react-navigation: ^3.11.0 => 3.12.1
npmGlobalPackages:
expo-cli: 3.1.0

app's target: iOS

I just started learning Expo, please let me know if I need to provide more details.

Thanks very much,
SK

@tinyGoldfish tinyGoldfish changed the title undefined is not an object (evaluating '_expo Localization.Localization.locale') After Upgrade to SDK 33: undefined is not an object (evaluating '_expo Localization.Localization.locale') Sep 22, 2019
@andersravn
Copy link

Did you run expo install expo-localization and import it as import * as Localization from 'expo-localization';? As per the docs: https://docs.expo.io/versions/v33.0.0/sdk/localization/.

@kevinvugts
Copy link

kevinvugts commented Sep 23, 2019

Did you run expo install expo-localization and import it as import * as Localization from 'expo-localization';? As per the docs: https://docs.expo.io/versions/v33.0.0/sdk/localization/.

I also experiencing this error.

https://ibb.co/C5VGw0k

When is this on the pipeline to be fixed?

@tsapeta
Copy link
Member

tsapeta commented Sep 23, 2019

How do you import Localization module? Also, please remember about showing us an example code that will help us to reproduce the bug you're having.

@slauzinho
Copy link

slauzinho commented Sep 23, 2019

I'm also having the same issue.

SDK 35
iOS 13
expo-localization: 7.0.0

Here is a code example:

import * as Localization from 'expo-localization';
const userLocaleCountryCode = Localization.country;

Screenshot 2019-09-23 at 10 07 34

@kevinvugts
Copy link

kevinvugts commented Sep 23, 2019

How do you import Localization module? Also, please remember about showing us an example code that will help us to reproduce the bug you're having.

As you stated above.

Might be usefull while debugging

It all happened after upgrading to xcode 13

@lukmccall lukmccall self-assigned this Sep 23, 2019
@lukmccall
Copy link
Contributor

Hi @slauzinho, Localization.country was changed to Localization.region and it's only available on iOS (in SDK 35).

@serhiipalash
Copy link
Contributor

serhiipalash commented Sep 23, 2019

It all happened after upgrading to xcode 13

I can confirm that this bug only happens in iOS 13 simulator and in iOS 12.2 simulator everything works fine. Plus, this bug affects not only SDK 33, but also 34 and 35.

In SDK 34 app crashes in this line https://github.com/expo/expo/blob/master/packages/expo-localization/build/Localization.js#L4

Simulator Screen Shot - iPhone 8 - 2019-09-22 at 20 37 31

@serhiipalash
Copy link
Contributor

It all happened after upgrading to xcode 13

@kevinvugts you can install iOS 12.2 in your new Xcode 13 and use its Simulator to continue your work today.

@andersravn
Copy link

Just to be clear. You guys mean Xcode 11 right? I guess you are confusing it with iOS 13.

@kevinvugts
Copy link

It all happened after upgrading to xcode 13

@kevinvugts you can install iOS 12.2 in your new Xcode 13 and use its Simulator to continue your work today.

Sure. Already did that. @andersravn I mean xCode 11 right. Sorry for the misconception

@tinyGoldfish
Copy link
Author

Did you run expo install expo-localization and import it as import * as Localization from 'expo-localization';? As per the docs: https://docs.expo.io/versions/v33.0.0/sdk/localization/.

Yes I did, and I tried both iOS 13 and iOS 12.4.1 also not working.

@lukmccall
Copy link
Contributor

I've created PR which may fix it.

However, it will be nice if you go to settings > general > language and region in your iOS simulator and update region setting. Then let me know if the Localization module starts working correctly.

@serhiipalash
Copy link
Contributor

You guys mean Xcode 11 right?

Yes, we do. Sorry, I was confused with first message about it.

@serhiipalash
Copy link
Contributor

However, it will be nice if you go to settings > general > language and region in your iOS simulator and update region setting. Then let me know if the Localization module starts working correctly.

It helps. After updating region all future app starts, even if you kill the simulator, don't crash.

@tinyGoldfish
Copy link
Author

I've created PR which may fix it.

However, it will be nice if you go to settings > general > language and region in your iOS simulator and update region setting. Then let me know if the Localization module starts working correctly.

Hi thanks! But sorry it still does not work for me, I tried both on my iphones iOS 12.4.1 & iOS13, and iOS 12.2 simulator on Xcode, all still got the same error.

@tinyGoldfish
Copy link
Author

I've created PR which may fix it.

However, it will be nice if you go to settings > general > language and region in your iOS simulator and update region setting. Then let me know if the Localization module starts working correctly.

Would there be any hot fixes for iphone testing directly as well? Many thanks!

@lukmccall
Copy link
Contributor

Hi @tinyGoldfish, could you check if this bug occurred in iOS 13.1?
Please provide me with some information, because I'm struggling with reproducing this bug.

@serhiipalash
Copy link
Contributor

serhiipalash commented Sep 25, 2019

@lukmccall there is no iOS 13.1 in Xcode 11, at least for now, but I tried to run our app in Expo app on my iPhone with iOS 13.1 and everything works fine. Also, as I understood, the bug happens only in iOS 13 Simulator.

@serhiipalash
Copy link
Contributor

the bug happens only in iOS 13 Simulator.

not in standalone or Expo-client app

@superKalo
Copy link

superKalo commented Sep 25, 2019

@serhiipalash , it happens on our side too. Both - in simulator and Expo-client (on a real device). iOS 13.0. However, iOS 12 - all good.

Happens right after when you install the latest Expo-client on the simulator.

As soon as my code reaches this point: Localization.locale the error appears.

@serhiipalash
Copy link
Contributor

@superKalo I've read your post and I don't see how it is related to this issue. This issue is about expo-localization module and not about react-native-svg, which is your post about.

@superKalo
Copy link

@superKalo I've read your post and I don't see how it is related to this issue. This issue is about expo-localization module and not about react-native-svg, which is your post about.

Sorry, I shared wrong issue. Please see my updated comment above.

@tinyGoldfish
Copy link
Author

Hi @tinyGoldfish, could you check if this bug occurred in iOS 13.1?
Please provide me with some information, because I'm struggling with reproducing this bug.

Hi @lukmccall , thanks for the follow up, just tried again with the iOS 13.1 on my iphone, it's not working on my project neither...got the same error.
Yes sure, what kind of other information you would like me to provide? Thanks a lot!

@superKalo
Copy link

@lukmccall do you think this issue happens on iOS simulator (iOS v13.0) only?

I tried to publish same app (which displays this error) on a different release channel and I opened it on a real device (iPhone, iOS v13.0) via Expo-client. It works just fine. I wonder if this error will appear on the standalone app, if I decide to update.

@bit-scrambler
Copy link

As per my understanding the problem is that if the phone (either device or simulator) has the default language because the user didn't set it, all the language properties like timezone, country, currency and so on are undefined raising the exception
I'm able to reproduce the issue with iOS13 on a fresh simulator or on some devices.
Changing the language in "settings" to English/UK or English/US, the Localization.* properties are set properly.

@lukmccall
Copy link
Contributor

@superKalo I think @bit-scrambler is right. This bug can occur not only in simulators.

For now, I've added a fallback value to locale property. Unfortunately, I don't know when a new version with the fix will be available.

@serhiipalash
Copy link
Contributor

For now, I've added a fallback value to locale property.

@lukmccall do you mean that locale, timezone, currency properties could be undefined?

@lukmccall
Copy link
Contributor

@serhiipalash, I was talking only about locale and locales properties. For some reason, iOS's function which should get system locale value return null.

@serhiipalash
Copy link
Contributor

@lukmccall thanks for explanation, I just want to be sure that at least region still works and we can resolve app locale by region when user starts the app first time. Did you test region? Showing users app not in their native language will downgrade users retention a lot :(

@lukmccall
Copy link
Contributor

@serhiipalashu unfortunately, region could fail too. Sorry for misleading you about this.

To sum everything up, locale, locales and region properties may not work correctly on iOS 13. I've added fallback values to locale and locales which should prevent an app from crashing. On the other hand, the region could be null.

For now, we should wait for a system patch.

@jazzy-pm
Copy link

jazzy-pm commented Oct 3, 2019

I am using localization only for I18nManager. Below you can find the code. The above issue is only coming for iPhone pro 11 max and the other version before this are working fine.

import * as Localization from "expo-localization";
....
 loadFonts = async () => {
    await Font.loadAsync({
      icomoon: require("@assets/fonts/icomoon.ttf"),
      Roboto_medium: require("../node_modules/native-base/Fonts/Roboto_medium.ttf")
    });
    const { isRTL } = await Localization.getLocalizationAsync();
    I18nManager.forceRTL(isRTL);
    await I18n.initAsync();
  };
....

@holgersindbaek
Copy link

Can anyone confirm that this is NOT happening in production apps?

@jacekd
Copy link

jacekd commented Oct 7, 2019

@holgersindbaek I have an app in production and so far we have no problems with any of the iOS 13 devices.

tsapeta pushed a commit that referenced this issue Oct 15, 2019
# Why

Resolve #5735.

# How

Wrapped `region` variable into UMNullIfNil macro, because `[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode]` could return nil on iOS simulator.
@morer62
Copy link

morer62 commented Oct 16, 2019

In your simulator go to settings > General > Language & Region and pick the United State as a region ...... If your region is already US, you have to click again in united States and Update

@CruelMoney
Copy link

Just got this on sdk 35 in the simulator, but after uograding to 36 it seems to be fixed 馃憣

@feliperaul
Copy link

@tsapeta Tomasz, won't this fix be backported to SDK 33, since it's still a supported SDK?

Just upgraded my XCode and I see the crash on my simulator.

Also, can the expo team confirm this won't affect real devices, only the simulator?

@marcelxsilva
Copy link

worked for me, here's what needs to be done: https://docs.expo.io/versions/latest/sdk/svg/

@sarcadass
Copy link

Capture d鈥檈虂cran 2020-05-07 a虁 17 07 38

I still experience the problem here when I start a simulator for the first time without setting the region on the iPhone preferences. If the problem happen only on the Simulator it's not such a big deal as the solution is to set the region in the simulator preferences (even if a fix will be appreciated).
But if it happen too on real devices it's a critical bug, I don't have an iPhone on me so I can't test if the bug occur on real devices.

Is it possible to check if locale is not undefined before calling the replace() method?
And if locale is undefined you can fallback to English as it is the default language on the Simulator when you didn't set the region (locale = locale || 'en-en').

@lukmccall
Copy link
Contributor

@sarcadass, #8193 should fix it ;)

@drpiou
Copy link

drpiou commented Feb 22, 2021

So, hum hum, SDK 40, just as simple as that with real iOS device:

import * as Localization from 'expo-localization';

console.log({ Localization });

throws : Cannot read property 'locale' of undefined.

And no, I didn't opened "Settings > General > Language & Region" because I do not expect my app users to do so on their side, it would be ugly to mention anything like that to anyone.

@DamianBarrionuevo
Copy link

I have a similar problem but I've been trying to fix it for a long time and I can't.
If they could help me they would save my time

image

image

@dbalatoni13
Copy link

dbalatoni13 commented Oct 22, 2021

@DamianBarrionuevo I had the same problem on Android 11. The problem was that I forgot to rerun expo run:android after installing expo-localization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.