JennaL__
JennaL__

Reputation: 21

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:

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

UPDATE: It seems to be an issue in the Azure Pipeline (XCode successfully archived my project and I submitted the IPA to Testflight). I am now trying to archive an IPA in Azure DevOps by command line:

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

And now I'm receiving the following error:

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

My pods folder is also empty.

Does anybody know what to do? I tried a lot of different commands.

Upvotes: 1

Views: 1497

Answers (1)

Kaushik Chandru
Kaushik Chandru

Reputation: 17724

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

Upvotes: 1

Related Questions