在 M1 MAC 上的 iPhone 15 模拟器上运行 flutter 项目

问题描述 投票:0回答:1

我有一台 M1 Mac,我想在 iPhone 15 pro max 模拟器上运行我的项目,但出现错误。

Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max. 

我用谷歌搜索,有些人建议将这些行添加到 podfile 中:

post_install do |installer|
 xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1`

  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
      config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
      config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"

      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      # For xcode 15+ only
       if config.base_configuration_reference && Integer(xcode_base_version) >= 15
          xcconfig_path = config.base_configuration_reference.real_path
          xcconfig = File.read(xcconfig_path)
          xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
          File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
      end
    end
  end
end

当我运行时,我收到此错误:

Warning: CocoaPods is installed but broken. Skipping pod install.
  You appear to have CocoaPods installed but it is not working.
  This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used to invoke it.
  This can usually be fixed by re-installing CocoaPods.
To re-install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

CocoaPods not installed or not in valid state.
Error launching application on iPhone 15 Pro Max.

我又安装了cocoapods:

 ios % brew install cocoapods           
==> Downloading https://formulae.brew.sh/api/formula.jws.json
#=#=-  #       #                                                                                                                                                                                                                                               
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################################################################################################################################################################################################### 100.0%
Warning: Treating cocoapods as a formula. For the cask, use homebrew/cask/cocoapods
Warning: cocoapods 1.14.2 is already installed and up-to-date.
To reinstall 1.14.2, run:
  brew reinstall cocoapods
 ios %

当我尝试使用 gem 安装时,出现此错误:

ios % sudo gem install cocoapods
Password:
ERROR:  Error installing cocoapods:
        There are no versions of cocoapods-downloader (>= 2.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
        cocoapods-downloader requires Ruby version >= 2.7.4. The current ruby version is 2.7.2.137.

但是通过brew一切都好。

 ios % gem which cocoapods                                                                                                   
/Users/alt/.rvm/gems/ruby-2.7.2/gems/cocoapods-1.13.0/lib/cocoapods.rb

我的 Pod 版本:

 pod --version                    
1.12.1

宝石文件:

gem "Fastlane"
gem "colorize"
gem 'cocoapods', '~> 1.12.1'
gem 'activesupport', '~> 7.0.8'
gem "fileutils"
gem "base64"
flutter macos simulator
1个回答
0
投票
post_install do |installer|
  installer.pods_project.targets.each do |target|
     flutter_additional_ios_build_settings(target)
      target.build_configurations.each do |config|
        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
        File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
      end
  end
end

--

flutter clean

进入ios文件夹

 cd ios

删除Podfile.lock

rm Podfile.lock

同时删除 Pods 文件夹

rm -rf Pods/

安装软件包

flutter pub get

安装吊舱

pod install
© www.soinside.com 2019 - 2024. All rights reserved.