facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.17k stars 24.32k forks source link

'value' is unavailable: introduced in iOS 12.0 #34106

Closed orzhtml closed 1 year ago

orzhtml commented 2 years ago

Description

'value' is unavailable: introduced in iOS 12.0

Version

0.69.0

Output of npx react-native info

System: OS: macOS 10.15.7 CPU: (4) x64 Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz Memory: 27.26 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.17.0/bin/yarn npm: 8.4.1 - ~/.nvm/versions/node/v14.17.0/bin/npm Watchman: 4.7.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 23, 25, 26, 27, 28, 29, 30 Build Tools: 26.0.2, 26.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.3 System Images: android-25 | Google APIs ARM EABI v7a, android-29 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_152 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.0 => 0.69.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

npx react-native init example --template react-native-template-typescript

yarn start

open xcode run

Snack, code example, screenshot, or link to a repository

image

orzhtml commented 1 year ago

This solution worked for me with Xcode 14.3RC

https://stackoverflow.com/a/74487309

image This worked like magic.

iamromec commented 1 year ago

This is happening with Xcode Cloud when you have Xcode set to 14.3RC, if you change it to 14.2 you are good to go.

I wonder if this is due to changes in Swift 5.8.

How to change this? Steps?

kelset commented 1 year ago

Hey folks, just an headsup: we already landed the change that fixes this correctly in https://github.com/facebook/react-native/pull/36759 and we are about to release the supported versions of React Native with their right fixes:

Expect them to land later this week.

cn-johndpope commented 1 year ago

not sure what's going on - but I had to change target from 12.4 -> 13 to fix problem with redefinition of timer. Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t') when building latest react-native rc with macOS target

  post_install do |installer|
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_13_0/' Pods/RCT-Folly/folly/portability/Time.h`
     react_native_post_install(installer)
    __apply_Xcode_14_3_RC_post_install_workaround(installer)
  end

UPDATE - this is flacky - not really working...

https://github.com/facebook/flipper/issues/834

Zagorevsky commented 1 year ago

Hi! This solution helped me a lot!

kelset commented 1 year ago

👋 everyone!

We have just finished rolling out new patch releases for the versions in the release support window to address this problem, check them out:

They should address this problem fully.

WyrdRaven commented 1 year ago

I upgraded from v0.70.5 -> v0.70.8 and I'm still getting the error :(

For instance, in (ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h:2598:110):

d[@"DEFAULT_BACKGROUND_COLOR"] = DEFAULT_BACKGROUND_COLOR.has_value() ? @((double)DEFAULT_BACKGROUND_COLOR.value()) : nil;
       |                                                                                                              ^ 'value' is unavailable: introduced in iOS 12.0
liamjones commented 1 year ago

@WyrdRaven did you remember to pod install after the upgrade? The fix needs to change a setting in the Pods xcodeproj file.

BrotskyS commented 1 year ago

Just don't install new versions of Xcode in the early days)) What are you hoping for?

asindhu commented 1 year ago

I upgraded from v0.70.5 -> v0.70.8 and I'm still getting the error :(

For instance, in (ios/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h:2598:110):

d[@"DEFAULT_BACKGROUND_COLOR"] = DEFAULT_BACKGROUND_COLOR.has_value() ? @((double)DEFAULT_BACKGROUND_COLOR.value()) : nil;
       |                                                                                                              ^ 'value' is unavailable: introduced in iOS 12.0

I had the same issue, applied the same fix (upgrade from v0.70.6 to v0.70.8) and still have the issue again as well. I'm not all that familiar with the Expo build environment yet but I tried to reset/clean everything as much as possible. I fully removed the ios build directory, then ran npx expo prebuild --clean followed by npx expo run:ios and get the exact same error still. Tried running pod install in the ios directory too, that works without error. I confirmed that react-native package is now at 0.70.8 version. Any ideas? Thanks.

jakobvase commented 1 year ago

👋 everyone!

We have just finished rolling out new patch releases for the versions in the release support window to address this problem, check them out:

* https://github.com/facebook/react-native/releases/tag/v0.71.6

* https://github.com/facebook/react-native/releases/tag/v0.70.8

* https://github.com/facebook/react-native/releases/tag/v0.69.9

They should address this problem fully.

This worked for me, after npm install, bundle install and pod install. Thanks kelset!

MelMayssonOwen commented 1 year ago

Just had this issue and applying the change to all the pods didn't cut it for me. So instead that's what worked for me.

