braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
50 stars 19 forks source link

[Bug]: Static XCFramework assets are embedded in app during compilation on Xcode 15.3 RC (Xcode bug) #105

Closed tiwoc closed 6 months ago

tiwoc commented 7 months ago

Platform

iOS

Platform Version

iOS 17.4

Braze SDK Version

8.0.0

Xcode Version

Xcode 15.3 beta 3 (15E5194e)

Computer Processor

Apple (M1)

Repro Rate

100% of the time

Steps To Reproduce

  1. Use Xcode 15.3 beta 3 to archive a build for Any iOS device (arm64)
  2. In Organizer > Archives, select the new archive and click Validate App (also happens when trying to upload to the App Store, but validations triggers the bug without even starting the distribution process)
  3. Select Validate and click the Validate button

Expected Behavior

Validation should succeed

Actual Incorrect Behavior

A validation error is shown:

<IDEDistributionIssue: severity(error), error(Error Domain=ContentDelivery Code=90208 \"Asset validation failed\" UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription=Asset validation failed, NSLocalizedRecoverySuggestion=Invalid Bundle. The bundle redacted.app/Frameworks/BrazeKit.framework does not support the minimum OS Version specified in the Info.plist. (ID: 6ca384f5-cc0f-40c3-902b-9d1fc26a45ba)})>

This prevents the distribution of the app via TestFlight and the App Store when built with Xcode 15.3.

Verbose Logs

No response

Additional Information

I was able to track down the reason for the failure thanks to a thread in Apple Developer Forums. There's an inconsistency in the minimum supported iOS version of the BrazeKit framework:

MinimumOSVersion is 12.0, but minos is 14.0.

I was able to fix validation locally by bumping MinimumOSVersion to 14.0 in BrazeKit.framework/Info.plist.

This might be a bug that is introduced or at least triggered by Xcode 15.3. iOS 14.0 is the deployment target of the app that we're including BrazeKit in. If I set the app's deployment target to another iOS version and archive the app again, BrazeKit's minos changes to that new version. Xcode 15.3 seems to update Braze's minos but not MinimumOSVersion to the one of the app target.

Interestingly, when archiving with Xcode 15.2, I don't even see BrazeKit.framework in the archived app bundle. I wonder if Xcode 15.2 statically links BrazeKit while Xcode 15.3 does dynamic linking?

tiwoc commented 7 months ago

Not sure if it's relevant, but we're including Braze via SPM.

tiwoc commented 7 months ago

Interestingly, BrazeKit is the only framework in our app that gets its minos bumped by Xcode 15.3. All the others retain their version, so there must be something inherent in BrazeKit, even if the source of the bug is in Xcode.

jacksonemiller commented 7 months ago

Hi @tiwoc,

Thank you very much for bringing this to our attention. We've begun looking into this and will let you know of any updates.

Thanks!

jacksonemiller commented 7 months ago

Hey, one other thing I forgot to mention. For right now, another potential workaround you might try is using our pre-built dynamic framework repository. It seems like it may not have the same issue.

tiwoc commented 7 months ago

Hi @jacksonemiller, thanks for bringing this up. With the dynamic framework, we don't run into the validation error 👍 Thank you!

For completeness, I also tried the braze-swift-sdk-prebuilt-static, but it doesn't change anything, which makes sense if you consider that the base repo also includes a static framework for BrazeKit.

kivra-janko commented 7 months ago

Xcode Cloud has just upgraded their "latest release" definition to Xcode 15.3 RC, which means all our builds have started to fail because of this issue.

Ironically, https://developer.apple.com/download/applications/ still lists 15.3 beta 3 as the latest...

hokstuff commented 7 months ago

Hi @tiwoc and @kivra-janko,

We believe that there is a bug in Xcode 15.3 RC in which the compilation process incorrectly copies over some files from a static XCFramework into the final app. In this case, BrazeKit.framework is embedded into the final app (which is a process typically reserved for dynamic XCFrameworks), and this ultimately creates a mismatch between the minimum supported iOS version listed in the embedded SDK’s Info.plist (in BrazeKit) and the minimum supported iOS version in the published framework products.

We have submitted a Feedback Assistant ticket with Apple to try to get this resolved in Xcode 15.3. Until then, we recommend the workarounds of either using our prebuilt dynamic repository or using Xcode 15.2 or before.

Thanks for your patience!

tiwoc commented 7 months ago

Thanks for the update! The prebuilt dynamic XCFramework works great for us, for the time being.

gooson commented 7 months ago

+1

hokstuff commented 6 months ago

Hi @tiwoc @kivra-janko @gooson,

We have just released Braze Swift SDK version 8.2.1 which fixes the issues during archiving on Xcode 15.3.

Let us know if you run into any further issues - Thanks!

tiwoc commented 6 months ago

Works great for us. Thanks, @hokstuff!