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

Dynamically toggle capabilities before build #384

Merged
merged 19 commits into from
May 14, 2021

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented May 5, 2021

Checklist

Why

If a capability is defined in the entitlements file but not registered with Apple, the build will fail. This PR aims to reduce the possibility of that happening by checking the native entitlements file and enabling/disabling capabilities.

Fixes expo/expo-cli#3448 for eas build

How

  • If the project is specified to run as a bare workflow build, then read the entitlements file directly if one exists.
    • Otherwise if it's a managed project, read the Expo config and use the ios.entitlements object, defaulting to the template object (which always enables push notifications). This needs to be improved further in expo/config to allow reading of evaluated entitlements automatically (can implement in another PR).
  • Given a JSON representation of an entitlements object, match against our supported capabilities. Supported capabilities are based on entitlements, and iOS platform support.
  • If a capability that we manage is enabled for app, but not defined in the entitlements file, we'll disable it. This allows for users to enable future capabilities without us needing to explicitly support them.
  • Basic capabilities (boolean) can be omitted from the request if they already exist on a bundle identifier, this helps to reduce the amount of invocations in simpler projects. If a capability has settings, we'll always update it to ensure the settings are in sync. This can be optimized further in the future but works for now.
  • Using debug mode will show more info on how the request is built.
  • We surface the user friendly names for enabled and disabled capabilities after syncing.

Example

If the user has associatedDomains defined in their entitlements file, then in their app.json then enable/disable the capability remotely before building. Without this feature the build fails.

❌  error: Provisioning profile "*[expo] com.bacon.yolo22 AppStore 2021-05-04T22:29:48.816Z" doesn't support the Associated Domains capability. (in target 'yolo22' from project 'yolo22')

❌  error: Provisioning profile "*[expo] com.bacon.yolo22 AppStore 2021-05-04T22:29:48.816Z" doesn't include the com.apple.developer.associated-domains entitlement. (in target 'yolo22' from project 'yolo22')

With this feature the build works.

Test Plan

  • Wrote unit tests for the request and assembly.

  • In a managed project's app.json:

{
  "ios": {
    "entitlements": {
      "com.apple.developer.associated-domains": [
        "applinks:evanbacon.dev",
        "webcredentials:evanbacon.dev"
      ]
    }
  }
}
  • Then run eas build -p ios, after capabilities sync, check to see if 889YZVZQDS_ASSOCIATED_DOMAINS is defined (my app's opaque id is 889YZVZQDS).
  • After the build completes, submit to the app store, it should finish processing without any warnings.
  • Then remove the entitlements and rerun eas build, the syncing step should remove the capability.

This feature doesn't currently support ios.usesAppleSignIn, ios.associatedDomains, etc. because the mods must be statically evaluated for this to work. We can add this functionality in a future PR.

Visually, this is the scope of automatic functionality:

Screen Shot 2021-05-05 at 6 02 35 PM

@EvanBacon EvanBacon requested review from brentvatne and dsokal May 5, 2021 00:19
@github-actions
Copy link

github-actions bot commented May 5, 2021

Size Change: +4.21 kB (0%)

Total Size: 33 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 33 MB +4.21 kB (0%)

compressed-size-action

Copy link
Member

@brentvatne brentvatne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me. one concern i have about continuing to go down this road is that it's not clear how a third party lib using a config plugin to add a feature that depends on a capability would be able to work w/o modifying eas-cli like this. maybe we could add a more generic ios.capabilities key in the future? correction - we already have ios.entitlements

@dsokal dsokal requested a review from wkozyra95 May 5, 2021 07:46
@EvanBacon EvanBacon marked this pull request as draft May 7, 2021 00:51
@EvanBacon EvanBacon changed the title Enable associated-domains capability for apps Dynamically toggle capabilities before build May 7, 2021
@EvanBacon EvanBacon marked this pull request as ready for review May 7, 2021 01:10
@brentvatne
Copy link
Member

brentvatne commented May 7, 2021

i spoke with @EvanBacon about this stuff today and i'm generally on board with changes. there's additional work being on on the expo-cli repo but this can ship independently.

@dsokal dsokal requested review from wkozyra95, dsokal and quinlanj May 7, 2021 07:46
Copy link
Contributor

@dsokal dsokal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It generally looks good but please address my comments before merging to make the code easier to follow.

Copy link
Member

@quinlanj quinlanj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but please get wojtek/dominik to approve this first before merging !

packages/eas-cli/src/build/ios/credentials.ts Outdated Show resolved Hide resolved
@EvanBacon EvanBacon merged commit ef54911 into main May 14, 2021
@EvanBacon EvanBacon deleted the @evanbacon/cli/build/enable-associated-domains branch May 14, 2021 03:25
@flow-danny
Copy link

Is this supposed to work with app.config.ts? The sync basically disabled all our capabilities...

@flow-danny
Copy link

Now I see EAS "workflow": "managed" still might behave as bare workflow in this case.

@brentvatne
Copy link
Member

@flow-danny - sorry can you elaborate on what you experienced? i'd like to understand what happened in your situation

@flow-danny
Copy link

flow-danny commented May 24, 2021 via email

@brentvatne
Copy link
Member

if anyone runs into issues with capability syncing, you can disable it with EXPO_NO_CAPABILITY_SYNC=1 eas build (as described here: https://docs.expo.dev/build-reference/ios-capabilities/) and post an issue with some more information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Associated Domains" not added to Expo created App ID
6 participants