Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated Domains not getting populated #17727

Closed
4 tasks done
fenghuang opened this issue Dec 3, 2020 · 4 comments
Closed
4 tasks done

Associated Domains not getting populated #17727

fenghuang opened this issue Dec 3, 2020 · 4 comments

Comments

@fenghuang
Copy link

fenghuang commented Dec 3, 2020

New Issue Checklist

Issue Description

If I archive my app locally in Xcode and then upload it to Firebase App Distribution, then my universal links work properly. However, if I run my Azure Devops pipeline that uses fastlane to build the app, the entitlements aren't getting populated correctly. I pulled the ipa and checked the entitlements against the one I generated manually, and the associated domains looks like this:

Fastlane generated ipa:

<key>com.apple.developer.associated-domains</key>
<string>*</string>

Manually generated ipa:

<key>com.apple.developer.associated-domains</key>
<array>
    <string>applinks:[domain]</string>
    <string>applinks:[domain]</string>
</array>

I saw a couple of older issues on this that were closed without any resolution, and there was a plugin on the fastlane site that supposedly solved this issue, but the link for it went to a 404 on Github.

Environment

Key Value
OS 10.15.7
Ruby 2.7.2
Bundler? false
Git git version 2.29.2
Installation Source /usr/local/lib/ruby/gems/2.7.0/bin/fastlane
Host Mac OS X 10.15.7 (19H15)
Ruby Lib Dir /usr/local/Cellar/ruby/2.7.2/lib
OpenSSL Version OpenSSL 1.1.1g 21 Apr 2020
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode_12.2.app/Contents/Developer/
Xcode Version 12.2

System Locale

Variable Value
LANG en_US.UTF-8
LC_ALL en_US.UTF-8
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.54.3"

default_platform :ios

platform :ios do

  # =================================== DO THIS BEFORE ALL ================================

    before_all do

       # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
       #cocoapods
       xcversion(version: "12.1")

      end

  # =================================== Release and Adhoc builds =======================================

      desc "Create release and adhoc builds and upload to crashlytics"
      lane :CreateBuildsAndUploadToCrashlytics do
       createOrGetProfilesForType(type:"appstore")
       testFlightExportMethod = "app-store"
       infoListPath = "./Configurations/#{ENV['SCHEME']}/#{ENV['SCHEME']}-Info.plist"
       productName = get_info_plist_value(path: infoListPath, key:"CFBundleDisplayName")
       build_number = ENV["BUILD_BUILDNUMBER"]
       version_number = get_info_plist_value(path: infoListPath, key:"CFBundleShortVersionString")
       large_version_number = "#{version_number}.#{build_number}"
       set_info_plist_value(path: infoListPath, key:"CFBundleVersion", value:"#{large_version_number}")
       gymOutputName =  "#{productName}-release.ipa"
       gym(scheme: ENV['SCHEME'],
           output_name: gymOutputName,
           configuration: "Release")

       createOrGetProfilesForType(type:"adhoc")
       provProfilePathString = "sigh_#{ENV['BUNDLE_IDENTIFIER']}_adhoc_profile-path"
       provProfilePath = "#{ENV["#{provProfilePathString}"]}"
       resignedNamePath = "#{ENV['BUILD_SOURCESDIRECTORY']}/#{productName}-adhoc.ipa"
       sh "cp '#{ENV['BUILD_SOURCESDIRECTORY']}/#{gymOutputName}' '#{resignedNamePath}'"
       resign(ipa: resignedNamePath,
              signing_identity: "#{ENV['SIGNING_CERTIFICATE_NAME']}",
              provisioning_profile: "#{provProfilePath}"
       )

	changesURL = "[url]"
	require './api_request'
	changelog = Fastlane::Helper::ApiHelper::get_messages_from(changesURL)

       crashlytics(api_token: "[token]",
                   build_secret: "[secret]",
                   ipa_path: resignedNamePath,
                   groups: "#{ENV['CRAHSLYTICS_NOTIFIED_GROUPS']}",
					         notes: changelog
       )
       upload_symbols_to_crashlytics(api_token: "[token]")
      end

