Flutter添加关联域名权限iOS端不生效及打包异常排查
一、通用链接Testflight失效排查与修复
本地Xcode运行正常,但Testflight打开链接跳网页,核心是打包时关联域名权限未正确嵌入IPA,按以下步骤排查:
确认流水线打包命令包含entitlements参数
检查Azure DevOps YAML中的xcodebuild命令,必须指定--entitlements指向项目中的Runner.entitlements文件,示例:xcodebuild archive -workspace Runner.xcworkspace -scheme Runner -archivePath build/Runner.xcarchive --entitlements Runner/Runner.entitlements同时要确保流水线使用的Provisioning Profile是已添加关联域名权限的版本,避免使用旧的无权限profile。
验证IPA中的权限配置
下载Testflight的IPA文件,解压后打开Payload/Runner.app/embedded.mobileprovision,搜索com.apple.developer.associated-domains,确认存在你的域名配置(比如applinks:yourdomain.com)。如果没有,说明打包时未嵌入entitlements,需调整流水线命令。重新验证apple-app-site-association文件
访问https://你的域名/.well-known/apple-app-site-association,确保返回的JSON格式正确:{ "applinks": { "apps": [], "details": [ { "appID": "你的TeamID.你的BundleID", "paths": ["*"] } ] } }同时确保服务器返回的Content-Type为
application/json,而非text/plain。苹果服务器可能缓存旧配置,可等待1-2小时后再测试。
二、命令行打包module 'share_plus' not found+Pods为空问题修复
这类问题通常是依赖缓存或Pod安装不完整导致,按以下步骤解决:
清理所有缓存文件
在项目根目录执行:flutter clean cd ios pod deintegrate pod cache clean --all rm -rf Podfile.lock .symlinks重新安装依赖与Pods
回到项目根目录,依次执行:flutter pub get cd ios # 普通Mac pod install --repo-update # M1/M2芯片Mac需用Rosetta arch -x86_64 pod install --repo-update调整Azure DevOps流水线步骤
在YAML中添加依赖安装步骤,确保xcodebuild前完成依赖准备:- script: | flutter pub get cd ios pod install --repo-update displayName: 'Install Flutter & iOS dependencies'修复GeneratedPluginRegistrant文件
如果仍报share_plus模块未找到,手动删除ios/Runner目录下的GeneratedPluginRegistrant.h和GeneratedPluginRegistrant.m,然后执行flutter pub get,Flutter会自动重新生成正确的注册文件。
内容的提问来源于stack exchange,提问作者JennaL__

