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
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
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.
I am getting this when I am trying to run app on ios simulator. can any one guide me what is reason/solution for this issue.
The following build commands failed:
CompileC /Users/xxx/Library/Developer/Xcode/DerivedData/eattog-dfbqbeyhmbgzhfcodvhlcaqjxepf/Build/Intermediates.noindex/P
ods.build/Debug-iphonesimulator/ReactCommon.build/Objects-normal/x86_64/RCTTurboModuleManager.o
/Users/xxx/Documents/React-Native-Projects/eattog/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
Thanks
just insert in the end of your Podfile:
post_install do |installer|
## Fix for XCode 12.5
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
Unable to build the app I am getting the error with import file not found error with different packages
So I have tried with import to import "{Any filename}.h"
But repeatedly I am facing errors with react-native-linear-gradient, fast-image, webview etc
Here I have tried to removed node_modules and then npm install and again rebuild the app. It failed
Cleaned project and also removed derived data. This also not worked
Also removed Pods and Podfile.lock then cleaned and run pod install. Nothing worked.
❌
node_modules/react-native-fast-image/ios/FastImage/FFFastImageViewManager.h:1:9:
'React/RCTViewManager.h' file not found
❌
node_modules/react-native-fast-image/ios/FastImage/RCTConvert+FFFastImage.h:1:9:
'React/RCTConvert.h' file not found
import
^~~~~~~~~~~~~~~~~~~~
import
React/RCTViewManager.h' file not found (This is due to the linear
gradient) package)
I personally added a little code to the Podefile to solve header search path problems as you meet it here
post_install do |installer|
puts 'post_install'
app_project = Xcodeproj::Project.open("./X.xcodeproj")
output = `find .. -name "*.xcodeproj"`
p output
output.split("\n").each do |projectPath|
app_project = Xcodeproj::Project.open(projectPath)
app_project.native_targets.each do |target|
target.build_configurations.each do |config|
if !config.build_settings['HEADER_SEARCH_PATHS']
config.build_settings['HEADER_SEARCH_PATHS'] ||= []
end
config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/Pods/Headers/**'
config.build_settings['HEADER_SEARCH_PATHS'] <<' $(SRCROOT)/../../../../ios/Pods/Headers/**'
config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/../../../ios/Pods/Headers/**'
config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/../../ios/Pods/Headers/**'
config.build_settings['HEADER_SEARCH_PATHS'] << ' $(SRCROOT)/../ios/Pods/Headers/**'
app_project.save
end
end
end
puts 'post_install DONE'
end
I hope I could have helped