# ===========================Firebase Upload Methods=================================

    desc "Create releases and upload to Firebase App Distribution"
    lane :distributeToFirebase do |options|
      createOrGetProfilesForType(type:"appstore")
       testFlightExportMethod = "app-store"
       infoListPath = "./Configurations/#{ENV['SCHEME']}/#{ENV['SCHEME']}-Info.plist"
       productName = get_info_plist_value(path: infoListPath, key:"CFBundleDisplayName")
       build_number = ENV["BUILD_BUILDNUMBER"]
       version_number = get_info_plist_value(path: infoListPath, key:"CFBundleShortVersionString")
       large_version_number = "#{version_number}.#{build_number}"
       set_info_plist_value(path: infoListPath, key:"CFBundleVersion", value:"#{large_version_number}")
       gymOutputName =  "#{productName}-release.ipa"
       gym(scheme: ENV['SCHEME'],
           output_name: gymOutputName,
           configuration: "Release")

       createOrGetProfilesForType(type:"adhoc")
       provProfilePathString = "sigh_#{ENV['BUNDLE_IDENTIFIER']}_adhoc_profile-path"
       provProfilePath = "#{ENV["#{provProfilePathString}"]}"
       resignedNamePath = "#{ENV['BUILD_SOURCESDIRECTORY']}/#{productName}-adhoc.ipa"
       sh "cp '#{ENV['BUILD_SOURCESDIRECTORY']}/#{gymOutputName}' '#{resignedNamePath}'"
       resign(ipa: resignedNamePath,
              signing_identity: "#{ENV['SIGNING_CERTIFICATE_NAME']}",
              provisioning_profile: "#{provProfilePath}"
       )

       changesURL = "[url]"
       require './api_request'
       changelog = Fastlane::Helper::ApiHelper::get_messages_from(changesURL)

       firebase_app_distribution(
          app:ENV["FIREBASE_APP_ID"],
          ipa_path: resignedNamePath,
          groups:"#{ENV['CRAHSLYTICS_NOTIFIED_GROUPS']}",
          release_notes: changelog,
          firebase_cli_path: "/usr/local/bin/firebase",
          firebase_cli_token: "#{options[:firebase_token]}"
        )

   end

# ======================================================================

    desc "Create temporary keychain for match"
    lane :CreateKeychainForCI do
       create_keychain(
          name: ENV["MATCH_KEYCHAIN_NAME"],
            password: ENV["MATCH_KEYCHAIN_PASSWORD"],
          timeout: 1800
        )
    end

    lane :createOrGetProfilesForType do |options|
        register_devices(
            devices_file: "fastlane/common_test_devices.txt",
            team_id: ENV["MATCH_TEAM_ID"]
          )
        match(type: options[:type],
            force_for_new_devices: true,
            git_branch: ENV["MATCH_GIT_BRANCH"],
            team_id: ENV["MATCH_TEAM_ID"],
            username: "[email]",
            keychain_name: ENV["MATCH_KEYCHAIN_NAME"],
            keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"]
          )
    end

end
`./fastlane/Appfile`
app_identifier "#{ENV["BUNDLE_IDENTIFIER"]}" # The bundle identifier of your app
apple_id "[email]" # Your Apple email address

team_id "#{ENV["MATCH_TEAM_ID"]}" # Developer Portal Team ID

# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md

fastlane gems

Gem Version Update-Status
fastlane 2.169.0 ✅ Up-To-Date

Loaded fastlane plugins:

