React Native iOS build failing due to glog and React Logger - react-native

I have a react native app which is working fine on android but when i try to run npx react-native run-ios I'm getting the following error
2023-02-16 11:27:07.190 xcodebuild[10406:767829] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x7f95f65afc30: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/shubhagarwal/Library/Developer/Xcode/DerivedData/weedlemobiledapptraining-cngaloxjuncutwengkgnppfnmbtd/SourcePackages/checkouts/swift-protobuf/Sources/protoc-gen-swift/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
** BUILD FAILED **
The following build commands failed:
CompileC /Users/shubhagarwal/Library/Developer/Xcode/DerivedData/weedlemobiledapptraining-cngaloxjuncutwengkgnppfnmbtd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-logger.build/Objects-normal/x86_64/react_native_log.o /Users/shubhagarwal/Desktop/metawork/portal-react-native/node_modules/react-native/ReactCommon/logger/react_native_log.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-logger' from project 'Pods')
(1 failure)
If I try to build it via XCode, this is what the error looks like
This is how my Podfile looks like
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('#react-native-community/cli-platform-ios/package.json')"`), "native_modules")
require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
$RNFirebaseAsStaticFramework = true
platform :ios, podfile_properties['ios.deploymentTarget'] || '12.0'
install! 'cocoapods',
:deterministic_uuids => false
target 'weedlemobiledapptraining' do
use_expo_modules!
use_modular_headers!
# use_frameworks!
config = use_native_modules!
# use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Dir.pwd}/.."
)
# Uncomment to opt-in to using Flipper
# Note that if you have use_frameworks! enabled, Flipper will not work
#
# if !ENV['CI']
# use_flipper!()
# end
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end
Versions :
node : 14.21.2
React : 17.0.2
React Native : 0.68.2
XCode : 12.1
I've tried everything that I could find on the internet.
Reinstalled Node Modules and Pods several times
Tried to make the build without use_frameworks! or use_modular_headers!
Adding glog to the podfile

Related

Build fails for React Native in iOS due to RNSVG

I have a react native app which is working fine on android but when i try to run npx react-native run-ios I'm getting the following error
2023-02-15 17:23:36.048 xcodebuild[81512:522416] [MT] IDEFileReferenceDebug: [Load] <IDESwiftPackageCore.IDESwiftPackageSpecialFolderFileReference, 0x7fd3caff3490: name:Docs.docc path:group:Docs.docc> Failed to load container at path: /Users/shubhagarwal/Library/Developer/Xcode/DerivedData/weedlemobiledapptraining-cngaloxjuncutwengkgnppfnmbtd/SourcePackages/checkouts/swift-protobuf/Sources/protoc-gen-swift/Docs.docc, Error: Error Domain=com.apple.dt.IDEContainerErrorDomain Code=6 "Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder"." UserInfo={NSLocalizedDescription=Cannot open "Docs.docc" as a "Swift Package Folder" because it is already open as a "Folder".}
** BUILD FAILED **
The following build commands failed:
Ld /Users/shubhagarwal/Library/Developer/Xcode/DerivedData/weedlemobiledapptraining-cngaloxjuncutwengkgnppfnmbtd/Build/Products/Debug-iphonesimulator/RNSVG/RNSVG.framework/RNSVG normal (in target 'RNSVG' from project 'Pods')
(1 failure)
This is how my Podfile looks like
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('#react-native-community/cli-platform-ios/package.json')"`), "native_modules")
require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
$RNFirebaseAsStaticFramework = true
platform :ios, podfile_properties['ios.deploymentTarget'] || '12.0'
install! 'cocoapods',
:deterministic_uuids => false
target 'weedlemobiledapptraining' do
use_expo_modules!
use_modular_headers!
# use_frameworks!
config = use_native_modules!
# use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Dir.pwd}/.."
)
# Uncomment to opt-in to using Flipper
# Note that if you have use_frameworks! enabled, Flipper will not work
#
# if !ENV['CI']
# use_flipper!()
# end
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end
Versions :
node : 14.21.2
React : 17.0.2
React Native : 0.68.2
XCode : 12.1
I've tried everything that I could find on the internet.
Reinstalled Node Modules and Pods several times
Tried to make the build without use_frameworks! or use_modular_headers!
Adding glog to the podfile
You need to run
pod install --project-directory=ios --repo-update
command to install pod dependencies

React Native - iOS release build failure

Archive is failed in release build with the following error but it is not an issue for debug build
** ARCHIVE FAILED **
The following build commands failed:
CompileC .../_appcircle_temp/appcircle_export_archive/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/project/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/Flipper-Folly.build/Objects-normal/armv7/VirtualEventBase.o .../_appcircle_temp/Repository/ios/Pods/Flipper-Folly/folly/io/async/VirtualEventBase.cpp normal armv7 c++ com.apple.compilers.llvm.clang.1_0.compiler
PodFile
use_flipper!({ 'Flipper-Folly' => '2.5.1' })
pre_install do |installer|
$RNMBGL.pre_install(installer)
end
post_install do |installer|
$RNMBGL.post_install(installer)
flipper_post_install(installer)
fix_deployment_target(installer)
end
end
def fix_deployment_target(installer)
return if !installer
project = installer.pods_project
project_deployment_target = project.build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
puts "Make sure all pods deployment target is #{project_deployment_target.green}"
project.targets.each do |target|
puts " #{target.name}".blue
target.build_configurations.each do |config|
old_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
new_target = project_deployment_target
next if old_target == new_target
puts " #{config.name}: #{old_target.yellow} -> #{new_target.green}"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = new_target
end
end
end
If in your error message you get something with DerivedData it is always a good idea to delete the complete subfolder in DerivedData dedicated to your app.
After that I would do pod install and Clean in Xcode and retry to build the app.

