1

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

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.

JennaL__
  • 21
  • 2

1 Answers1

1

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

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
  • Thanks for your answer! Looked it up to be sure but it is included in the enabled capabilities: Enabled Capabilities Access WiFi Information, Associated Domains, In-App Purchase, Push Notifications – JennaL__ Jul 28 '22 at 12:32
  • The host name is correct? And is ssl secured? – Kaushik Chandru Jul 28 '22 at 12:44
  • Yes, when running the app in Xcode it supports the specified domain in the entitlement file (clicking a link opens the iOS app). The host is also ssl secured. – JennaL__ Jul 28 '22 at 12:52
  • Your pipeline shows its renaming podfile_replace. Is it updated too? – Kaushik Chandru Jul 28 '22 at 13:25
  • Yes to check if it is updated correctly I copied the folder to the pipeline artifact and the podfile is updated. Also I added CODE_SIGNING_REQUIRED to fix another issue and that issue is fixed now. – JennaL__ Jul 28 '22 at 13:29
  • Can you try a manual build and release to test flight so we can be sure if its an issue from codes or pipeline – Kaushik Chandru Jul 28 '22 at 13:42
  • I tried a manual build and released it to test flight successfully. It seems to be an issue from the pipeline but we cannot find it.. – JennaL__ Aug 08 '22 at 12:49
  • Not sure.. but what's enabled false in install pods `displayName: 'Install cocoapods' enabled: false` – Kaushik Chandru Aug 08 '22 at 12:56
  • Oh I'm sorry, that is just a DevOps task that is disabled (we used it before but we don't need it anymore) – JennaL__ Aug 08 '22 at 13:01
  • Try checking each task and check if that's relevant and Podfile is correct – Kaushik Chandru Aug 08 '22 at 13:12
  • I updated the Azure Pipeline but I am now receiving a new error (see update in initial question) – JennaL__ Aug 11 '22 at 14:07