braintree / braintree_ios

Braintree SDK for iOS
https://developer.paypal.com/braintree/docs/start/hello-client/ios/v5
MIT License
557 stars 295 forks source link

Archive issues when using in SPM #747

Closed jsorge closed 2 years ago

jsorge commented 2 years ago

Integration Details (please complete the following information):

Describe the bug When adding Braintree via SPM and using a product of the SDK such as PayPal or Venmo and linking those to a framework, the resulting archive will not pass App Store validation because it has embedded frameworks. Here's what's happening:


                 Actual                                             Expected                        

┌──────────────────────────────────────────────┐    ┌──────────────────────────────────────────────┐
│ ┌───────────────────────────────────────┐    │    │ ┌───────────────────────────────────────┐    │
│ │┌──────────────────────────────┐       │    │    │ │┌──────────────────────────────┐       │    │
│ ││ ┌─────────────────────┐      │       │    │    │ ││                              │       │    │
│ ││ │┌──────────────┐     │      │       │    │    │ ││                              │       │    │
│ ││ ││              │     │      │       │    │    │ ││      MyFramework             │       │    │
│ ││ ││              │     │      │       │    │    │ ││                              │       │    │
│ ││ ││ PPRiskMagnes │     │      │       │    │    │ ││                              │       │    │
│ ││ ││              │     │      │       │    │    │ │└──────────────────────────────┘       │    │
│ ││ ││              │     │      │       │    │    │ │┌──────────────────────────────┐       │    │
│ ││ │└──────────────┘     │      │       │    │    │ ││                              │       │    │
│ ││ │                     │      │       │    │    │ ││                              │       │    │
│ ││ │   Frameworks        │      │       │    │    │ ││ PPRiskMagnes                 │       │    │
│ ││ │                     │      │       │    │    │ ││                              │       │    │
│ ││ │                     │      │       │    │    │ ││                              │       │    │
│ ││ └─────────────────────┘      │       │    │    │ │└──────────────────────────────┘       │    │
│ ││                              │       │    │    │ │                                       │    │
│ ││      MyFramework             │       │    │    │ │                                       │    │
│ ││                              │       │    │    │ │                                       │    │
│ │└──────────────────────────────┘       │    │    │ │                                       │    │
│ │                                       │    │    │ │                                       │    │
│ │   Frameworks                          │    │    │ │   Frameworks                          │    │
│ │                                       │    │    │ │                                       │    │
│ │                                       │    │    │ │                                       │    │
│ └───────────────────────────────────────┘    │    │ └───────────────────────────────────────┘    │
│                                              │    │                                              │
│                                              │    │                                              │
│        App                                   │    │        App                                   │
│                                              │    │                                              │
└──────────────────────────────────────────────┘    └──────────────────────────────────────────────┘

The embedded PPRiskMagnes framework inside of the Framework product which is not supported by the App Store. Attached is a sample project that can be built and observed with this behavior.

To Reproduce Steps to reproduce the behavior:

  1. Create an Xcode project for an app
  2. Add a framework target
  3. Add the Braintree SDK as a dependency
  4. Link BraintreePayPal as a dependency to the framework
  5. Build the app
  6. Check derived data and find the resulting app product
  7. Right click on it and show package contents
  8. See that the Frameworks/{Framework Name}.framework/Frameworks/PPRiskMagnes.framework is populated

Expected behavior The PPRiskMagnes framework should be in the app's Frameworks directory.

scannillo commented 2 years ago

Hi @jsorge - thanks for opening up this issue. So, with the latest version of braintree_ios (5.4.4), I am able to successfully archive given the above setup. Are you getting a rejection at the app store level? If so, can you share that error message?

I do see the structure you are explaining when inspecting via "Show Package Contents" on the Application file. Can I ask, are you using any other braintree_ios dependencies?

Also - please update to 5.4.4, as it provides a few small SPM optimizations.

jsorge commented 2 years ago

Yes the error happens at the App Store submission level. When running our binary through the iTMS Transporter tool I get this error. It will build and run on device, but be rejected by the App Store.

Screen Shot 2021-10-19 at 1 43 03 PM
scannillo commented 2 years ago

@jsorge - Thanks for providing that. Is there a specific Xcode version this became an issue with - were you able to do this successfully in Xcode 12?

jsorge commented 2 years ago

@scannillo I've only tried on 13. My suspicion is that this is may be more of an SPM thing than a Braintree thing but it's hard to say. I did attempt to write a script that moves the framework and cleans up in a post-build phase and while that built fine in our debug mode, it fell down in release mode with an SPM error.

I honestly don't know what the way around this is. Perhaps if PPRiskMagnes was made a target that I could link directly I might be able to futz with it after the build completes.

scannillo commented 2 years ago

@jsorge My suspicion is that this is may be more of an SPM thing than a Braintree thing but it's hard to say.

I agree this is probably an SPM bug. But worth trying to investigate and get to the bottom of.

I see this StackOverflow issue outlines the same issue using Xcode 12.

A few ideas:

Can you try those options out and let me know?

scannillo commented 2 years ago

Hi @jsorge - due to inactivity, I am going to close this issue as this is likely an XCode issue and these workarounds worked for me. Please comment or re-open if this becomes an issue again and we can help in any way.