AnyView works, but I think a @ViewBuilder is nicer.
https://developer.apple.com/documentation/swiftui/viewbuilder
struct HeaderView: View {
@State var choices = Choices.one
@ViewBuilder
var body: some View {
switch choices {
case .two:
ChoiceTwoView(choices: choices)
default:
ChoiceOneView(choices: choices)
}
}
}
Note that there is no return statement.
Post
Replies
Boosts
Views
Activity
Dear Steve T,
Thanks for your tip! Indeed I am not calling SKPaymentQueue.restoreCompletedTransactions, but only SKReceiptRefreshRequest, since I was processing the receipts anyway on our server. I will try to call SKPaymentQueue.restoreCompletedTransactions as well and see if that solves the issue. It will take a while before I can confirm that this works.
After I have added SKPaymentQueue.restoreCompletedTransactions I did not receive any complaints of users expierincing problems with family sharing of in app purchases.
So concluding, SKReceiptRefreshRequest refreshes the receipt, but does not always fetch all family shared in-app purchases. To make sure you get all the in app purchases shared by family members you need to invoke SKPaymentQueue.restoreCompletedTransactions.
I got the "Missing package product" error when including a local Swift Package in two xcode projects simultaneously (Xcode 13.4.1). My solution was to close one of the projects and then the error went away. It seems it is not possible to use the same local package simultaneously in two open projects.
In addition to the correct answer of Quinn above. To conditionalise the entitlements based on platform, navigate to the xcode build settings, search for 'entitlements', and add an entry for a platform specific entitlements file, as in the example below:
Also having the same problem with WCSessionFileTransfer.
The didFinish fileTransfer delegate method is never called anymore.
I also successfully used the solution with sending a custom message from the Watch OS app to the iOS app once the file received.
I also noticed that the WCSession keeps all oustandingFileTransfers. I clean them by checking the progress, and cancelling them manually and do some custom cleanup.
for fileTransfer in session.outstandingFileTransfers {
if (fileTransfer.progress.isFinished) {
fileTransfer.cancel()
didFinish(fileTransfer) // my method
}
}
Hopefully Apple fixes this issue soon.
We also had unexpected crashes on launch on iOS 17 due to using NSDecimalRound. We have followed the suggestion from the known issues in the Xcode 16 RC Release notes by writing a designated class in Objective C and calling the NSDecimalRound function from objective C instead of from Swift.
This prevents the crash.
Below our code:
// DecimalRoundFix.m
#import "DecimalRoundFix.h"
@implementation DecimalRoundFix
+(void)round:(nonnull NSDecimal *)result number: (nonnull NSDecimal *)number scale: (NSInteger) scale roundingMode: (NSRoundingMode) roundingMode {
NSDecimalRound(result, number, scale, roundingMode);
}
@end
// DecimalRoundFix.h
#import <Foundation/Foundation.h>
@interface DecimalRoundFix : NSObject {
}
+(void)round:(nonnull NSDecimal *)result number: (nonnull NSDecimal *)number scale:(NSInteger) scale roundingMode: (NSRoundingMode) roundingMode;
@end
Then in your Swift code replace everywhere:
NSDecimalRound(&result, &number, scale, roundingMode) with DecimalRoundFix.round(&result, number: &number, scale: scale, roundingMode:roundingMode).