in react native camera onGoogleVisionBarcodesDetected not working on IOS

in react native camera I am using onGoogleVisionBarcodesDetected
does not triggered on IOS
work on android but not ios
in the installation requirements I should add this in pod file
pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
'BarcodeDetectorMLKit'
]
but when i try to pod install this error happened
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'
platform :ios, '10.0'
target 'megatel' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
# react-native-maps dependencies
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
pod 'GoogleMLKit/BarcodeScanning'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
pod 'GoogleMLKit/BarcodeScanning'
pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
'BarcodeDetectorMLKit'
]
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'megatel-tvOS' do
# Pods for megatel-tvOS
target 'megatel-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
"react": "16.9.0",
"react-native": "^0.63.3",
"react-native-camera": "^3.40.0",
I was able to get it to work yesterday on a Mac.
Scanning is so much faster using onGoogleVisionBarcodesDetected.
I just added the snipped to the Podfile like you did:
pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
'BarcodeDetectorMLKit'
]
and then ran pod update.
Used versions are:
CocoaPods 1.10.1
react 17.0.2
react-native 0.64.2
react-native-camera 4.1.1
GoogleMLKit 2.3.0
MLImage 1.0.0-beta1
MLKitBarcodeScanning 1.4.0
MLKitCommon 3.1.0
MLKitVision 1.3.0

React Native Build Error on IOS - typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')