# Fix for use_frameworks! :linkage => :static
      react_native_post_install(installer)
      installer.pods_project.targets.each do |target|
        if target.name == 'RCT-Folly'
          target.build_configurations.each do |config|
            config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
          end
        end
--------> // added this
      # Change the deployment target to 12.4 for React-Codegen
        if target.name == 'React-Codegen'
          target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
          end
        end
      end
<-------
      # __apply_Xcode_12_5_M1_post_install_workaround(installer)
      installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
cn-johndpope commented 1 year ago

downgrading to xcode 14.2 also working.

canpoyrazoglu commented 1 year ago

Yup. Upgrading from 0.71.4 to 0.71.6 fixes this issue.

ahmad-ali14 commented 1 year ago

Here's how I fixed it:

  1. Open node_modules/react-native/scripts/react_native_pods.rb
  2. Go to line no 401 >>> 'ios' => '11.0',
  3. Change 11.0 to 12.0
  4. Use patch-package to make a patch.
  5. Run yarn
  6. Run pod install
  7. Go to ios/build/generated/ios/React-Codegen.podspec.json and confirm "platforms": { "ios": "12.0" }

That's all.

diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb
index 7f6ebab..cea0fef 100644
--- a/node_modules/react-native/scripts/react_native_pods.rb
+++ b/node_modules/react-native/scripts/react_native_pods.rb
@@ -398,7 +398,7 @@ def get_react_codegen_spec(options={})
     'source' => { :git => '' },
     'header_mappings_dir' => './',
     'platforms' => {
-      'ios' => '11.0',
+      'ios' => '12.0',
     },
     'source_files' => "**/*.{h,mm,cpp}",
     'pod_target_xcconfig' => { "HEADER_SEARCH_PATHS" =>

Thank you very much; this was super helpful.

ElectricCoffee commented 1 year ago

👋 everyone! We have just finished rolling out new patch releases for the versions in the release support window to address this problem, check them out:

* https://github.com/facebook/react-native/releases/tag/v0.71.6

* https://github.com/facebook/react-native/releases/tag/v0.70.8

* https://github.com/facebook/react-native/releases/tag/v0.69.9

They should address this problem fully.

This worked for me, after npm install, bundle install and pod install. Thanks kelset!

Unfortunately this only fixed things for me for the React Native stuff. I guess I'll have to make an issue on Quick Crypto to get them to fix the same issue.

kelset commented 1 year ago

thanks everyone! Sounds like for RN the issue is addressed, if you have similar issues but in separate libraries please open issues and PRs to them directly!

devpenzil commented 1 year ago

https://stackoverflow.com/a/75915794/12105742

This solution works for me

hungdev commented 1 year ago

https://stackoverflow.com/a/75915794/12105742

This solution works for me

thank you, it worked for me

diegoamorim-cs commented 1 year ago

https://stackoverflow.com/a/75915794/12105742

This solution works for me

Thank's, it worked

anshif10 commented 1 year ago

if anybody with with react native 0.70 still facing this issue please upgrade to latest react native version 1.npx react-native upgrade

  1. cd ios
  2. pod install
  3. Reopen xcode and build
eliot-ye commented 1 year ago

https://mrdevgeek.com/xcode-14-3-simulator-16-4-build-failure-how-to-fix-value-is-unavailable-introduced-in-ios-12-0-error-with-react-native-0-71-5/

work for me

tahagates97 commented 1 year ago

@eliot-ye is great works like a charm believe

sureco-doug commented 1 year ago

@OmarUsman777

I think If you set like this in Podfile, you don't have to change them manually everytime.

  ...
  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    # NOTE: Change IPHONEOS_DEPLOYMENT_TARGET to 12.4.
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      end
    end
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

@kouhot 's solution worked for me. Had to add this to Podfile and then Clean and run pod install again, and everything worked without error. Thanks kouhot!

hlspablo commented 1 year ago

Guys, don't do anything fancy, just update to the latest minor version, delete pods, Podfile.lock, reinstall the pods with pod install --repo-update, and everything should work. See

Emekaony commented 1 year ago

In iOS Folder go to Pods/Pods.xcodeproj/xcuserdata/project.pbxproj

Change all the 'IPHONEOS_DEPLOYMENT_TARGET = 11.0' to 'IPHONEOS_DEPLOYMENT_TARGET = 12.4'. save and run.

Note: every time you pod install it will change so again you have to do it. If there is better approach please do mention.

is there a better way to do this? an automated way via cmd line? I have over 100 instances where this happens and doing it by hand is insane.

hlspablo commented 1 year ago

In iOS Folder go to Pods/Pods.xcodeproj/xcuserdata/project.pbxproj Change all the 'IPHONEOS_DEPLOYMENT_TARGET = 11.0' to 'IPHONEOS_DEPLOYMENT_TARGET = 12.4'. save and run. Note: every time you pod install it will change so again you have to do it. If there is better approach please do mention.

is there a better way to do this? an automated way via cmd line? I have over 100 instances where this happens and doing it by hand is insane.

Update to a version that already fixed it. Manually changing things can be a pain in the ass in long time

karatekid430 commented 1 year ago
    target.build_configurations.each do |config|
      if target.name == "React-Codegen"
        # https://github.com/facebook/react-native/issues/34106
        config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = "12.4"
      end
    end

I found that the scalpel is better than the hammer. This is in ios/Podfile.

Aakash359 commented 1 year ago

Here's how I fixed it:

  1. Open node_modules/react-native/scripts/react_native_pods.rb
  2. Go to line no 401 >>> 'ios' => '11.0',
  3. Change 11.0 to 12.0
  4. Use patch-package to make a patch.
  5. Run yarn
  6. Run pod install
  7. Go to ios/build/generated/ios/React-Codegen.podspec.json and confirm "platforms": { "ios": "12.0" }

That's all.

diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb
index 7f6ebab..cea0fef 100644
--- a/node_modules/react-native/scripts/react_native_pods.rb
+++ b/node_modules/react-native/scripts/react_native_pods.rb
@@ -398,7 +398,7 @@ def get_react_codegen_spec(options={})
     'source' => { :git => '' },
     'header_mappings_dir' => './',
     'platforms' => {
-      'ios' => '11.0',
+      'ios' => '12.0',
     },
     'source_files' => "**/*.{h,mm,cpp}",
     'pod_target_xcconfig' => { "HEADER_SEARCH_PATHS" =>

When i i have try this soultion then i am getting this error lol now do i fixed this issues i think your solution does't work for me it is creating another problem, i guess everyone getting the same issues after trying your solutions like this Screenshot 2023-06-07 at 2 30 16 PM i am totally fed -up with your solution pls someone suggest me another solution accepting this one

csoylu commented 1 year ago

isn't this solved already, i am facing the same issue?

efecantekin commented 1 year ago

👋 everyone!

We have just finished rolling out new patch releases for the versions in the release support window to address this problem, check them out:

They should address this problem fully.

I tried to build RN 71.10 on XCode 14.3.1 and got this error again. I checked Codegen_utils.rb and it uses min_ios_version_supported definition which returns 12.4 already in react_native_pods.rb.

image
samih-dev commented 1 year ago

@efecantekin try cleaning the build using CMD/CRTL+SHIFT+K on xcode and try add the pods again npx pod-install - this worked for me

bryce0516 commented 1 year ago
diff --git a/node_modules/react-native/scripts/cocoapods/codegen_utils.rb b/node_modules/react-native/scripts/cocoapods/codegen_utils.rb
index 3694e68..caa9794 100644
--- a/node_modules/react-native/scripts/cocoapods/codegen_utils.rb
+++ b/node_modules/react-native/scripts/cocoapods/codegen_utils.rb
@@ -85,7 +85,7 @@ class CodegenUtils
           'source' => { :git => '' },
           'header_mappings_dir' => './',
           'platforms' => {
-            'ios' => '11.0',
+            'ios' => '12.4',
           },
           'source_files' => "**/*.{h,mm,cpp}",
           'pod_target_xcconfig' => { "HEADER_SEARCH_PATHS" =>

in "react-native": "0.71.2"

npx patch-package react-native

this works! try this

snake302 commented 1 year ago

The second solution is: 1) In the Xcode Project select "Pods" 2) Select target that throws errors 3) Select Build Settings 4) Bump iOS Target to required version

