Appboy / appboy-ios-sdk

Public repo for the Braze iOS SDK
https://www.braze.com
Other
165 stars 142 forks source link

Unable to retrieve correct bundle path for ABKContentCardsTableViewController with SPM #281

Closed martinknabbe closed 3 years ago

martinknabbe commented 3 years ago

Report

Describe your environment.

Info Value
Platform Name iOS
Platform Version 14.4
SDK Version 3.33.1
Integration Method Swift Package Manager
Xcode Version Xcode 12.4 (12D4e)
Repro rate all the time (100%)

What did you do?

We're upgrading from SDK Version 3.30.0 with Swift Package Manager. When creating a ABKContentCardsTableViewController the app crashes, because the storyboard can't be found. The SDK is integrated in one of our own frameworks and not in the app target itself. app -> private framework -> appboy-ios-sdk

What did you expect to happen?

The bundle that contains the storyboard for ABKContentCardsTableViewController can be located when the SDK is integrated in another framework.

What happened instead?

ABKUIUtils was updated in SDK version 3.31.1. The changes lead to a wrong bundle path when the SDK is integrated inside a framework instead of the app target. Bundle path in SDK Version 3.31.1:/Users/username/Library/Developer/Xcode/DerivedData/appname/Build/Products/Debug-iphonesimulator/customframework.framework/Appboy_iOS_SDK_AppboyUI.bundle Bundle path in SDK Version 3.30.0: /Users/username/Library/Developer/CoreSimulator/Devices/56960A41-D517-4D94-8158-C20A08D4510D/data/Containers/Bundle/Application/71EB4AC5-D126-46C0-AEA5-7B144A005119/appname.app/Appboy_iOS_SDK_AppboyUI.bundle/

Steps to reproduce

  1. Include the SDK inside another custom framework with Swift Package Manager.
  2. Add the custom framework to the app target.
  3. Execute let contentCardsTableViewController = ABKContentCardsTableViewController() in main app target.
lowip commented 3 years ago

Hi @martinknabbe,

Thank you for that report. We are able to reproduce the issue and are tracking it internally. We will tag you in this discussion once we have released a fix.

martinknabbe commented 3 years ago

Hi @lowip, do you have any update for this issue? It's blocking us to update to a newer SDK version. We would really like to get the latest features and bug fixes.

lowip commented 3 years ago

Hi @martinknabbe,

We are working on a fix that should be part of the next release.

Can you share the reasons for this specific setup?

It does not seem that your use-case is documented by Apple, and from my investigation, this is/was only working because your framework target is in the same project as your app target. If you were to build your customframework.framework in a project of its own, SPM would not copy the assets into the built binary framework either. Importing that framework in your app would lead to the same issue (bundle not present in framework) without a way to fix it (bundle not present in app either).

As this is a custom build setup, we can not officially support it. The next release will include a better way to lookup SPM resources that will resolve your specific issue as a side-effect.

martinknabbe commented 3 years ago

Sure, I'm happy to share our configuration. Our code base is big, so we split it into several frameworks to keep the code base maintainable and fast to compile. The project structure looks like this:

Xcode workspace
- Main app Xcode project (instantiates ABKContentCardsTableViewController)
- Custom framework 1 Xcode project (has Appboy SDK as dependency managed with Swift Package Manager)
- Custom framework 2 Xcode project
- ...

This structure was created before Swift Package Manager existed and the Xcode workspace and projects are created manually. Custom framework 1 doesn't contain user interface elements. The UI is part of the main app to keep separation of concerns.

lowip commented 3 years ago

Hi @martinknabbe,

We just released version 4.0.2 which make SPM resource import more reliable and as a result should fix this issue.

Feel free to reopen this issue if you are still experiencing missing resources.

martinknabbe commented 3 years ago

Hi @lowip, the latest release fixed our issue. Thanks a lot.