After upgrading React Native from 0.61.5 to 0.63.2, Flipper causes an error on IOS as typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
On github there are a few proposed answers but none of them solved my problem https://github.com/facebook/flipper/issues/834
Is there anyone figured out how to solve this?
Many thanks
Note that if you have use_frameworks! enabled, Flipper will not work and
you should disable these next few lines in your Podfile.
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
STEP 1:
Go to YOUR_PROJECT > ios > Podfile and then comment these lines
# use_flipper!()
# post_install do |installer|
# react_native_post_install(installer)
# __apply_Xcode_12_5_M1_post_install_workaround(installer)
# end
STEP 2:
after step 1 you have to run pod update command on YOUR_PROJECT > ios path.
Bingo its done.
IMPORTANT
In case you get some errors after doing above 2 steps,
GO to YOUR_PROJECT > ios > YOUR_PROJECT_NAME > and run this command
plutil ./Info.plist it will show you where the issue is.
Then fix that issue from your text editor.
Directories name should not have space in which project exists.
This can also cause this error.
This is what solves for me for react native 0.65. It is very important that folly should link to 9.0
post_install do |installer|
react_native_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete "IPHONEOS_DEPLOYMENT_TARGET"
end
case target.name
when 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end
Update your pod file with below code.
use_flipper!({ 'Flipper-Folly' => '2.3.0' }) # update this part
post_install do |installer|
flipper_post_install(installer)
end
I needed to specify the versions:
# https://github.com/facebook/flipper/releases
# https://cocoapods.org/pods/Flipper-Folly
# https://cocoapods.org/pods/OpenSSL-Universal
use_flipper!({
"Flipper" => "0.134.0",
"Flipper-Folly" => "2.6.10",
"OpenSSL-Universal" => "1.1.1100"
})
And for a full Podfile, it might help:
require_relative "../node_modules/expo/scripts/autolinking"
require_relative "../node_modules/react-native/scripts/react_native_pods"
require_relative "../node_modules/#react-native-community/cli-platform-ios/native_modules"
platform :ios, "12.0"
target "socializus" do
use_expo_modules!
config = use_native_modules!
use_react_native!(
path: config[:reactNativePath],
hermes_enabled: false
)
# https://github.com/facebook/flipper/releases
# https://cocoapods.org/pods/Flipper-Folly
# https://cocoapods.org/pods/OpenSSL-Universal
use_flipper!({
"Flipper" => "0.134.0",
"Flipper-Folly" => "2.6.10",
"OpenSSL-Universal" => "1.1.1100"
})
post_install do |installer|
flipper_post_install(installer)
react_native_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete "IPHONEOS_DEPLOYMENT_TARGET"
end
end
end
end
I upgraded from react-native 0.65 to 0.68.
Deleted Pods and Podfile.lock and then ran pod update from within my iOS directory.
Didn't have to change any other code.
Thanks to #Sultan Aslam for mentioning pod update
I faced the same problem with RCT-Folly and solved the issue following the ways below:
Basically, it comes from ../node_modules/react-native/scripts/react_native_pods.rb file. Here is the code of that file.
# But... doing so caused another issue in Flipper:
# "Time.h:52:17: error: typedef redefinition with different types"
# We need to make a patch to RCT-Folly - remove the `__IPHONE_OS_VERSION_MIN_REQUIRED` check.
# See https://github.com/facebook/flipper/issues/834 for more details.
time_header = "#{Pod::Config.instance.installation_root.to_s}/Pods/RCT-Folly/folly/portability/Time.h"
`sed -i -e $'s/ && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)//' #{time_header}`
If you edit the code in node_modules, the .lock file will be changed. So to be safe, you can update the Podfile.
Add this line of code
sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h
after the post_install do |installer| line in Podfile like the following code snippet
target 'AwesomeProjectTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
`sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Run cd ios on the project root folder
Run pod deintergrate in the terminal and install pod again with the command pod install
Finally, build the project again with running the command npx react-native run-ios on the project root folder
Bingo! My issue has been solved as expected.
In my case, my XCode version was 11.5 and it was not supporting something newer in Flipper. Updating my XCode to version 12 fixed it immediately.
if you do not want to remove Flipper from your app then go through this solution.
your pod.file like this
add_flipper_pods!('Flipper' => '0.74.0')
upgrade Flipper-Folly by doing this
remove this line add_flipper_pods!('Flipper' => '0.74.0')
add this line add_flipper_pods!('Flipper-Folly' => '2.3.0')
In the Time.h(RTC-Folly) file:
I changed __IPHONE_10_0 to __IPHONE_12_0 (as my target iOS version is 11) and got it working. I guess the same can be done for MAC_OS_X_VERSION_10_12 to MAC_OS_X_VERSION_10_15 if you are targeting macOS.
First, remove the Flipper from your project.
After you go with this path.
Path: "Your-Project-App/ios/Pods/RCT-Folly/folly/portability/Time.h"
Replace this code time.h
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <time.h>
#include <folly/portability/Config.h>
// OSX is a pain. The XCode 8 SDK always declares clock_gettime
// even if the target OS version doesn't support it, so you get
// an error at runtime because it can't resolve the symbol. We
// solve that by pretending we have it here in the header and
// then enable our implementation on the source side so that
// gets linked in instead.
#if __MACH__ && \
((!defined(TARGET_OS_OSX) || TARGET_OS_OSX) && \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12)) || \
(TARGET_OS_IPHONE)
#ifdef FOLLY_HAVE_CLOCK_GETTIME
#undef FOLLY_HAVE_CLOCK_GETTIME
#endif
#define FOLLY_HAVE_CLOCK_GETTIME 1
#define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1
#endif
// These aren't generic implementations, so we can only declare them on
// platforms we support.
#if !FOLLY_HAVE_CLOCK_GETTIME && (defined(__MACH__) || defined(_WIN32))
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
#define CLOCK_PROCESS_CPUTIME_ID 2
#define CLOCK_THREAD_CPUTIME_ID 3
typedef uint8_t clockid_t;
extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
#endif
#ifdef _WIN32
#define TM_YEAR_BASE (1900)
extern "C" {
char* asctime_r(const tm* tm, char* buf);
char* ctime_r(const time_t* t, char* buf);
tm* gmtime_r(const time_t* t, tm* res);
tm* localtime_r(const time_t* t, tm* o);
int nanosleep(const struct timespec* request, struct timespec* remain);
char* strptime(
const char* __restrict buf,
const char* __restrict fmt,
struct tm* __restrict tm);
time_t timelocal(tm* tm);
time_t timegm(tm* tm);
}
#endif
After that, Please try to run the application via Xcode, Now the application can't run successfully you got another error
2nd Error is: "Command PhaseScriptExecution failed with a nonzero exit code"
2nd Error solution in the screenshot,
enter image description here
For me, this error occurred because I was doing in the ios/Podfile the following:
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
installer.pods_project.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
I can only assume that setting the build target of the Folly target was messing with something. Once these lines were removed from my Podfile and npx pod-install was run, the build worked again.

React Native Navigation React/RCTRootView.h file not found

I'm try to use React Native Navigation refer to this instruction
https://wix.github.io/react-native-navigation/#/installation-ios
I stuck at step 3 when I link the libReactNativeNavigation.a Xcode show error and I don't know how to fix this issue!
Here my package.json
"dependencies": {
"react": "~16.2.0",
"react-native": "~0.51.0",
"react-native-navigation" : "1.1.428"
}
My Pod file
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for React
pod 'React', :path => '../js/node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTImage',
'RCTNetwork',
'RCTText',
'RCTWebSocket',
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod "yoga", :path => "../js/node_modules/react-native/ReactCommon/yoga"
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../js/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'GLog', :podspec => '../js/node_modules/react-native/third-party-podspecs/GLog.podspec'
pod 'Folly', :podspec => '../js/node_modules/react-native/third-party-podspecs/Folly.podspec'
It's because that React-Native-Navigation is a subproject of your project, and it has dependency with React which you added to your project via cocoapods.
Try add ${BUILT_PRODUCTS_DIR} recursive to Build Settings -> FRAMEWORK_SEARCH_PATHS in ReactNativeNavigation.xcodeproj