我正在尝试更新react本机项目,但我将得到下一个错误。
在FBReactNativeSpec内部循环;构建可能产生不可靠的结果。这通常可以通过移动shell脚本阶段‘CP-用户生成规范’来解决,这样它就可以在依赖于其输出的构建阶段之前运行。循环详细信息:目标‘'/Users/test/Library/Developer/Xcode/DerivedData/taaaa-ejybfsygrxmpyrfwevuwhwcaaeri/Build/Products/Debug-iphonesimulator/FBReactNativeSpec/FBReactNativeSpec.framework/FBReactNativeSpec’‘具有具有输出Files/FBReactNativeSpec/FBReactNativeSpec-dummy.m’0的链接命令,目标'FBReactNativeSpec‘有编译命令,输入’/User/test/Desktop/taaaa/Pods/ Target Support Files/FBReactNativeSpec/FBReactNativeSpec-dummy.m‘0该命令依赖于目标'FBReactNativeSpec’中的命令:脚本阶段“CP-用户生成的规范”“0 Target 'FBReactNativeSpec‘有来自’/User/test‘的复制命令。/Desktop/taaaa/Libraries/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h‘to '/Users/test/Library/Developer/Xcode/DerivedData/taaaa-ejybfsygrxmpyrfwevuwhwcaaeri/Build/Products/Debug-iphonesimulator/FBReactNativeSpec/FBReactNativeSpec.framework/Headers/FBReactNativeSpec.h’0该命令依赖于目标‘FBReactNativeSpec’中的命令:脚本阶段“CP-用户生成规范”
发布于 2021-07-01 15:57:28
我找到了解决办法。如果有人有这个问题,你应该做下一个。
podfile应该保持这样
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'taaaa' do
# Comment the next line if you don't want to use dynamic frameworks
# Pods for taaaa
options={}
# The prefix to react-native
prefix = options[:path] ||= "./node_modules/react-native"
# Include Fabric dependencies
fabric_enabled = options[:fabric_enabled] ||= false
# Include DevSupport dependency
production = options[:production] ||= false
# Include Hermes dependencies
hermes_enabled = options[:hermes_enabled] ||= false
# The Pods which should be included in all projects
pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "#{prefix}/React/FBReactNativeSpec"
pod 'RCTRequired', :path => "#{prefix}/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "#{prefix}/Libraries/TypeSafety"
pod 'React', :path => "#{prefix}/"
pod 'React-Core', :path => "#{prefix}/"
pod 'React-CoreModules', :path => "#{prefix}/React/CoreModules"
pod 'React-RCTActionSheet', :path => "#{prefix}/Libraries/ActionSheetIOS"
pod 'React-RCTAnimation', :path => "#{prefix}/Libraries/NativeAnimation"
pod 'React-RCTBlob', :path => "#{prefix}/Libraries/Blob"
pod 'React-RCTImage', :path => "#{prefix}/Libraries/Image"
pod 'React-RCTLinking', :path => "#{prefix}/Libraries/LinkingIOS"
pod 'React-RCTNetwork', :path => "#{prefix}/Libraries/Network"
pod 'React-RCTSettings', :path => "#{prefix}/Libraries/Settings"
pod 'React-RCTText', :path => "#{prefix}/Libraries/Text"
pod 'React-RCTVibration', :path => "#{prefix}/Libraries/Vibration"
pod 'React-Core/RCTWebSocket', :path => "#{prefix}/"
unless production
pod 'React-Core/DevSupport', :path => "#{prefix}/"
end
pod 'React-cxxreact', :path => "#{prefix}/ReactCommon/cxxreact"
pod 'React-jsi', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-jsiexecutor', :path => "#{prefix}/ReactCommon/jsiexecutor"
pod 'React-jsinspector', :path => "#{prefix}/ReactCommon/jsinspector"
pod 'React-callinvoker', :path => "#{prefix}/ReactCommon/callinvoker"
pod 'React-runtimeexecutor', :path => "#{prefix}/ReactCommon/runtimeexecutor"
pod 'React-perflogger', :path => "#{prefix}/ReactCommon/reactperflogger"
pod 'ReactCommon/turbomodule/core', :path => "#{prefix}/ReactCommon"
pod 'Yoga', :path => "#{prefix}/ReactCommon/yoga", :modular_headers => true
pod 'DoubleConversion', :podspec => "#{prefix}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{prefix}/third-party-podspecs/glog.podspec"
pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec"
#Core
pod 'RNGestureHandler', :path => './node_modules/react-native-gesture-handler'
pod 'BVLinearGradient', :path => './node_modules/react-native-linear-gradient'
pod 'RNDeviceInfo', :path => './node_modules/react-native-device-info'
pod 'RNFS', :path => './node_modules/react-native-fs'
pod 'RNPermissions', :path => './node_modules/react-native-permissions'
pod 'Permission-Camera', :path => './node_modules/react-native-permissions/ios/Camera/Permission-Camera.podspec'
pod 'react-native-webview', :path => './node_modules/react-native-webview'
# Adjust
pod 'react-native-adjust', :path => './node_modules/react-native-adjust'
if fabric_enabled
pod 'React-Fabric', :path => "#{prefix}/ReactCommon"
pod 'React-graphics', :path => "#{prefix}/ReactCommon/react/renderer/graphics"
pod 'React-jsi/Fabric', :path => "#{prefix}/ReactCommon/jsi"
pod 'React-RCTFabric', :path => "#{prefix}/React"
pod 'RCT-Folly/Fabric', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec"
end
if hermes_enabled
pod 'React-Core/Hermes', :path => "#{prefix}/"
pod 'hermes-engine', '~> 0.7.2'
pod 'libevent', '~> 2.1.12'
end
target 'taaaaTests' do
inherit! :search_paths
# Pods for testing
end
target 'taaaaUITests' do
# Pods for testing
end
end
def use_flipper!(versions = {}, configurations: ['Debug'])
versions['Flipper'] ||= '~> 0.75.1'
versions['Flipper-DoubleConversion'] ||= '1.1.7'
versions['Flipper-Folly'] ||= '~> 2.5.3'
versions['Flipper-Glog'] ||= '0.3.6'
versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
versions['Flipper-RSocket'] ||= '~> 1.3'
pod 'FlipperKit', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configurations => configurations
# List all transitive dependencies for FlipperKit pods
# to avoid them being linked in Release builds
pod 'Flipper', versions['Flipper'], :configurations => configurations
pod 'Flipper-DoubleConversion', versions['Flipper-DoubleConversion'], :configurations => configurations
pod 'Flipper-Folly', versions['Flipper-Folly'], :configurations => configurations
pod 'Flipper-Glog', versions['Flipper-Glog'], :configurations => configurations
pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configurations => configurations
pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configurations => configurations
pod 'FlipperKit/Core', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/CppBridge', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FBDefines', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configurations => configurations
pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configurations => configurations
end
def has_pod(installer, name)
installer.pods_project.pod_group(name) != nil
end
# Post Install processing for Flipper
def flipper_post_install(installer)
installer.pods_project.targets.each do |target|
if target.name == 'YogaKit'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
def exclude_architectures(installer)
projects = installer.aggregate_targets
.map{ |t| t.user_project }
.uniq{ |p| p.path }
.push(installer.pods_project)
arm_value = `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i
# Hermes does not support `i386` architecture
excluded_archs_default = has_pod(installer, 'hermes-engine') ? "i386" : ""
projects.each do |project|
project.build_configurations.each do |config|
if arm_value == 1 then
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default
else
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 " + excluded_archs_default
end
end
project.save()
end
end
def react_native_post_install(installer)
pods_prefix = File.dirname(installer.pods_project.path)
if has_pod(installer, 'Flipper')
flipper_post_install(installer)
end
## Fix for RTC-Folly on iOS 14.5 - makes Hermes work again
find_and_replace(
"#{pods_prefix}/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
'atomic_notify_one(state)',
'folly::atomic_notify_one(state)'
)
find_and_replace(
"#{pods_prefix}Pods/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
'atomic_wait_until(&state, previous | data, deadline)',
'folly::atomic_wait_until(&state, previous | data, deadline)'
)
## Exclude `i386` from valid architectures when building with Hermes on iOS
exclude_architectures(installer)
end
def use_react_native_codegen!(spec, options={})
return if ENV['DISABLE_CODEGEN'] == '1'
# The path to react-native (e.g. react_native_path)
prefix = options[:path] ||= File.join(__dir__, "..")
# The path to JavaScript files
srcs_dir = options[:srcs_dir] ||= File.join(prefix, "Libraries")
# Library name (e.g. FBReactNativeSpec)
codegen_modules_library_name = spec.name
codegen_modules_output_dir = options[:codegen_modules_output_dir] ||= File.join(prefix, "React/#{codegen_modules_library_name}/#{codegen_modules_library_name}")
# Run the codegen as part of the Xcode build pipeline.
env_vars = "SRCS_DIR=#{srcs_dir}"
env_vars += " CODEGEN_MODULES_OUTPUT_DIR=#{codegen_modules_output_dir}"
# Since the generated files are not guaranteed to exist when CocoaPods is run, we need to create
# empty files to ensure the references are included in the resulting Pods Xcode project.
mkdir_command = "mkdir -p #{codegen_modules_output_dir}"
generated_filenames = [ "#{codegen_modules_library_name}.h", "#{codegen_modules_library_name}-generated.mm" ]
generated_files = generated_filenames.map { |filename| File.join(codegen_modules_output_dir, filename) }
if ENV['USE_FABRIC'] == '1'
# We use a different library name for components, as well as an additional set of files.
# Eventually, we want these to be part of the same library as #{codegen_modules_library_name} above.
codegen_components_library_name = "rncore"
codegen_components_output_dir = File.join(prefix, "ReactCommon/react/renderer/components/#{codegen_components_library_name}")
env_vars += " CODEGEN_COMPONENTS_OUTPUT_DIR=#{codegen_components_output_dir}"
mkdir_command += " #{codegen_components_output_dir}"
components_generated_filenames = [
"ComponentDescriptors.h",
"EventEmitters.cpp",
"EventEmitters.h",
"Props.cpp",
"Props.h",
"RCTComponentViewHelpers.h",
"ShadowNodes.cpp",
"ShadowNodes.h"
]
generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(codegen_components_output_dir, filename) })
end
spec.script_phase = {
:name => 'Generate Specs',
:input_files => [srcs_dir],
:output_files => ["$(DERIVED_FILE_DIR)/codegen-#{codegen_modules_library_name}.log"].concat(generated_files),
:script => "set -o pipefail\n\nbash -l -c '#{env_vars} CODEGEN_MODULES_LIBRARY_NAME=#{codegen_modules_library_name} #{File.join(__dir__, "generate-specs.sh")}' 2>&1 | tee \"${SCRIPT_OUTPUT_FILE_0}\"",
:execution_position => :before_compile,
:show_env_vars_in_log => true
}
spec.prepare_command = "#{mkdir_command} && touch #{generated_files.reduce() { |str, file| str + " " + file }}"
end
# Local method for the Xcode 12.5 fix
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr, replacestr)
replaced = text.index(replacestr)
next if !replaced.nil? || text == replace
puts "Patching #{name}"
File.open(name, 'w') { |file| file.puts replace }
$stdout.flush
end
Dir["#{dir}*/"].each(&method(:find_and_replace))
end
此外,您还应该包括项目中的所有节点模块。
json包是
{
"name": "Dummy",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.5",
"prop-types": "^15.7.2",
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-device-info": "^8.1.3",
"react-native-dotenv": "^3.0.0",
"react-native-fetch-polyfill": "^1.1.3",
"react-native-fs": "^2.18.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-indicators": "^0.17.0",
"react-native-keyboard-aware-scroll-view": "^0.9.4",
"react-native-linear-gradient": "^2.5.4",
"react-native-permissions": "^3.0.4",
"react-native-reanimated": "^2.2.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.4.0",
"react-native-webview": "^11.6.5",
"react-navigation": "^4.4.4"
},
"devDependencies": {
"@babel/core": "7.14.6",
"@babel/runtime": "7.14.6",
"@react-native-community/eslint-config": "2.0.0",
"babel-jest": "26.6.3",
"eslint": "7.14.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.64.0",
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
}
}
另外,做下一件事也是必要的。
单击左侧边栏中的Pods项目,进入构建阶段,确保CP-用户生成规范在标头之前。
https://stackoverflow.com/questions/68212071
复制相似问题