facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.28k stars 24.22k 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

friederbluemle commented 2 years ago

Same issue here. I'm also using Xcode 12.4 - Could that be the reason?

AmirDiafi commented 2 years ago

+1

orzhtml commented 2 years ago

My system: macOS Catalina (10.15.7) MacBook Pro (13-inch, Mid 2012)

Xcode Version:12.4 (12D4e)

The latest system cannot be upgraded,Could that be the reason?

datqb commented 2 years ago

same issue, please give me solution when u have. tks

zhaoaixu520 commented 2 years ago

Same with me macOS Catalina (10.15.7) Xcode Version:12.4 (12D4e)

kangfenmao commented 2 years ago

Same issue,

macOS Catalina (10.15.7) Xcode Version:12.4 (12D4e)

image
3runoDesign commented 2 years ago

+1

deep-innow8 commented 2 years ago

hope that works.....

llVeraVerall commented 2 years ago

I have the same problem. I think the error is that the app runs iOS 14.4

ammarahm-ed commented 2 years 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" =>
craspadotcom commented 2 years ago

this worked, on a brand new project. Ive yet to add packages to see if those run fine. but can you please explain your line of thinking/workflow that made you come to this solution?

edit: after installing packages, project kept on reverting to 11.0. still unable to find a solution

craspadotcom commented 2 years ago

4. Use patch-package to make a patch.

npx patch-package react-native

charlieswing commented 2 years ago

+1

I'm getting this on a brand RN new project following the Getting Started instructions. Seems pretty ridiculous we'd have to modify one of the node_module files.

ammarahm-ed commented 2 years ago

@craspadotcom You have to add the postinstall script in package.json so it patches the files when you install/update packages.

"scripts": {
    "postinstall": "patch-package",

  },

The error occurs because React Native 0.69 targets ios 12.4 in Podfile but the Codegen generated podspec still targets ios 11.0 while using ios 12+ apis. I think there should be a patch release that fixes this issue.

Daniel-Houston commented 2 years ago

This fix worked for me

OmarUsman777 commented 2 years 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.

Azaz0723 commented 2 years 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.

this was helpful my issue was resolved using this

chrisjoohn commented 2 years 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.

Thanks for this. After so many tries on how to resolve this issue, this is the one that worked. 🍻

sesm commented 1 year ago

Update for version 0.70.3: If you want to follow advice from @ammarahm-ed , the property is in a different file now:

diff --git a/node_modules/react-native/scripts/cocoapods/codegen_utils.rb b/node_modules/react-native/scripts/cocoapods/codegen_utils.rb
index 6fcbb15..7e457b9 100644
--- a/node_modules/react-native/scripts/cocoapods/codegen_utils.rb
+++ b/node_modules/react-native/scripts/cocoapods/codegen_utils.rb
@@ -84,7 +84,7 @@ class CodegenUtils
           'source' => { :git => '' },
           'header_mappings_dir' => './',
           'platforms' => {
-            'ios' => '11.0',
+            'ios' => '12.0',
           },
           'source_files' => "**/*.{h,mm,cpp}",
           'pod_target_xcconfig' => { "HEADER_SEARCH_PATHS" =>
jhoanborges commented 1 year ago

+1

kayewrobleski commented 1 year ago

I had the same issue. Advice from @sesm worked for me

IlirBajrami 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.

You saved my job man! I know this is because our old macs are not updating to the latest ios. Now i hope i earn enough to buy the new mac :)

hailie-rei commented 1 year ago

@ammarahm-ed 's and @sesm 's solution helped me as well. Thank you!

kouhot 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
samzhao2008 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.

Thank you so much. You saved my day.

Jf-js commented 1 year ago

Thank you very much. The below fix worked for me too, I am still in the old XCode Version 12.4.

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

shanecowherd 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.

ricardoMogg commented 1 year ago

This is happening to me on XCode 14.2 as well since 2 days ago

dvelopin commented 1 year ago

This solution worked for me with Xcode 14.3RC

https://stackoverflow.com/a/74487309

ricardoMogg commented 1 year ago

To anyone that keeps having these issues and is using XcodeCloud, make sure to go to the workflow settings and choose the correct environment. In my case it was using the latest environment (14.3RC at the moment) and that was breaking everything. I selected spewcifically 14.2 and multiple things got fixed.

alexanderblackh commented 1 year ago