But you should do this every time when project is updates

Screenshot 2023-06-15 at 12 29 01
zabojad commented 1 year ago

It still happens with XCode 14.3.1 and RN 0.71.8 on several modules like : react-native-simple-toast, react-native-svg, react-native-permissions...

The problem started to pop in my project after updating XCode from 14.1 to 14.3.1.

jamesrogers93 commented 1 year ago

I fixed this by upgrading react-native from 0.71.4 to 0.71.11

zachrispoli commented 1 year ago

This issue was fixed for me by bumping react-native from 0.70.6 to 0.70.10, in order to get this fix: https://github.com/facebook/react-native/commit/c5e549e694607cd576be8fcb5ed909fec2ed6dce

So if you're still on react-native 0.70.x, you can still get support for Xcode 14.3 using minor version 10.

MohameddAmineYaich commented 1 year ago

I just remove pods folder under ios then, cd ios pod install and it run for me

PhillipFraThailand commented 1 year ago

The second solution is:

  1. In the Xcode Project select "Pods"
  2. Select target that throws errors
  3. Select Build Settings
  4. Bump iOS Target to required version

But you should do this every time when project is updates

Screenshot 2023-06-15 at 12 29 01

This simple solution worked for me

expressdev093 commented 1 year ago

@OmarUsman777

