How I fixed "Undefined symbol: _OBJC_CLASS_$_FKUserDefaultsPlugin" etc, in React Native ios.

How I fixed "Undefined symbol: _OBJC_CLASS_$_FKUserDefaultsPlugin" etc, in React Native ios.

Here are the rest of the errors I found on xcode
"Undefined symbol: OBJC_CLASS$_FKUserDefaultsPlugin", "Undefined symbol: OBJC_CLASS$_FlipperClient", "Undefined symbol: OBJC_CLASS$_FlipperKitLayoutPlugin","Undefined symbol: OBJC_CLASS$_FlipperKitNetworkPlugin", "Undefined symbol: OBJC_CLASS$_FlipperKitReactPlugin", "Undefined symbol: OBJC_CLASS$_RCTBridge", "Undefined symbol: OBJC_CLASS$_RCTBundleURLProvider", "Undefined symbol: OBJC_CLASS$_RCTRootView", "Undefined symbol: OBJC_CLASS$_SKDescriptorMapper", "Undefined symbol: OBJC_CLASS$_SKIOSNetworkAdapter",

I got this error when building a project on Macbook with Apple's M1 chip, however, the project builds well on a Macbook with an Intel chip.

The first thing I did was go to my ios podfile in "ios/Podfile" look for post_install script and add this line of code

...
installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end

After which your code should look like this

post_install do |installer|
  react_native_post_install(installer)
...
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

If you have other stuffs on post_install, add them.

Now go to the terminal of the ios folder(cd ios), of your project and run

pod deintegrate && pod install

Finally go back to xcode and clean your build folder by:
Going to product -> Clean build folder or

CMD + SHIFT + K

Rebuild your code and everything should be fine now