braintree_ios icon indicating copy to clipboard operation
braintree_ios copied to clipboard

Enhancement request - support for `tuist` framework via SPM

Open kabirkhaan opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is.

While working with Brain Tree SDK, We found that to resolve the SPM package Brain Tree using absolute path to resolve the header example

#elif SWIFT_PACKAGE // SPM
#import <BraintreeApplePay/BTConfiguration+ApplePay.h>
#import <BraintreeApplePay/BTApplePayCardNonce.h>
#import <BraintreeCore/BraintreeCore.h>
#import "../BraintreeCore/BTAPIClient_Internal.h"
#import "../BraintreeCore/BTPaymentMethodNonceParser.h"

reference

In the current solution, we have two issue to resolve the Header

  • Using Seperate Compile flag like SWIFT_PACKAGE
  • Absoute path

We faced an issue while working with tuist where tuist is project generator tool which also provide cache By generating the separate Targets for the project.

Internally tuist support 3 dependency managers

  • Carthage
  • CocoasPod
  • SPM

Brief introduction to Tuist However tuist has two main mechanism

  • tuist generate which download the dependcy and cache it so in the case of SPM it will dependcy will not sync in XCode as they are already cached
  • tuist test it will generate different graph base of project graph based on Package.swift for all the dependcies and cache it.

As Braintree uses Absolute path to resolve the dependcy and don't using cSettings - Header Search Path While running the tuist test we are not able to compile the brain tree project as missing of headers.

Describe the solution you'd like

Description of what you want to happen. Follow the user story format to clearly describe the use case.

As a developer to resolve the SPM Brain Tree, I would like to suggest the use of c Settings Header Search Path so that project has more information on Package.swift and the header should be resolved by using framework search path

Thanks to BrainTree to open source their code base, so that developers have more insight into the code.

Sugguestion

Include c-settings headers in Package.swift file

.target(
             name: "BraintreeCard",
             dependencies: ["BraintreeCore"],
             publicHeadersPath: "Public"
             publicHeadersPath: "Public",
             cSettings: [
                 .headerSearchPath("../")
             ]
         ),

Remove Following code from all class that import BrainTree core and only import framework

#elif SWIFT_PACKAGE // SPM
 #import <BraintreeAmericanExpress/BTAmericanExpressRewardsBalance.h>
 #import <BraintreeCore/BraintreeCore.h>
 #import "../BraintreeCore/BTAPIClient_Internal.h" // This one

In this manner we don't need compiler check SWIFT_PACKAGE for import and we use same import as Carthage is doing resolving the target dependcy without absolute search path.

In the scope of investigate following PR has been created which includes all the details as well examples.

kabirkhaan avatar Aug 25 '22 10:08 kabirkhaan

👋 @kabirkhaan thanks for reaching out, we'll follow up with any additional Qs or feedback. For internal tracking, issue 385

hollabaq86 avatar Aug 29 '22 19:08 hollabaq86

👋 Hi @kabirkhaan - thank you again for opening this PR and GH Issue. Due to lack of community engagement on this thread regarding adding explicit support for tuist, in addition to the fact that our SDK already supports native integrations with Swift Package Manager, we are going to close this feature request.

Please do feel free to commend on this issue, or open another in the future if this ends up being a further blocker for your team!

scannillo avatar Nov 02 '22 21:11 scannillo