本地与SSH远程执行Flutter打包IPA命令结果不一致求助
问题描述
我使用Flutter 3.0.4版本,在本地终端执行以下命令可正常完成IPA打包:
flutter build ipa --no-sound-null-safety
但通过SSH从另一台Mac以相同管理员用户(用户名panda)连接到目标Mac(本地IP:192.168.0.2)后,执行相同命令时出现Xcode构建错误,报错信息如下:
Error output from Xcode build: ↳ 2022-08-07 23:43:50.880 xcodebuild[35333:683754] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore 2022-08-07 23:43:50.880 xcodebuild[35333:683754] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore ** ARCHIVE FAILED ** Xcode's output:
环境信息:
- macOS版本:Monterey 12.5
- Xcode版本:13.4.1(13F100)
Flutter检测结果:
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.5 21G72 darwin-x64, locale en-VN) • Flutter version 3.0.4 at /Users/panda/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 85684f9300 (5 weeks ago), 2022-06-30 13:22:47 -0700 • Engine revision 6ba2af10bb • Dart version 2.17.5 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/panda/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] VS Code (version 1.69.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 12.5 21G72 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134 [✓] HTTP Host Availability • All required HTTP hosts are available
解决方案
以下是针对SSH会话中Xcode构建失败的几种可行修复方案:
1. 加载完整用户环境变量
本地终端会自动加载~/.zshrc/~/.bash_profile等shell配置文件,但SSH默认仅加载~/.profile。连接后手动加载对应配置:
source ~/.zshrc # 若使用bash则替换为source ~/.bash_profile
或修改SSH服务配置,让会话默认加载完整配置:
编辑/etc/ssh/sshd_config,启用PermitUserEnvironment yes(去掉行首注释),然后重启SSH服务:
sudo launchctl stop com.openssh.sshd sudo launchctl start com.openssh.sshd
2. 显式指定Xcode命令行工具路径
SSH会话可能无法正确识别Xcode路径,手动设置:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
执行后验证路径是否正确:
xcode-select -p
3. 禁用WatchOS相关插件(临时 workaround)
报错指向WatchOS插件,若无需构建WatchOS应用,可修改项目配置排除相关目标:
在项目ios/Podfile中添加以下内容,然后执行pod install:
post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| if target.name.include?('watchOS') config.build_settings['ENABLED'] = 'NO' end end end end
4. 重装Xcode命令行工具
若命令行工具损坏,卸载后重装:
sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install
安装完成后再次指定Xcode路径:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
5. 确保Xcode组件初始化完成
在目标Mac本地打开一次Xcode,完成组件初始化与权限验证后,再通过SSH执行打包命令。
内容的提问来源于stack exchange,提问作者tuanngocptn
相关产品推荐
相关产品推荐

