gpt4 book ai didi

flutter - Azure管道错误: No `Podfile' found in the project directory

转载 作者:行者123 更新时间:2023-12-03 06:58:09 26 4
gpt4 key购买 nike

我正在尝试使用 azure-pipelines.yml 文件为 Flutter iOS 应用程序创建 CI/CD 管道。android studioXcode 中一切正常。但是当我尝试在 Azure DevOps 中构建 ios 应用程序时,我收到此错误:

/usr/local/lib/ruby/gems/2.7.0/bin/pod --version
1.11.3
/usr/local/lib/ruby/gems/2.7.0/bin/pod install --repo-update
[!] No `Podfile' found in the project directory.
##[error]The process '/usr/local/lib/ruby/gems/2.7.0/bin/pod' failed with exit code 1
##[error]The 'pod' command failed with error: The process '/usr/local/lib/ruby/gems/2.7.0/bin/pod' failed with exit code 1
Finishing: CocoaPods

我的azure-pipelines.yml文件是:

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

- task: InstallAppleProvisioningProfile@1
displayName: "Install provisioning file"
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '$(provisioningProfile)'

- task: CocoaPods@0
inputs:
forceRepoUpdate: true

- task: Xcode@5
displayName: 'Xcode task'
inputs:
actions: 'build'
sdk:
configuration: 'Release'
xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace'
xcodeVersion: '12'
packageApp: true
signingOption: 'manual'
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'

- task: FlutterInstall@0
displayName: "Install Flutter SDK"
inputs:
mode: 'auto'
channel: 'stable'
version: 'latest'

- task: FlutterBuild@0
displayName: "Build application"
inputs:
target: ipa
projectDirectory: '$(Build.SourcesDirectory)'
exportOptionsPlist: 'ios/exportOptions.plist'

这是myPodfile:

platform :ios, '12.0'

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

def flutter_install_ios_plugin_pods(ios_application_path = nil)
ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
raise 'Could not find iOS application path' unless ios_application_path

symlink_dir = File.expand_path('.symlinks', ios_application_path)
system('rm', '-rf', symlink_dir) # Avoid the complication of dependencies like FileUtils.

symlink_plugins_dir = File.expand_path('plugins', symlink_dir)
system('mkdir', '-p', symlink_plugins_dir)

plugins_file = File.join(ios_application_path, '..', '.flutter-plugins-dependencies')
plugin_pods = flutter_parse_plugins_file(plugins_file)
plugin_pods.each do |plugin_hash|
plugin_name = plugin_hash['name']
plugin_path = plugin_hash['path']
if (plugin_name && plugin_path)
symlink = File.join(symlink_plugins_dir, plugin_name)
File.symlink(plugin_path, symlink)

if plugin_name == 'flutter_ffmpeg'
pod 'flutter_ffmpeg/full-lts', :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
else
pod plugin_name, :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
end
end
end
end

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

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

如果我添加

工作目录:'$(Build.SourcesDirectory)/ios'

我会收到此错误消息:

“无效的 Podfile 文件:/Users/runner/work/1/s/ios/Flutter/Generated.xcconfig 必须存在。如果您手动运行 pod install,请确保首先执行 flutter pub get。 “

最佳答案

最后,我找到了解决方案:

- stage: iOSStage
dependsOn: []
displayName: iOS
condition: always()
jobs:

- job: iOSJob
displayName: iOS
steps:

- task: FlutterInstall@0
displayName: "Install Flutter SDK"
inputs:
mode: 'auto'
channel: 'stable'
version: 'latest'

- task: InstallAppleCertificate@2
displayName: 'Install Apple Certificate'
inputs:
certSecureFile: '$(p12FileName)'
certPwd: '$(p12Password)'
keychain: 'temp'
deleteCert: true

- task: InstallAppleProvisioningProfile@1
displayName: "Install provisioning file"
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: '$(provisioningProfile)'

- task: Bash@3
displayName: '[Flutter] Configure Flutter'
inputs:
targetType: 'inline'
script: |
$(FlutterToolPath)/flutter doctor -v
$(FlutterToolPath)/flutter config --no-analytics

- task: Bash@3
displayName: '[Flutter] Build project environment'
inputs:
targetType: 'inline'
script: |
$(FlutterToolPath)/flutter pub get
$(FlutterToolPath)/flutter pub global activate junitreport

- task: Bash@3
displayName: '[Flutter] Flutter coverage'
inputs:
targetType: 'inline'
script: |
pip install lcov_cobertura
$(FlutterToolPath)/flutter test --coverage
python -m lcov_cobertura coverage/lcov.info -o coverage/coverage.xml

- task: Bash@3
displayName: '[Flutter] Flutter build'
inputs:
targetType: 'inline'
script: |
$(FlutterToolPath)/flutter build ios --release --no-codesign --build-number $(Build.BuildId)

- task: CocoaPods@0
inputs:
workingDirectory: '$(Build.SourcesDirectory)/ios/Flutter'
forceRepoUpdate: true

- task: Xcode@5
displayName: 'Xcode task'
inputs:
actions: 'build'
sdk: '$(sdk)'
configuration: '$(configuration)'
scheme: '$(scheme)'
xcWorkspacePath: ios/Runner.xcworkspace
signingOption: 'manual'
signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY)
provisioningProfileUuid: $(APPLE_PROV_PROFILE_UUID)
packageApp: true
workingDirectory: 'ios'
exportOptions: 'auto'
exportMethod: 'ad-hoc'
archivePath: 'output/$(sdk)/$(configuration)/Runner.xcarchive'
exportPath: 'output/$(sdk)/$(configuration)'
useXcpretty: 'false'
args: '-verbose'

- task: CopyFiles@2
displayName: 'Copy app to staging directory'
inputs:
Contents: '**/*.ipa'
TargetFolder: '$(build.artifactStagingDirectory)'
OverWrite: true

- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'

关于flutter - Azure管道错误: No `Podfile' found in the project directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72725563/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com