简体   繁体   中英

Add associated domains entitlement in Flutter doesn't work on iOS

I need to implement universal links in my Flutter application. I got everything to work on Android using the uni_links Flutter library, but on iOS I am facing some issues.

I followed these steps:

  1. Added Associated Domain Entitlement to provisioning profile in my Apple Developer Account
  2. Added domain to Associated Domains in Xcode capabilities tab
  3. Copied the Runner.entitlements file to my Flutter project
  4. Added host file to the associated domain (https:///.well-known/apple-app-site-association)
  5. Added CFBundleURLTypes to Info.Plist file

After following the steps I succeeded to run the iOS app locally in Xcode and the universal link seems to work. However, after deploying the iOS app works but clicking on a link opens the website and not our application. We are using Azure DevOps pipelines to publish our apps to MS App Center and eventually Testflight.

I believe that somehow the generated IPA does not contain the correct entitlements. Can someone help to fix our issue? Thank you in advance

Our YAML build pipeline:

  • task: joachimdalen.env-transform.057845f0-8352-446f-a666-cb0e1f1055e3.EnvTransform@0 displayName: EnvTransform inputs: inputFile: '$(Build.SourcesDirectory)/[project]/assets/env/dotenv' outputFile: '$(Build.SourcesDirectory)/[project]/assets/env/dotenv'

  • task: InstallAppleProvisioningProfile@1 displayName: 'Install an Apple provisioning profile' inputs: provProfileSecureFile: '[GUID]'

  • task: InstallAppleCertificate@2 displayName: 'Install an Apple certificate' inputs: certSecureFile: '[GUID]' certPwd: '$(P12password)' setUpPartitionIdACLForPrivateKey: false

  • task: InstallAppleCertificate@2 displayName: 'Install an Apple certificate push' inputs: certSecureFile: '[GUID]' certPwd: '$(P12password)' setUpPartitionIdACLForPrivateKey: false

  • task: Hey24sheep.flutter.flutter-install.FlutterInstall@0 displayName: 'Flutter Install'

  • script: | echo "uninstalling all cocoapods versions" sudo gem uninstall cocoapods -ax echo "installing cocoapods version latest" sudo gem install cocoapods --pre workingDirectory: '$(build.sourcesdirectory)/[project]' displayName: 'Install cocoapods' enabled: false

  • task: Hey24sheep.flutter.flutter-build.FlutterBuild@0 displayName: 'Flutter Build iOS' inputs: target: ios projectDirectory: '$/[DIRECTORY]' verboseMode: true buildNumber: '$(build.buildNumber)' buildName: '$(build.buildNumber)' iosCodesign: false extraArgs: '--no-sound-null-safety'

  • task: DeleteFiles@1 displayName: 'Delete generated podfile' inputs: SourceFolder: '$(Build.SourcesDirectory)/[project]/ios/' Contents: Podfile

  • task: KirKone.fileoperations.rename.rename@0 displayName: 'Use our own special podfile ' inputs: SourceFile: '$(Build.SourcesDirectory)/[project]/ios/Podfile_replace' NewName: Podfile

  • script: | cd ios/ pod repo update pod install
    cd.. workingDirectory: '$(Build.SourcesDirectory)/[project]' displayName: 'Install new pod'

  • task: Xcode@5 displayName: 'Xcode build' inputs: xcWorkspacePath: '**/Runner.xcworkspace' scheme: Runner packageApp: true exportPath: '$(System.ArtifactsDirectory)' exportOptions: plist exportOptionsPlist: '$[DIRECTORY]' exportArgs: '', signingOption: manual signingIdentity: 'iPhone Distribution' provisioningProfileUuid: '[PROVISIONING PROFILE]'

  • task: CopyFiles@2 displayName: 'Copy Files to: $(build.artifactstagingdirectory)' inputs: SourceFolder: '$(Build.SourcesDirectory)/[project]/ios/' TargetFolder: '$(build.artifactstagingdirectory)'

  • task: PublishPipelineArtifact@0 displayName: 'Publish Pipeline Artifact' inputs: artifactName: IOS targetPath: '$(build.artifactstagingdirectory)'

Our 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

My guess is that the provision profile included in build pipeline doesn't have associated domain entitlement enabled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM