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

Fix AWSMobileClient to be extension API compatible #1522

Closed
mfcollins3 opened this issue May 3, 2019 · 8 comments
Closed

Fix AWSMobileClient to be extension API compatible #1522

mfcollins3 opened this issue May 3, 2019 · 8 comments
Labels
feature-request Request a new feature follow up Requires follow up from maintainers mobile client Issues related to AWSMobileClient platform support Issues related to platform support, such as MacOS, watchOS, tvOS, etc

Comments

@mfcollins3
Copy link

mfcollins3 commented May 3, 2019

Which AWS Services is the feature request for?
AWSMobileClient

Is your feature request related to a problem? Please describe.
I'm trying to use the AWS SDK using CocoaPods. My application is structured as follows:

  • Application
  • Core dynamic framework
  • Share extension
  • Today extension
  • Dynamic framework for custom UIViewControllers
  • Dynamic framework for third-party service integration
  • Dynamic framework for custom business logic

I'm building and linking the CocoaPods dependencies as static frameworks (using the cocoapods-static-swift-framework plugin). What I want to do is merge shared frameworks together into my Core framework and share the Core framework with all of my other frameworks and application. Because Core is used by extensions, it needs to enforce that all code uses extension-compatible APIs. I'm doing this to try to reduce the number of dynamic frameworks that I'm linking against in order to optimize the launch time of my app and extensions, per Apple's guidance.

The problem that I am running into is that AWSMobileClient is not compatible with extensions because of the getViewController function in AWSMobileClientExtensions.swift:

    public func getViewController() -> UIViewController {
        // This should never get called based on the design
        if (developerNavigationController?.visibleViewController != nil) {
            return developerNavigationController!.visibleViewController!
        }
        return UIApplication.shared.keyWindow!.rootViewController!
    }

The UIApplication.shared field is not extension compatible since there will not be a UIApplication instance in the extension.

The problem is that I can include all of the other AWS frameworks into my Core framework, but I can't add AWSMobileClient to my main application or another framework because it will fail to find and include header files for AWSCore and AWSAuthCore at build time, based on how CocoaPods builds its frameworks.

Describe the solution you'd like
I would like to see if there's a way to remove the dependency on UIApplication.shared in AWSMobileClient and make the AWSMobileClient extension-compatible by setting the Allow app extension API only flag in order to allow combining AWSMobileClient into a shared dynamic framework along with the other AWS frameworks. There does not appear to be any other blocker except for this one function.

The comment // This should never get called based on the design could be interpreted that this code is not expected to be executed, so can it be removed? Or can it be changed to allow the AWSMobileClient creator to pass a view controller to the initializer? Or add a delegate to AWSMobileClient and have the AWSMobileClient.getViewController call that delegate?

I'm happy to make the change and submit a PR if there's general support for a particular solution.

@desokroshan desokroshan added mobile client Issues related to AWSMobileClient feature-request Request a new feature labels May 6, 2019
@desokroshan desokroshan added the product review Issues awaiting product evaluation/review label May 6, 2019
@james-ff
Copy link

This would be great to have for us too!

@koxon
Copy link

koxon commented Nov 19, 2019

Anyone ?

@jugos654
Copy link

Will this move forward, anyone?

@james-ff
Copy link

An example of a similar issue to this being fixed in another library:
slackhq/PanModal#81

@palpatim
Copy link
Member

Adding context from @james-ff in #2958 (comment)

Yes, here I've included additional context for the use case I'm working with: having to use lower level libraries in the meantime to workaround the issue. Ideally only one library (AWSMobileClient) would be shared / linked between the app and extension targets

@royjit
Copy link
Contributor

royjit commented Oct 7, 2020

The AWS SDK for iOS currently only supports iOS applications. Adding support for app extensions will require significant changes to the code. We have this in our backlog but we do not have an ETA or any additional information. We will update this issue as soon as we have more updates.

@drochetti drochetti added follow up Requires follow up from maintainers platform support Issues related to platform support, such as MacOS, watchOS, tvOS, etc and removed product review Issues awaiting product evaluation/review labels Oct 21, 2020
@alionthego
Copy link

any update or workaround to get authentication tokens in app extension?

@atierian
Copy link
Member

atierian commented Dec 6, 2023

The AWS SDK for iOS doesn't support app extensions. We recommend using Amplify Swift for this -- for more information, please visit https://docs.amplify.aws/swift/

Thanks!

@atierian atierian closed this as completed Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature follow up Requires follow up from maintainers mobile client Issues related to AWSMobileClient platform support Issues related to platform support, such as MacOS, watchOS, tvOS, etc
Projects
None yet
Development

No branches or pull requests