From 058ea3925373b8d5fedd78e252b49bdaa2d4e2a6 Mon Sep 17 00:00:00 2001 From: Omer Gery <68545675+OmerGery@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:44:12 +0200 Subject: [PATCH] fix ios 15.0.0 xcode build (#816) * Update Podfile * fix iso code fallback --- examples/client/Locomotion/ios/Podfile | 3 +++ .../src/Components/PhoneNumberInput/index.tsx | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/client/Locomotion/ios/Podfile b/examples/client/Locomotion/ios/Podfile index b328d1c14..71d1f36f1 100644 --- a/examples/client/Locomotion/ios/Podfile +++ b/examples/client/Locomotion/ios/Podfile @@ -47,6 +47,9 @@ target 'Locomotion' do react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION'] + end if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle" target.build_configurations.each do |config| config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' diff --git a/examples/client/Locomotion/src/Components/PhoneNumberInput/index.tsx b/examples/client/Locomotion/src/Components/PhoneNumberInput/index.tsx index b9e950486..f728d6391 100644 --- a/examples/client/Locomotion/src/Components/PhoneNumberInput/index.tsx +++ b/examples/client/Locomotion/src/Components/PhoneNumberInput/index.tsx @@ -1,5 +1,5 @@ import React, { useContext, useEffect, useState } from 'react'; -import PhoneInput from 'react-native-phone-number-input'; +import PhoneInput, { PhoneInputProps } from 'react-native-phone-number-input'; import Config from 'react-native-config'; import { AsYouType } from 'libphonenumber-js'; import { ThemeContext } from 'styled-components'; @@ -8,6 +8,9 @@ import i18n from '../../I18n'; import codes from './codes.json'; import { ERROR_COLOR } from '../../context/theme'; +type SupportIsoCode = PhoneInputProps['defaultCode']; +const ALL_SUPPORTED_ISO_CODES_FROM_LIB: SupportIsoCode[] = []; + const PhoneNumberInput = ({ onPhoneNumberChange, autoFocus, @@ -15,7 +18,7 @@ const PhoneNumberInput = ({ value, }: any) => { const [isFocused, setIsFocused] = useState(false); - const [defaultCode, setDefaultCode] = useState(null); + const [defaultCode, setDefaultCode] = useState(null); const theme = useContext(ThemeContext); const asYouTypePhoneNumber = new AsYouType(); @@ -28,11 +31,19 @@ const PhoneNumberInput = ({ asYouTypePhoneNumber.isValid(), ); }; + const getSafeIsoCode = (rawCode: string) : SupportIsoCode => { + const code = Config.OVERWRITE_COUNTRY_CODE || rawCode; + if (ALL_SUPPORTED_ISO_CODES_FROM_LIB.includes(code as SupportIsoCode)) { + return (code as SupportIsoCode); + } + return (Config.DEFAULT_COUNTRY_CODE as SupportIsoCode); + }; const setIsoCode = async () => { - const mobileIso = await getInputIsoCode(); + const rawMobileIso = await getInputIsoCode(); + const safeCode = getSafeIsoCode(rawMobileIso); setTimeout(() => { - setDefaultCode(Config.OVERWRITE_COUNTRY_CODE || mobileIso); + setDefaultCode(safeCode); }, 50); };