47

I just upgraded from RN 0.68.x to 0.69.0 using the react-native upgrade command.Its shows an error about
FBReactNativeSpec 'value' is unavailable : introduced in ios 12.0 react native and same error shown when i create a new project with latest version.

xcode:12.4 macVersion:10.15.7

enter image description here

enter image description here

1

13 Answers 13

135

Illustrated answer for those who might have a hard time finding the options:

  1. In your Xcode project navigator, select Pods.
  2. Under Targets, select React-Codegen
  3. Set the window to Build Settings
  4. Under Deployment, set iOS Deployment Target to 12.4
  5. Clean project and rebuild: Product > Clean Build Folder, Product > Build

Source: https://github.com/facebook/react-native/issues/34106#issuecomment-1489549051

enter image description here

1
  • error is getting again each time i clean and install pods again Jun 13 at 7:40
30

Following up on Azaz Answer

You can automate it for all the build configurations in your podfile

add

post_install do |installer|
   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'] = '12.4'
       end
   end
end
2
  • 2
    Yes, but better to target only the problematic pod with if target.to_s === 'React-Codegen' as outlined in Joe Davis's response below. Apr 3 at 15:58
  • worked for me in xcode 14, and ios target 12.4 May 17 at 12:47
26
  1. Open the project in XCode.
  2. Pods>React-Codegen
  3. Change the target version from 11.0 to 12.x.
  4. Build.

Update from React Native Community (I didn't tried to upgrade yet): https://github.com/facebook/react-native/issues/34106#issuecomment-1495970568

3
  • Can you please include more detailed instructions on how to do this? Like what is the second step? Where do Ifind React-Codegen. Thanks!
    – checklist
    Apr 2 at 19:09
  • 3
    Please check the "Project Navigator" tab in XCode (the tab where you can search files/folders). You can see "Pods" there. imgur.com/a/SHLwAAr After you select "Pods", under "Targets", select "React-Codegen" and select "Build Settings" from the window. "Deployment" → set "iOS Deployment Target" to 12.x.
    – Cem
    Apr 2 at 19:25
  • Upgrading to the latest RN version got it fixed for me. Thanks for the hint. May 19 at 23:15
8

I know this is solved but if anyone wants a solution using only expo (I'm a big expo fanboy right now)

Heres how you can modify the podfile like in Vivek's answer using an expo config plugin.

I also added an if statment to only update React-codegen because it was the only one giving me issues after updating xcode to 14.3

// ./expo-plugins/fix-rn-codegen.js
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]);

Then link it in app.json

// ./app.json
{
  "expo": {
    "plugins": [
      ["./expo-plugins/fix-rn-codegen.js"]
    ]
  }
}
2
  • 2
    thank you! solved the problem. Don't forget to delete node_modules and ios folder, then run 'npx expo run:ios'
    – Anubz
    Apr 2 at 1:28
  • @Anubz Good callout, since this modifies your pods project you'll need the pod install command to run. if you have the ios fold then expo may skip the pod install step, so make sure to rm ios and node_modules
    – Joe Davis
    Apr 3 at 13:34
7

Following Vivek Verma answer.

Just prevent overriding Pods with a higher targets(new Expo pods have target 13).

ios/Podfile

// ios/Podfile
post_install do |installer|
...
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5.0'
      if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] < '12.4'
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
      end
    end
  end
...
end

1
  • Life saver! All the other answers suppose your app is already built but does not solve for remote build machines. Jun 5 at 22:22
5

It started happening after upgrading to the latest Xcode few days back.

  1. In 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.

That's a big discussion on https://github.com/facebook/react-native/issues/34106 regarding this issue.

4

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.

0
4

This has been fixed in the latest versions of react-native. You should be able to solve the problem by upgrading to any of these versions:

0
3

I think this is caused by some pods in your react-native project that are not the latest version and as a result some of may have IPHONEOS_DEPLOYMENT_TARGET less than 12.0

In my case I did the following steps

  • In VS Code i did a search for IPHONEOS_DEPLOYMENT_TARGET i could see that in the ios/Pods/Pods.xcodeproj/project.pbxproj file a few pods had target version less then 12.0 I updated them to 12.4 (This step i feel can be sorted by updating your packages to the latest and re-run pod install/update but I had some packages that the latest update did not change it for me)
  • Under XCode top menu, Goto XCode->Preferences -> Locations -> Open Derived Data folder(By clicking the arrow button)
  • Finder will open Derived Data folder
  • Delete Derived Data Folder
  • Start Metro server using npm start or yarn start
  • In Xcode, perform Clean build using cmd+shift+k
  • In Xcode, run the application using cmd+r
1
3

Go to: /node_modules/react-native/scripts/cocoapods/codegen_utils.rb

And change the version. From 11 to 12.

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

Finally run pod update.

2
  1. Open the project in Xcode.
  2. open Pods.
  3. then find and select "React-Codegen" pod in target section.
  4. Change the target version from 11 to 12.
  5. And build again the project.
1

I've spent hours going through solutions with no luck. I finally got it working by doing the following:

  1. Open workspace in Xcode
  2. Go to Pods -> React-Codegen -> Build Settings -> Deployment -> iOS Deployment Target
  3. Change the Target version to a later version

In my case, it was on set to 11.0. I changed the target to 12.4 and it resolved the issue.

I hope this helps.

0

Open the project in XCode.

Pods>React-Codegen

Change the target version from 11.0 to 12.x.

Build.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.