braze-inc / braze-swift-sdk

https://www.braze.com
Other
48 stars 19 forks source link

[Bug]: 9.0.0 Build error #127

Closed davehpcnt closed 1 month ago

davehpcnt commented 2 months ago

Platform

iOS

Platform Version

all

Braze SDK Version

9.0.0

Xcode Version

Xcode 15.2

Computer Processor

Apple (M1)

Repro Rate

100%

Steps To Reproduce

Example:

  1. Using Tuist for BrazeUI and BrakeKit integration.
  2. Build

Expected Behavior

Build success

Actual Incorrect Behavior

Build error

Verbose Logs

When building with SPM using Tuist, the following error occurs. What is the reason for this?
Using BrazeUI and BrazeKit.

Invalid redeclaration of 'BrazeUIResources'


### Additional Information

_No response_
jerielng commented 2 months ago

Hi @davehpcnt, is this a new integration, or are you upgrading from a previous version and are only now seeing this error in 9.0.0? We may need to get some additional details about your Xcode project setup, particularly around what your Frameworks & Libraries and Compile Sources sections look like.

For what it's worth, we do have some resource override features specifically for setups like Tuist, where the default bundles may not always be available, but that doesn't seem to be the cause of the issue here. To be thorough, are you leveraging any of these features?

If possible, could you generate a minimal reproducible sample project and send it in to support@braze.com? Thanks!

suhaibalabsi commented 1 month ago

@jerielng After investigation, I think the problem shows up with this specific version (v8.1.0).

With that version, the following type "BrazeUIResources" was introduced into this file: https://github.com/braze-inc/braze-swift-sdk/blob/4183918f7eb88ffb5c2b55c47fd759c9a802ec6a/Sources/BrazeUI/Resources.swift#L15

Which is get conflicted with a Tuist synthesized definition of resources bundle.

suhaibalabsi commented 1 month ago

@jerielng Here is an example for a Tuist synthesized resources bundle definition.

Usually exists on a path that looks like this: {PROJECT_DIR}/Tuist/Dependencies/SwiftPackageManager/.build/checkouts/braze-swift-sdk/Derived/Sources/TuistBundle+BrazeUIIos.swift

// swiftlint:disable all
// swift-format-ignore-file
// swiftformat:disable all
import Foundation

// MARK: - Swift Bundle Accessor

private class BundleFinder {}

extension Foundation.Bundle {
    /// Since BrazeUI_ios is a staticFramework, the bundle containing the resources is copied into the final product.
    static let module: Bundle = {
        let bundleName = "braze_swift_sdk_BrazeUI_ios"

        let candidates = [
            Bundle.main.resourceURL,
            Bundle(for: BundleFinder.self).resourceURL,
            Bundle.main.bundleURL,
        ]

        for candidate in candidates {
            let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
            if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
                return bundle
            }
        }
        fatalError("unable to find bundle named braze_swift_sdk_BrazeUI_ios")
    }()
}

// MARK: - Objective-C Bundle Accessor

@objc
public class BrazeUIResources: NSObject {
    @objc public class var bundle: Bundle {
        return .module
    }
}
// swiftlint:enable all
// swiftformat:enable all
jerielng commented 1 month ago

Thanks for the additional insight, @suhaibalabsi! We've filed a ticket internally to look into this and will keep you updated when we have a fix out. It might take a deeper investigation on our end to determine a resolution, but we'll reach back out here when we have a clearer timeline on a release.

davehpcnt commented 1 month ago

Solved by updating tuist version. https://github.com/tuist/tuist/issues/6283

hokstuff commented 1 month ago

Since it appears the original issue has been solved by using the latest Tuist version, I will close this issue out. Feel free to comment back on this issue or contact our Support team if you continue to run into problems.

Thanks!