【问题标题】:Add associated domains entitlement in Flutter doesn't work on iOS在 Flutter 中添加关联域权利在 iOS 上不起作用
【发布时间】:2022-08-11 22:04:24
【问题描述】:

我需要在我的 Flutter 应用程序中实现通用链接。我使用 uni_links Flutter 库在 Android 上完成了所有工作,但在 iOS 上我遇到了一些问题。

我按照以下步骤操作:

  1. 在我的 Apple 开发人员帐户中的配置文件中添加了关联域权利
  2. 在 Xcode 功能选项卡中将域添加到关联域
  3. 已将 Runner.entitlements 文件复制到我的 Flutter 项目中
  4. 将主机文件添加到关联域 (https:///.well-known/apple-app-site-association)
  5. 在 Info.Plist 文件中添加了 CFBundleURLTypes

    遵循这些步骤后,我成功地在 Xcode 中本地运行了 iOS 应用程序,并且通用链接似乎有效。但是,在部署 iOS 应用程序后,单击链接会打开网站,而不是我们的应用程序。我们正在使用 Azure DevOps 管道将我们的应用程序发布到 MS App Center 并最终发布到 Testflight。

    我相信生成的 IPA 不知何故不包含正确的权利。有人可以帮助解决我们的问题吗?先感谢您!

    我们的 YAML 构建管道:

    • 任务:joachimdalen.env-transform.057845f0-8352-446f-a666-cb0e1f1055e3.EnvTransform@0 显示名称:EnvTransform 输入: 输入文件:\'$(Build.SourcesDirectory)/[project]/assets/env/dotenv\' 输出文件:\'$(Build.SourcesDirectory)/[project]/assets/env/dotenv\'

    • 任务:安装AppleProvisioningProfile@1 displayName: \'安装 Apple 配置文件\' 输入: provProfileSecureFile:\'[GUID]\'

    • 任务:安装AppleCertificate@2 displayName: \'安装苹果证书\' 输入: certSecureFile:\'[GUID]\' certPwd: \'$(P12password)\' setUpPartitionIdACLForPrivateKey: 假

    • 任务:安装AppleCertificate@2 displayName: \'安装苹果证书推送\' 输入: certSecureFile:\'[GUID]\' certPwd: \'$(P12password)\' setUpPartitionIdACLForPrivateKey: 假

    • 任务:Hey24sheep.flutter.flutter-install.FlutterInstall@0 显示名称:\'颤振安装\'

    • 脚本:| echo \"卸载所有 cocoapods 版本\" sudo gem 卸载 cocoapods -ax echo \"正在安装最新的 cocoapods 版本\" sudo gem install cocoapods --pre 工作目录:\'$(build.sourcesdirectory)/[project]\' displayName: \'安装 cocoapods\' 启用:假

    • 任务:Hey24sheep.flutter.flutter-build.FlutterBuild@0 displayName: \'Flutter Build iOS\' 输入: 目标:ios 项目目录:\'$/[DIRECTORY]\' 详细模式:真 buildNumber: \'$(build.buildNumber)\' buildName: \'$(build.buildNumber)\' ios代码设计:假 extraArgs: \'--no-sound-null-safety\'

    • 任务:删除文件@1 displayName: \'删除生成的 podfile\' 输入: 源文件夹:\'$(Build.SourcesDirectory)/[project]/ios/\' 内容:Podfile

    • 任务:KirKone.fileoperations.rename.rename@0 displayName: \'使用我们自己的特殊 podfile \' 输入: 源文件:\'$(Build.SourcesDirectory)/[project]/ios/Podfile_replace\' 新名称:Podfile

    • 脚本:| 光盘 ios/ Pod 存储库更新 吊舱安装
      光盘.. 工作目录:\'$(Build.SourcesDirectory)/[项目]\' displayName: \'安装新的 pod\'

    • 任务:Xcode@5 显示名称:\'Xcode 构建\' 输入: xcWorkspacePath:\'**/Runner.xcworkspace\' 方案:亚军 包应用程序:真 导出路径:\'$(System.ArtifactsDirectory)\' 导出选项:plist exportOptionsPlist:\'$[DIRECTORY]\' 导出参数:\'\', 签名选项:手动 签名身份:\'iPhone 分发\' provisioningProfileUuid:\'[供应配置文件]\'

    • 任务:复制文件@2 displayName:\'复制文件到:$(build.artifactstagingdirectory)\' 输入: 源文件夹:\'$(Build.SourcesDirectory)/[project]/ios/\' 目标文件夹:\'$(build.artifactstagingdirectory)\'

    • 任务:PublishPipelineArtifact@0 displayName: \'发布管道工件\' 输入: 工件名称:IOS 目标路径:\'$(build.artifactstagingdirectory)\'

    我们的播客文件:

    # 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 flutter_root
      generated_xcode_build_settings_path = File.expand_path(File.join(\'..\', \'Flutter\', \'Generated.xcconfig\'), __FILE__)
      unless File.exist?(generated_xcode_build_settings_path)
        raise \"#{generated_xcode_build_settings_path} must exist. If you\'re running pod install manually, make sure flutter pub get is executed first\"
      end
    
      File.foreach(generated_xcode_build_settings_path) do |line|
        matches = line.match(/FLUTTER_ROOT\\=(.*)/)
        return matches[1].strip if matches
      end
      raise \"FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get\"
    end
    
    require File.expand_path(File.join(\'packages\', \'flutter_tools\', \'bin\', \'podhelper\'), flutter_root)
    
    flutter_ios_podfile_setup
    
    target \'Runner\' do
      use_frameworks!
      use_modular_headers!
    
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
    end
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        target.build_configurations.each do |config|
          config.build_settings[\'SWIFT_VERSION\'] = \'5.0\'  # required by simple_permission
          config.build_settings[\'ENABLE_BITCODE\'] = \'NO\'
          config.build_settings[\'EXPANDED_CODE_SIGN_IDENTITY\'] = \"\"
          config.build_settings[\'CODE_SIGNING_REQUIRED\'] = \"NO\"
          config.build_settings[\'CODE_SIGNING_ALLOWED\'] = \"NO\"
        end
      end
    end

    更新: 这似乎是 Azure 管道中的一个问题(XCode 成功归档了我的项目,我将 IPA 提交给了 Testflight)。 我现在正在尝试通过命令行在 Azure DevOps 中存档 IPA:

    git clone https://github.com/flutter/flutter.git -b stable export PATH=$(build.sourcesdirectory)/[project\\/flutter/bin:$PATH 
    echo \"uninstalling all cocoapods versions\" 
    sudo gem uninstall cocoapods -ax 
    echo \"installing cocoapods version latest\" 
    sudo gem install cocoapods --pre 
    echo \"pod files\" 
    flutter precache --ios 
    cd ios/  
    pod install --repo-update  
    cd ../  flutter 
    pub get 
    flutter build ios --no-codesign --build-name=$(build.buildNumber) --build-number=$(build.buildNumber) --verbose --no-sound-null-safety
    
    xcodebuild -sdk iphoneos -configuration release -workspace /Users/runner/work/18/s/webdashboard/ios/Runner.xcworkspace -scheme Runner build CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=\'iPhone Distribution\' PROVISIONING_PROFILE=[profile] PROVISIONING_PROFILE_SPECIFIER= | /usr/local/lib/ruby/gems/2.7.0/bin/xcpretty -r junit --no-color

    现在我收到以下错误:

    /Users/runner/work/18/s/[project/ios/Runner/GeneratedPluginRegistrant.m:12:9: module \'share_plus\' not found.

    我的 pods 文件夹也是空的。

    有人知道该怎么做吗?我尝试了很多不同的命令。

    标签: ios flutter azure entitlements applinks


    【解决方案1】:

    我的猜测是构建管道中包含的配置文件没有启用相关的域权利

    【讨论】:

    • 感谢您的回答!查了一下确定,但它包含在启用的功能中:启用的功能访问 WiFi 信息、关联域、应用内购买、推送通知
    • 主机名正确吗? ssl 是否安全?
    • 是的,在 Xcode 中运行应用程序时,它支持授权文件中的指定域(单击链接打开 iOS 应用程序)。主机也是 ssl 安全的。
    • 您的管道显示其重命名 podfile_replace。也更新了吗?
    • 是的,以检查它是否已正确更新,我将文件夹复制到管道工件并更新了 podfile。我还添加了 CODE_SIGNING_REQUIRED 来解决另一个问题,现在该问题已得到解决。
    猜你喜欢
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 2021-02-14
    • 2015-07-26
    • 2021-01-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-21
    相关资源
    最近更新 更多