-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable asserts in release builds when using Swift Package Manager #1061
Conversation
Hi @rcancro! Thanks for reporting! We try to be extremely conservative with Have you hit any of them while running the app? Note: we're working on a v4 of the SDK, built entirely in Swift, that handles these a bit differently. This is currently in beta, though. |
I don't love disabling assertions, but I suppose this change makes SPM consistent with the project. |
I think given that we're very close to releasing RCv4, we should audit As for updating RCv3 for setting Of course, that is worst case scenario, but IMO I'd prefer to have the SDK crash right now instead of having the potential to silently do the wrong thing. We're going to continue to examine how we willfully crash, though. This is really good feedback. |
I did notice there are very few places where you use
Actually, right now it appears that asserts are disabled in release for Cocoapods. If leaving assertions on in release is your desired behavior, then you need to add that to the Podspec I believe. Or if you turn asserts off in SPM it will make both methods of installing Purchases consistent. |
Yeah, great point and I didn't realize we had different configs for SPM/Pods, whoops. I'll chat with the team about this. We should, at least, be consistent! |
@@ -26,7 +26,9 @@ func resolveTargets() -> [Target] { | |||
exclude: [infoPlist], | |||
sources: ["Purchases"], | |||
publicHeadersPath: "Purchases/Public", | |||
cSettings: objcSources.map { CSetting.headerSearchPath($0) } | |||
cSettings: objcSources.map { CSetting.headerSearchPath($0) } + [ | |||
.define("NS_BLOCK_ASSERTIONS", to: "1", .when(configuration: .release)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of this to have consistency across the different types of integration, but I'll let the team chime in.
If we merge this, could you add a comment linking to https://forums.swift.org/t/assertions-in-swift-packages/42692 for future reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to do some research before I can 👍
@taquitos any updates here? |
I'm ok with this. That being said, we're about to launch RCv4, so we'd want to merge this in a new hotfix branch for v3. |
@rcancro thanks for the PR, explanation and patience! I'm merging this now and making a release |
When using Swift Package Manager to integrate
Purchases
into an app, Xcode does not automatically setNS_BLOCK_ASSERTIONS
to1
when building the package in release. This means that anyNSAsserts
that are hit in release cause crashes. This appears to only be an issue with ObjC packages.The change I've made is to
Package.swift
to setNS_BLOCK_ASSERTIONS
to1
when building in release.(Note: I didn't actually hit an assert in this Purchases, but the possibility is there)
I haven't added unit tests as I can't think of a way to do that using SPM. I did, however, point to your branch of 3.13.1 and change a configure method to look like:
When building in release and pointing to your 3.13.1 branch, this causes a crash. I think change SPM to point to my fork with the change in
Package.swift
and the assert no longer caused a crash.