当前位置: 首页 > 知识库问答 >
问题:

在Flutter中添加关联域权限在iOS上不起作用

曹和正
2023-03-14

我需要在我的Flutter应用程序中实现通用链接。我使用uni_links Flutter库在Android上运行一切,但是在iOS上我面临一些问题。

我遵循了以下步骤:

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

在遵循这些步骤后,我成功地在Xcode中本地运行了iOS应用程序,通用链接似乎可以工作。然而,部署iOS应用程序后可以工作,但点击链接会打开网站,而不是我们的应用程序。我们正在使用Azure DevOps管道将我们的应用程序发布到MS应用程序中心,并最终进行试飞。

我认为,不知何故,生成的IPA不包含正确的权利。有人能帮助解决我们的问题吗?提前感谢!

我们的YAML构建管道:

>

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

    任务:installappleprovisiongprofile @ 1 display name:“安装Apple预置描述文件”输入:provProfileSecureFile:“[GUID]”

    任务:InstallAppleCertificate@2displayName:“安装苹果证书”输入:certSecureFile:“[GUID]'certPwd:“$(P12password)”setUpPartitionIdACLForPrivateKey:false

    任务:InstallAppleCertificate@2显示名称:“安装 Apple 证书推送”输入:certSecureFile:“[GUID]”certPwd:“$(P12password)”setUpPartitionIdACLForPrivateKey:false

    任务:Hey24sheep.flutter.flutter-install.FlutterInstall@0displayName:“Flutter安装”

    脚本:|echo“卸载所有cocoapods版本”sudo gem uninstall cocoapod-ax echo“安装最新版本的cocoapods-version latest”sudo gem install cocoapod--预工作目录:'$(build.sourcesdirectory)/[project]'显示名称:'install cocoapod'enabled:false

    任务:Hey24sheep.flutter.flutter-build.FlutterBuild@0displayName:'Flutter BuildiOS'输入:目标:ios项目目录:'$/[目录]'verboseMode: true buildNumber:'$(build.buildNumber)'buildName:'$(build.buildNumber)'iosCodesign:false exargs:'--no-son-null-saf'

    任务:DeleteFiles@1显示名称:“删除生成的 podfile”输入:源文件夹:“$(Build.SourcesDirectory)/[project]/ios/” 内容:podfile

    任务:KirKone.fileoperations.rename.rename@0displayName:“使用我们自己的特殊podfile”输入:SourceFile:“$(Build.SourcesDirectory)/[project]/ios/podfile_replace”NewName:podfile

    脚本:| cd ios/ pod repo更新pod安装< br> cd..工作目录:“$(Build .sources directory)/[project]' display name:'安装新窗格'

    task:Xcode @ 5 display name:' Xcode build ' inputs:xcWorkspacePath:“* */Runner . xcworkspace”scheme:Runner package app:true export path:“$(System .artifacts DIRECTORY)“export options:plist export options list:“$[DIRECTORY]”export args:“”,签名选项:手动签名标识:“iPhone分发”provisioningprofiuuid:“[预配描述文件]”

    任务:CopyFiles@2displayName:'将文件复制到:$(build.artifactstagingdirectory)'输入:SourceFolder:'$(build.SourcesDirectory)/[project]/ios/'TargetFolder:'$[(build.aartifactstagingDirectory)'

    任务:PublishPipelineArtifact@0显示名称:“发布管道项目”输入:项目名称:IOS 目标路径:“$(build.artifactstagingdirectory)”

    我们的podfile:

    # 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/Generated PluginRegistrant.m:12:9:未找到模块“share_plus”。

    我的 pods 文件夹也是空的。

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

  • 共有1个答案

    石正奇
    2023-03-14

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

     类似资料:
    • 问题内容: 我正在尝试创建一个可以从Gallery应用程序获取图像并将其显示在imageButton上的简单应用程序。我正在运行Android 5.0.1的手机上使用API​​ 21进行测试。不幸的是,无论我尝试什么,即使我指定了权限,我仍然会遇到安全错误。 我获取图像的代码是: 当我尝试从Dropbox选择图像时,该代码有效,但是当我从图库中选择图像时,我得到 我将READ_EXTERNAL_S

    • 我无法在iOS设备上进行测试

    • 它完全忽略了: 所以我得到了例外: 原因:android。看法WindowManager$BadTokenException:无法添加Windows android。看法ViewRootImpl$W@86fb55b--此窗口类型的权限被拒绝 它甚至没有列出: 我应该如何修复它?谢谢 编辑: 它列在配置应用程序/高级/绘制其他应用程序中。所以我打开它,现在它工作正常,但是为什么在我运行我的应用程序时

    • 我正在Flutter中开发我自己的应用程序,我想使用一些我自己制作的图标。我已经使用了font_awesome_flutter提供的一些图标,但是在我的代码的这一点上,我想添加一些其他的图标(svgs或pngs),这些图标不包括在这个包中,以使它更加个性化。 这就是我的应用程序组织: 代码组织 这就是我想要实现自己的图片upct的代码部分。巴布亚新几内亚: 非常感谢你!

    • 如果我只传递一个字符串,而不是的列表: 我得到的是:

    • 问题内容: 正在尝试在方法级别定义访问规则,但是它从未如此有效。 安全配置 ExampleController 每当我尝试使用user:user它访问/ v2 / home时,它执行得很好,是否由于“用户”没有访问权限而给我“拒绝访问”错误ROLE_ADMIN? 我实际上是在考虑在方法级别放弃访问规则并坚持使用http()ant规则,但是我必须知道为什么它对我不起作用。 问题答案: 在控制器上使用

    • 我有一个应用程序,想要允许从设备事件的联系人。我用了(,true),但这对我不起作用。我使用appium 1.5.2,甚至我想刷那个特定的联系人聊天或打电话给那个特定的联系人。当我使用一个: 我发现了一些例外

    • 问题内容: 如何检查我的应用是否启用了定位服务? 我有2个故事板,我想检查位置服务。如果为我的应用程序启用了位置服务,我想启动具有位置的地图故事板。否则,我要启动另一个情节提要。我该如何编程? 问题答案: 这是正确的。