Can confirm this happens in Xcode 14.3. I downloaded RC2 today and this issue started. I was able to solve it by the following:

  1. In your Xcode project navigator, select Pods.
  2. Under Targets, selectReact-Codegen and set the window to Build Settings.
  3. Under Deployment, set iOS Deployment Target to 12.4.
  4. Clean project and rebuild.
ElectricCoffee commented 1 year ago

Can confirm this happens in Xcode 14.3. I downloaded RC2 today and this issue started. I was able to solve it by the following:

1. In your Xcode project navigator, select `Pods`.

2. Under Targets, select`React-Codegen` and set the window to `Build Settings`.

3. Under Deployment, set `iOS Deployment Target` to `12.4`.

4. Clean project and rebuild.

This almost worked for me. I also had to update the build targets for react-native-quick-crypto and react-native-quick-base64. So if anyone relies on these dependencies as well, those need to be bumped.

zanzarone commented 1 year ago

Thanks

Can confirm this happens in Xcode 14.3. I downloaded RC2 today and this issue started. I was able to solve it by the following:

1. In your Xcode project navigator, select `Pods`.

2. Under Targets, select`React-Codegen` and set the window to `Build Settings`.

3. Under Deployment, set `iOS Deployment Target` to `12.4`.

4. Clean project and rebuild.

This almost worked for me. I also had to update the build targets for react-native-quick-crypto and react-native-quick-base64. So if anyone relies on these dependencies as well, those need to be bumped.

Thanks man, you saved my day!

ervibern commented 1 year ago

Do you know how this can be solved in Expo Managed Workflow? I added expo-build-properties plugin to increase the iOS Deployment Target to 13.0 but it didn't solve the issue. Still getting the 'value' is unavailable: introduced in iOS 12.0 issue. [ 'expo-build-properties', { ios: { deploymentTarget: '13.0', }, }, ],

iway1 commented 1 year ago

Why was this issue closed? @orzhtml can you please reopen since it isn't fixed

Esparzarr commented 1 year ago

This solution worked for me with Xcode 14.3RC

https://stackoverflow.com/a/74487309

This work for me

iway1 commented 1 year ago

Here's an expo config plugin that worked for me for managed Expo workflow (it updates the deployment target for all pods to 13.0)