Plugin Version Update-Status
fastlane-plugin-firebase_app_distribution 0.1.4 🚫 Update available
Loaded gems
Gem Version
did_you_mean 1.4.0
slack-notifier 2.3.2
rouge 2.0.7
xcpretty 0.3.0
terminal-notifier 2.0.0
CFPropertyList 3.0.2
addressable 2.7.0
multipart-post 2.0.0
word_wrap 1.0.0
colored 1.2
highline 1.7.10
commander-fastlane 4.4.6
ruby2_keywords 0.0.2
faraday 1.1.0
faraday_middleware 1.0.0
gh_inspector 1.1.3
rubyzip 2.3.0
security 0.1.3
xcpretty-travis-formatter 1.0.0
bundler 2.1.4
uber 0.1.0
declarative-option 0.1.0
representable 3.0.4
retriable 3.1.2
mini_mime 1.0.2
httpclient 2.8.3
google-api-client 0.38.0
jmespath 1.4.0
aws-partitions 1.399.0
aws-eventstream 1.1.0
aws-sigv4 1.2.2
aws-sdk-core 3.109.3
aws-sdk-kms 1.39.0
aws-sdk-s3 1.85.0
uri 0.10.0
nanaimo 0.3.0
colored2 3.1.2
claide 1.0.3
atomos 0.1.3
xcodeproj 1.19.0
unicode-display_width 1.7.0
terminal-table 1.8.0
plist 3.5.0
public_suffix 4.0.6
tty-screen 0.8.1
tty-cursor 0.7.1
tty-spinner 0.9.3
babosa 1.0.4
excon 0.78.0
unf_ext 0.0.7.7
unf 0.1.4
domain_name 0.5.20190701
http-cookie 1.0.3
faraday-cookie_jar 0.0.7
fastimage 2.2.0
json 2.3.0
mini_magick 4.11.0
dotenv 2.7.6
naturally 2.2.0
simctl 1.6.8
jwt 2.2.2
declarative 0.0.20
multi_json 1.15.0
signet 0.14.0
os 1.1.1
memoist 0.16.2
googleauth 0.14.0
rake 13.0.1
digest-crc 0.6.1
google-cloud-errors 1.0.1
google-cloud-env 1.4.0
google-cloud-core 1.5.0
google-cloud-storage 1.29.1
emoji_regex 3.2.1
forwardable 1.3.1
logger 1.4.2
cgi 0.1.0
timeout 0.1.0
stringio 0.1.0
ipaddr 1.2.2
openssl 2.1.2
ostruct 0.2.0
strscan 1.0.3
date 3.0.0
delegate 0.1.0
fileutils 1.4.1
zlib 1.1.0
singleton 0.1.0
mini_portile2 2.1.0
nokogiri 1.6.8.1
racc 1.4.16
rexml 3.2.3
open3 0.1.0
yaml 0.1.0
psych 3.1.0
mutex_m 0.1.0
webrick 1.6.0
fastlane-plugin-firebase_app_distribution 0.1.4
@max-ott
Copy link
Member

max-ott commented Dec 7, 2020

Without information what you are actually running / doing, it's hard to help.

@fenghuang
Copy link
Author

fenghuang commented Dec 7, 2020

Specifically I'm implementing Firebase Dynamic/Universal links into my iOS app. I've added a list of URLs to the Associated Domains Capability in Xcode that should be recognized by the app as valid Universal Links. If I'm running the debug build off of Xcode, or if I archive the build in Xcode and then upload it myself to Firebase App Distribution, everything works as expected. But if build through fastlane (specifically the distributeToFirebase lane that's in my Fastfile) and download that build via Firebase, the app doesn't recognize the universal links and they always take the user to the app store listing for the app instead of opening the app. The associated domains plist entries that I put in my original description were the result of unzipping both IPAs (the one I built in Xcode vs the one that fastlane built) to validate that the latter wasn't working because it was missing the references to those URLs.

Here's the full script that our build pipeline is running for fastlane:


sudo bundle install

curl -sL firebase.tools | bash

sudo gem install fastlane

bundle exec fastlane CreateKeychainForCI

bundle exec fastlane distributeToFirebase firebase_token:$(Firebase.Token) --env [environment]

@max-ott
Copy link
Member

max-ott commented Dec 7, 2020

You're not setting the entitlements through the scripts. Therefore you are not getting the expected results.

@fenghuang
Copy link
Author

I added use_app_entitlements: true to my resign flags and it works perfectly now, thanks for pointing me in the right direction!

@fastlane fastlane locked and limited conversation to collaborators Feb 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants