【问题标题】:'React/RCTUtils.h' file not found找不到“反应/RCTUtils.h”文件
【发布时间】:2020-08-05 11:57:16
【问题描述】:

我正在使用 xcode 来构建 android 应用程序。在 azure devops 管道中;在构建时我收到此错误:

▸ Compiling PdfManager.m

❌  /Users/runner/runners/2.166.3/work/1/s/node_modules/react-native-pdf/ios/RCTPdf/PdfManager.m:16:9: 'React/RCTUtils.h' file not found

#import "React/RCTUtils.h"
                                       ^~~~~~~~~~~


▸ Compiling RCTPdfPageViewManager.m
▸ Compiling RCTPdfPageView.m
▸ Compiling RCTPdfView.m
** BUILD FAILED **


The following build commands failed:
    CompileC /Users/runner/Library/Developer/Xcode/DerivedData/helloapp-awmfiqdyvoywmpfazxztxqjlmzar/Build/Intermediates.noindex/Pods.build/Release-iphoneos/react-native-pdf.build/Objects-normal/armv7/PdfManager.o /Users/runner/runners/2.166.3/work/1/s/node_modules/react-native-pdf/ios/RCTPdf/PdfManager.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
##[error]Error: /usr/bin/xcodebuild failed with return code: 65

无法找到原因,需要一些帮助,我的 podfile 是:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'helloapp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for helloapp
   pod 'Firebase/Core'
   pod 'Firebase/Messaging' 

 pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

 pod 'react-native-pdf', :path => '../node_modules/react-native-pdf'


 target 'helloappTests' do
    inherit! :search_paths
    # Pods for testing
  end

end
post_install do |installer|
        installer.pods_project.build_configurations.each do |config|
            config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
            config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
        end
end

还有我的 azure 管道 yaml 任务,在此我使用 cocoapods 安装 pod:

trigger:
- master

pool:
  vmImage: 'macos-latest'

variables:
  - group: abcd

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '9.7.1'
  displayName: 'Install Node'
- script: npm install
  displayName: 'Install dependencies'

- task: InstallAppleCertificate@2
  inputs:
   certSecureFile: '$(file)'
   certPwd: '$(Pass)'
   keychain: 'temp'
   deleteCert: true  

- task: InstallAppleProvisioningProfile@1
  inputs:
   provisioningProfileLocation: ''
   provProfileSecureFile: '$(provisioningProfile)'
   removeProfile: true

- task: Cache@2
  inputs:
   key: 'pods | "$(Agent.OS)" | Podfile.lock'
   path: 'pods'
- task: CocoaPods@0
  inputs:
    forceRepoUpdate: true
    projectDirectory: '$(system.defaultWorkingDirectory)'
  displayName: 'pod install using the CocoaPods'

- task: Xcode@5
  inputs:
    workingDirectory: 'ios'
    actions: 'build'
    scheme: 'helloapp'
    sdk: 'iphoneos'
    configuration: 'Release'
    xcWorkspacePath: '**/helloapp.xcworkspace'
    xcodeVersion: 'default'
    packageApp: true
    signingOption: 'manual'
    signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
    provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
    args: '-UseModernBuildSystem=0'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(build.artifactStagingDirectory)'
  inputs:
    SourceFolder: ''
    contents: '**/*.ipa'
    targetFolder: '$(build.artifactStagingDirectory)'
    overWrite: true

- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(build.ArtifactStagingDirectory)'
    artifactName: 'drop' 
    publishLocation: 'Container'

pod 安装任务输出,即 cocoapods 添加到安装 pod 的任务的日志:

Version      : 0.151.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/cocoapods
==============================================================================
/usr/local/lib/ruby/gems/2.6.0/bin/pod --version
1.9.1
/usr/local/lib/ruby/gems/2.6.0/bin/pod install --repo-update --project-directory=/Users/runner/runners/2.166.3/work/1/s/ios
Updating local specs repositories
Adding spec repo `trunk` with CDN `https://cdn.cocoapods.org/`
Analyzing dependencies
Downloading dependencies
Installing React (0.11.0)
Installing react-native-pdf (5.0.12)
Installing rn-fetch-blob (0.10.6)
Generating Pods project
Integrating client project
Pod installation complete! There are 5 dependencies from the Podfile and 14 total pods installed.

[!] Automatically assigning platform `iOS` with version `9.0` on target `helloapp` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] The `helloappTests [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-helloappTests/Pods-helloapp.debug.xcconfig'. This can lead to problems with the CocoaPods installation

[!] The `helloappTests [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-helloappTests/Pods-helloappTests.release.xcconfig'. This can lead to problems with the CocoaPods installation

[!] React has been deprecated
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.
Finishing: pod install using the CocoaPods

如果需要更多详细信息,请在 cmets 中询问。

【问题讨论】:

  • 你使用的是哪个 react native 版本?您的 Podfile 看起来不正确
  • react-native-pdf (5.0.12), React (0.11.0) @JarvisLuong
  • @JarvisLuong 我添加了有问题的 cocoapod 任务输出,你可以参考一下。
  • 我在this thread 中发现了同样的错误。它说错误是由于插件安装不正确引起的。如果您使用 Pod 安装插件,则不应使用 react-native 链接,反之亦然。
  • 我只使用 pod @LeviLu-MSFT

标签: ios xcode react-native azure-pipelines podfile


【解决方案1】:

您提供的 podfile 缺少对 react 本身的引用,这是您如何修复它的一个示例(使用 cmets 的 react-native 版本 0.58):

target 'helloapp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # START REACT_NATIVE DEPENDENCIES
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'RCTPushNotification',
    'DevSupport'
  ]
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'
    # END REACT_NATIVE DEPENDENCIES

  # Pods for helloapp
   pod 'Firebase/Core'
   pod 'Firebase/Messaging' 

 pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

 pod 'react-native-pdf', :path => '../node_modules/react-native-pdf'


 target 'helloappTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-03
    • 2019-07-03
    • 2016-05-27
    • 2021-11-10
    • 1970-01-01
    • 2022-08-03
    相关资源
    最近更新 更多