簡體   English   中英

iOS 中的 Flutter audio_service 依賴問題

[英]Flutter audio_service dependancy issue in iOS

我正在添加用於在后台運行音頻的audio_service包。 在 android 中它可以工作,但作者沒有在 iOS 中實現,所以在 iOS 中運行應用程序時會出現以下錯誤。

錯誤:

在調試模式下在 iPhone 8 Plus 上啟動 lib/main.dart... 運行 pod install... CocoaPods 的輸出: ↳ 准備中

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

Finding Podfile changes
  A audio_service
  A audioplayer
  M Flutter
  - audio_player_service
  - url_launcher

Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `audio_player_service` from `.symlinks/plugins/audio_player_service/ios`
-> Fetching podspec for `audio_service` from `.symlinks/plugins/audio_service/ios`
[!] No podspec found for `audio_service` in `.symlinks/plugins/audio_service/ios`

/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:85:in `titled_section'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/external_sources/path_source.rb:11:in `fetch'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:697:in `fetch_external_source'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:673:in `block (2 levels) in fetch_external_sources'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:672:in `each'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:672:in `block in fetch_external_sources'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:671:in `fetch_external_sources'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:85:in `analyze'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:243:in `analyze'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:153:in `resolve_dependencies'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:116:in `install!'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.5.3/libexec/bin/pod:22:in `load'
/usr/local/Cellar/cocoapods/1.5.3/libexec/bin/pod:22:in `<main>'

CocoaPods 的錯誤輸出: ↳ [!] 用於生成鎖定文件的 CocoaPods 版本(1.6.0)高於當前可執行文件的版本(1.5.3)。 可能會出現不兼容問題。

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

運行 pod install 時出錯 在 iPhone 8 Plus 上啟動應用程序時出錯。

下面是 pod 文件:

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

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

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

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) { |line|
      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
      plugin = line.split(pattern=separator)
      if plugin.length == 2
        podname = plugin[0].strip()
        path = plugin[1].strip()
        podpath = File.expand_path("#{path}", file_abs_path)
        pods_ary.push({:name => podname, :path => podpath});
      else
        puts "Invalid plugin specification: #{line}"
      end
  }
  return pods_ary
end

target 'Runner' do
  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

  # Flutter Pods
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  if generated_xcode_build_settings.empty?
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  end
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
      symlink = File.join('.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('.symlinks', 'plugins', p[:name])
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
  }
end

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

在這里,我還將 pod 文件更改為if p[:name] != 'audio_service'

# Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    if p[:name] != 'audio_service'
      symlink = File.join('.symlinks', 'plugins', p[:name])
      File.symlink(p[:path], symlink)
      pod p[:name], :path => File.join(symlink, 'ios')
    end
  }

但是沒有用。

我該如何解決這個問題? 我們可以在 subspace.yaml 文件中設置限制嗎? 像這種依賴只安裝在 android 平台上? 反正我只是想解決它。

只需刪除您的ios/Podfile.lock文件,然后在同一目錄中運行

pod install

你應該很高興去。 這將確保您使用正確的版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM