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

wb1gzix0  于 6个月前  发布在  Flutter
关注(0)|答案(1)|浏览(173)

我有一台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.


但通过酿造一切都很好。

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"

gtlvzcf8

gtlvzcf81#

我也得到了同样的错误
错误(Xcode):DT_TOOLCHAIN_DIR不能用于计算LIBRARY_SEARCH_PATHS,请改用TOOLCHAIN_CHAIN
无法为模拟器构建应用程序。在iPhone 15上启动应用程序时出错。
这是我找到的Here

相关问题