/* eslint-disable @typescript-eslint/no-var-requires */
const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const {
  mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const fs = require("fs");
const path = require("path");

async function readFileAsync(path) {
  return fs.promises.readFile(path, "utf8");
}

async function saveFileAsync(path, content) {
  return fs.promises.writeFile(path, content, "utf8");
}

const withFixedDeploymentTarget = (c) => {
  return withDangerousMod(c, [
    "ios",
    async (config) => {
      const file = path.join(config.modRequest.platformProjectRoot, "Podfile");
      const contents = await readFileAsync(file);
      await saveFileAsync(file, fixDeploymentTarget(contents));
      return config;
    },
  ]);
};

function fixDeploymentTarget(src) {
  return mergeContents({
    tag: `rn-fix-deployment-target`,
    src,
    newSrc: `
   installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
               config.build_settings['SWIFT_VERSION'] = '5.0'
               config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
`,
    anchor: /post_install/,
    offset: 1,
    comment: "#",
  }).contents;
}

module.exports = (config) => withPlugins(config, [withFixedDeploymentTarget]);

Put this in "/config-plugins/deployment-targets.js"

Then add to your app.json:

{
  "plugins": ["./config-plugins/deployment-targets"]
}

Then rm -rf ios => expo run:ios

ElectricCoffee commented 1 year ago

Do you know how this can be solved in Expo Managed Workflow? I added expo-build-properties plugin to increase the iOS Deployment Target to 13.0 but it didn't solve the issue. Still getting the 'value' is unavailable: introduced in iOS 12.0 issue. [ 'expo-build-properties', { ios: { deploymentTarget: '13.0', }, }, ],

That's cool if you use Expo. Our project doesn't however, so other workarounds are needed.

behenate commented 1 year ago

Can confirm this happens in Xcode 14.3. I downloaded RC2 today and this issue started. I was able to solve it by the following:

  1. In your Xcode project navigator, select Pods.
  2. Under Targets, selectReact-Codegen and set the window to Build Settings.
  3. Under Deployment, set iOS Deployment Target to 12.4.
  4. Clean project and rebuild.

Thank you this worked perfectly!

shoopapa commented 1 year ago

Here's an expo config plugin that worked for me for managed Expo workflow (it updates the deployment target for all pods to 13.0)

/* eslint-disable @typescript-eslint/no-var-requires */
const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const {
  mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const fs = require("fs");
const path = require("path");

async function readFileAsync(path) {
  return fs.promises.readFile(path, "utf8");
}

async function saveFileAsync(path, content) {
  return fs.promises.writeFile(path, content, "utf8");
}

const withFixedDeploymentTarget = (c) => {
  return withDangerousMod(c, [
    "ios",
    async (config) => {
      const file = path.join(config.modRequest.platformProjectRoot, "Podfile");
      const contents = await readFileAsync(file);
      await saveFileAsync(file, fixDeploymentTarget(contents));
      return config;
    },
  ]);
};

function fixDeploymentTarget(src) {
  return mergeContents({
    tag: `rn-fix-deployment-target`,
    src,
    newSrc: `
   installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
               config.build_settings['SWIFT_VERSION'] = '5.0'
               config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
`,
    anchor: /post_install/,
    offset: 1,
    comment: "#",
  }).contents;
}

module.exports = (config) => withPlugins(config, [withFixedDeploymentTarget]);

Put this in "/config-plugins/deployment-targets.js"

Then add to your app.json:

{
  "plugins": ["./config-plugins/deployment-targets"]
}

Then rm -rf ios => expo run:ios

Working for me! I like the fix

Do you have a edit that will only update the react-native codegen package, updating all of them seems a error prone?

iway1 commented 1 year ago

@shoopapa I haven't tried to do it just with the one package but maybe can add an if statement in there to check for the package name? I'm not really well versed in pod file syntax. probably better to do it for just react native codegen but doing it this way seems to be fine so far

hussainarthuna commented 1 year ago

Can confirm this happens in Xcode 14.3. I downloaded RC2 today and this issue started. I was able to solve it by the following:

  1. In your Xcode project navigator, select Pods.
  2. Under Targets, selectReact-Codegen and set the window to Build Settings.
  3. Under Deployment, set iOS Deployment Target to 12.4.
  4. Clean project and rebuild.

Thank you, it works perfectly for me.

lfoliveir4 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" =>

The same issue happened to me in new Xcode 14.3. That's save me! Thanks! ❤️

orzhtml commented 1 year ago
image

image

orzhtml commented 1 year ago

image

shoopapa commented 1 year ago

@iway1 This works for me, updating all the pods isn't necessary

const { withDangerousMod, withPlugins } = require("@expo/config-plugins");
const { ExpoConfig } = require("@expo/config-types");
const {
  mergeContents,
} = require("@expo/config-plugins/build/utils/generateCode");
const { readFileSync, writeFileSync } = require("fs");
const { resolve } = require("path");

const withFixedDeploymentTarget = (c) => {
  return withDangerousMod(c, [
    "ios",
    async (config) => {
      const file = resolve(config.modRequest.platformProjectRoot, "Podfile");
      const contents = readFileSync(file, { encoding: "utf-8" });
      writeFileSync(file, fixDeploymentTarget(contents));
      return config;
    },
  ]);
};

function fixDeploymentTarget(src) {
  return mergeContents({
    tag: `rn-fix-deployment-target`,
    src,
    newSrc: `
  installer.pods_project.targets.each do |target|
    if target.to_s === 'React-Codegen'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '5.0'
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
      end
    end
  end
`,
    anchor: /post_install/,
    offset: 1,
    comment: "#",
  }).contents;
}

module.exports = (config) => withPlugins(config, [withFixedDeploymentTarget]);

Here is edit for only patching React-Codegen At least temporarily, I recommend this solution if using expo, manually editing the podfile isn't optimal in the expo workflow

iway1 commented 1 year ago

@shoopapa nice - I also strongly recommend not manually editing any native files at all with expo managed workflow, it's a really big advantage to be able to not care about the ios/android folders and to be able to regenerate them easily.

ROG3R-DEV commented 1 year ago

I have this problem after updating xcode from version 14.2 to 14.3. The above solution does the trick, but it's very annoying to have to do this every time you run pod-install. Has anyone found a permanent solution to this problem?

rodolforamos commented 1 year ago

This solution worked for me with Xcode 14.3RC

https://stackoverflow.com/a/74487309

This worked like magic.

skurgansky-sugarcrm commented 1 year ago

test your fix on build with hermes and fabric enabled