I think If you set like this in Podfile, you don't have to change them manually everytime.

  ...
  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    # NOTE: Change IPHONEOS_DEPLOYMENT_TARGET to 12.4.
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      end
    end
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

thanks this work for me

zabojad commented 1 year ago

Still having the issue after performing these steps: 1 - upgrade react-native from 0.71.8 to 0.71.12 2 - Deleted Pods and Podfile.lock 3 - run RCT_NEW_ARCH_ENABLED=1 bundle exec pod install in /ios folder 4 - clean build in XCode and build...

Screenshot 2023-07-13 at 17 11 11
qaudfuture commented 1 year ago

@OmarUsman777 I think If you set like this in Podfile, you don't have to change them manually everytime.

  ...
  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    # NOTE: Change IPHONEOS_DEPLOYMENT_TARGET to 12.4.
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      end
    end
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

@kouhot 's solution worked for me. Had to add this to Podfile and then Clean and run pod install again, and everything worked without error. Thanks kouhot!

Thank you, This worked for me

Dsalvat596 commented 1 year ago

The second solution is:

  1. In the Xcode Project select "Pods"
  2. Select target that throws errors
  3. Select Build Settings
  4. Bump iOS Target to required version

But you should do this every time when project is updates

Screenshot 2023-06-15 at 12 29 01

You've saved my life. Hours upon hours of trying to fix it, and this did the trick.

brunoamorim616 commented 1 year ago

@OmarUsman777

I think If you set like this in Podfile, you don't have to change them manually everytime.

  ...
  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    # NOTE: Change IPHONEOS_DEPLOYMENT_TARGET to 12.4.
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      end
    end
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

This worked on my project: "react": "18.1.0", "react-native": "0.70.6", XCode Version 14.3 MacBookAir M1 - MacOS Ventura 13.0

tonyjohnvan commented 1 year ago

just upgrade react native version to 0.72.3 and pod install fix it for me

holicstudio commented 1 year ago

The second solution is:

  1. In the Xcode Project select "Pods"
  2. Select target that throws errors
  3. Select Build Settings
  4. Bump iOS Target to required version

But you should do this every time when project is updates

Screenshot 2023-06-15 at 12 29 01

You've saved my life. Hours upon hours of trying to fix it, and this did the trick.

Today, what is the required version? ios12? or 16?

liamjones commented 1 year ago

Today, what is the required version? ios12? or 16?

@holicstudio depends on your RN version. For the current version, 0.72.4, it's 12.4: https://github.com/facebook/react-native/blob/v0.72.4/packages/react-native/scripts/react_native_pods.rb#L41

You shouldn't need to manually change the version in the Pods project settings with recent RN versions though, the template Podfile references the above-linked code dynamically (see https://github.com/facebook/react-native/blob/v0.72.4/packages/react-native/scripts/react_native_pods.rb#L41). So, as RN updates, it'll change the version the Pods project is looking for (as long as you remember to pod install after upgrading).

Also, you may have other dependencies that pull up this min required version (for example I believe Expo currently needs 13+ if you're using that in your RN project)

nqam1904 commented 12 months ago

min_ios_version_supported

How to configure only once since the project is updated :-?

amruth-k99 commented 9 months ago

I have an Apple Macbook Pro M3 with Xcode 15.3. If anyone out there is unable to solve it, try this version: The IPHONEOS_DEPLOYMENT_TARGET should be 13.0. It should be more than 12.4.


target.build_configurations.each do |config|
  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
  if target.name == 'react-native-config'
    config.build_settings['ENVFILE'] = ENVFILES[config.name]
  end
  config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
end