Hi folks,
I've used a NavigationSplitView within one of the tabs of my app since iOS 16, but with the new styling in iOS 18 the toolbar region looks odd. In other tabs using e.g. simple stacks, the toolbar buttons are horizontally in line with the new tab picker, but with NavigationSplitView, the toolbar leaves a lot of empty space at the top (see below). Is there anything I can do to adjust this, or alternatively, continue to use the old style?
Thanks!
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Posts under SwiftUI tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Already filed a feedback in case this is a bug, but posting here in case I'm doing something wrong?
I'd like the search field to automatically be displayed with the keyboard up when the view appears. This sample code works in iOS 18, but it does not work in iOS 26 beta 7
I also tried adding a delay to setting searchIsFocused = true but that did not help
struct ContentView: View {
var body: some View {
NavigationStack {
NavigationLink(destination: ListView()) {
Label("Go to list", systemImage: "list.bullet")
}
}
.ignoresSafeArea()
}
}
struct ListView: View {
@State private var searchText: String = ""
@State private var searchIsPresented: Bool = false
@FocusState private var searchIsFocused: Bool
var body: some View {
ScrollView {
Text("Test")
}
.searchable(text: $searchText, isPresented: $searchIsPresented, placement: .automatic, prompt: "Search")
.searchFocused($searchIsFocused)
.onAppear {
searchIsFocused = true
}
}
}
When a popover is presented from a view that uses glassEffect(.regular.interactive()), I’m seeing mutually exclusive behavior: either the popover’s chrome (its navigation bar / toolbar) uses Liquid Glass or the originating control keeps its Liquid Glass “morph” behavior — but not both at the same time.
There are two ways that I can enable Liquid Glass on the container:
Option 1 (background capsule with .glassEffect) → The popover’s toolbar shows Liquid Glass, but the menu button loses its morph effect.
Option 2 (.glassEffect applied to the HStack) → The menu button keeps the morph effect, but the popover’s toolbar does not have Liquid Glass.
I'm using XCode 26.0.1, with latest iOS 26.0 stable simulator installed.
Here's an example code to reproduce the issue:
import PlaygroundSupport
import SwiftUI
// MARK: - TestView
struct TestView: View {
@State private var isPresented = false
var body: some View {
VStack {
Spacer()
HStack {
Button("", systemImage: "plus") {
isPresented = true
}
.popover(isPresented: $isPresented) {
MyPopover()
}
Menu {
Button("Option 1", action: {})
Button("Option 2", action: {})
Button("Option 3", action: {})
} label: {
Image(systemName: "ellipsis")
.frame(width: 40, height: 40)
}
}
.padding(.horizontal)
// Option 1 - The popover's toolbar will have liquid glass effect, but then the menu button loses liquid glass morph effect
.background {
Capsule()
.fill(Color.white)
.glassEffect(.regular.interactive())
}
// Option 2 - The popover's toolbar will not have liquid glass effect, but the menu button keeps liquid glass morph effect
// .glassEffect(.regular.interactive())
Spacer()
}
.frame(width: 400, height: 800)
}
}
// MARK: - MyPopover
private struct MyPopover: View {
var body: some View {
NavigationStack {
VStack {
ScrollView {
Text(
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
)
.padding(.horizontal)
}
}
.navigationTitle("Welcome")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("", systemImage: "xmark", action: {})
}
}
}
.presentationCompactAdaptation(.popover)
.frame(width: 300, height: 200)
}
}
PlaygroundPage.current.setLiveView(
TestView()
)
Attached the screenshots for the difference.
Hi. I‘m making an app with SwiftUI for iOS 26, and found that the old ways of changing unselected icons color seem not working as they did in old versions of iOS.
I tried these methods:
TabView() {
Tab {
// some view here
} label: {
Label(title: {
Text("something")
}, icon: {
Image(systemName: "checkmark.seal.fill")
.foregroundStyle(.blue)
}
}
}
I wrapped Image with an if-else, but itisn't able to change any color even without if;
struct ParentView: View {
init() {
UITabBar.appearance()
.unselectedItemTintColor
= UIColor.red
}
var body: some View {
TabView() {
// some tabs here
}
}
}
and an extension of above
struct ParentView: View {
init() {
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithOpaqueBackground()
tabBarAppearance.backgroundColor = UIColor.green
tabBarAppearance.stackedLayoutAppearance
.selected.titleTextAttributes
= [.foregroundColor: UIColor.red]
tabBarAppearance.stackedLayoutAppearance.normal
.titleTextAttributes
= [.foregroundColor: UIColor.black]
tabBarAppearance.stackedLayoutAppearance
.normal.iconColor = UIColor.black
tabBarAppearance.stackedLayoutAppearance
.selected.iconColor = UIColor.red
UITabBar.appearance()
.scrollEdgeAppearance
= tabBarAppearance
UITabBar.appearance()
.standardAppearance
= tabBarAppearance
UITabBar.appearance()
.unselectedItemTintColor
= .black
}
var body: some View {
TabView() {
// some tabs here
}
}
}
I read about this from reddit https://www.reddit.com/r/iOSProgramming/comments/1ftmfoa/tabbartabview_icon_and_text_colors_in_ios_18/,
it successfully changes the color of the texts in the tabbar, but not the icons.
After these, GitHub Copilot suggested me to draw two versions of icons, for different colors, which does work, but out of my capabilities. Is there any other ways to do this on new systems?
Thank you very much for any replies.
In SwiftUI I am using the manageSubscriptionsSheet modifier to open the iOS subscription screen. When this is presented it immediately flashes a white view and then animated the subscription screen up from the bottom, it looks pretty bad.
The view I am calling manageSubscriptionsSheet on is presented in a sheet, so maybe trying to present the subscriptions view as well is causing the visual glitch. Any way to not have this white flashing view when opening the subscription screen?
Hi everyone,
I recently updated to Xcode 26.0 and noticed that the “Extract Subview” refactoring option seems to be missing.
Now, in Xcode 26, the only options I see under Editor -> Refactor -> are:
Extract to Selection File
Extract to Method
Extract to Variable
Extract All Occurrences
But there’s no Extract Subview as there was before.
Was Extract Subview intentionally removed in Xcode 26? Or is it hidden behind a new menu location or renamed?
Hello,
We use the .confirmationDialog() view modifier to present an alert when deleting an item in a list. Prior to iOS 26, this dialog appeared as an action sheet on iPhone.
Following WWDC 25, my understanding is that on iOS 26 the dialog should appear as an action sheet over the originating view on iPhone. This is the behavior we observe in the built-in Messages and Mail apps when deleting an item (see the screenshot below).
However, when using .confirmationDialog() on iOS 26, the dialog is displayed as a standard popover on iPhone. I haven’t been able to reproduce the new expected behavior.
Here's a sample code:
struct ContentView: View {
@State var data: [String] = ["A", "B", "C"]
@State var confirmationPresented: Bool = false
var body: some View {
List {
ForEach(data, id: \.self) { item in
Text(item)
.confirmationDialog("Title", isPresented: $confirmationPresented, actions: {
Button(action: {
}, label: {
Text("OK")
})
})
.swipeActions {
Button("Delete", systemImage: "trash", action: {
confirmationPresented.toggle()
})
.tint(Color.red)
}
}
}
}
}
Here's the result from this sample code:
Is there an additional modifier or configuration required to enable the action sheet presentation on iPhone in iOS 26?
I’m encountering a consistent crash in WebKit when using WKWebView to play a YouTube playlist in my iOS app. Playback starts successfully, but the web process terminates during the second video in the playlist. This only occurs on physical devices, not in the simulator.
Here’s a simplified Swift example of my setup:
import SwiftUI
import WebKit
struct ContentView: View {
private let playlistID = "PLig2mjpwQBZnghraUKGhCqc9eAy0UbpDN"
var body: some View {
YouTubeWebView(playlistID: playlistID)
.edgesIgnoringSafeArea(.all)
}
}
struct YouTubeWebView: UIViewRepresentable {
let playlistID: String
func makeUIView(context: Context) -> WKWebView {
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
let webView = WKWebView(frame: .zero, configuration: config)
webView.scrollView.isScrollEnabled = true
let html = """
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0">
<style>body,html{height:100%;margin:0;background:#000}iframe{width:100%;height:100%;border:0}</style>
</head>
<body>
<iframe
src="https://www.youtube-nocookie.com/embed/videoseries?list=\(playlistID)&controls=1&rel=0&playsinline=1&iv_load_policy=3"
frameborder="0"
allow="encrypted-media; picture-in-picture; fullscreen"
webkit-playsinline
allowfullscreen
></iframe>
</body>
</html>
"""
webView.loadHTMLString(html, baseURL: nil)
return webView
}
func updateUIView(_ uiView: WKWebView, context: Context) {}
}
#Preview {
ContentView()
}
Observed behavior:
First video plays without issue.
Web process crashes when the second video in the playlist starts.
Console logs show WebProcessProxy::didClose and repeated memory status messages.
Using ProcessAssertion or background activity does not prevent the crash.
Only occurs on physical devices; simulators do not reproduce the issue.
Questions:
Is there something I should change or add in my WKWebView setup or HTML/iframe to prevent the crash when playing the second video in a playlist on physical iOS devices?
Is there an officially supported way to limit memory or prevent WebKit from terminating the web process during multi-video playback?
Are there recommended patterns for playing YouTube playlists in a WKWebView on iOS without risking crashes?
Any tips for debugging or configuring WKWebView to make it more stable for continuous playlist playback?
Thanks in advance for any guidance!
struct ContentView: View {
@State private var showingPopover:Bool = false
private var popOverHeight: CGFloat {
return 566
}
var body: some View {
NavigationStack {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
showingPopover = true
} label: {
Image(systemName: "plus")
.font(Font.system(size: 15))
.foregroundColor(Color.red)
}
.popover(isPresented: $showingPopover) {
FTShelfNewNotePopoverView1()
.frame(minWidth: 340.0)
.frame(height: popOverHeight)
}
}
}
}
}
}
Hi team,
I’m developing an iOS app that helps manage and translate multilingual content .
The app uses SwiftUI with Localizable.strings and Bundle.localizedString(forKey:). I’m trying to optimize for dynamic language switching inside the app without restarting.
I’ve tested various methods like:
Text(NSLocalizedString("welcome_text", comment: ""))
and some approaches using @Environment(.locale), but the system doesn’t always update views instantly when language changes.
Question:
What’s the recommended approach (or WWDC reference) for real-time language change handling in SwiftUI apps targeting iOS 18+?
Question
I'm trying to replicate the iOS 26 Photos app behavior where a segmented control appears in the tab bar area when scrolling. Specifically, when the tab bar minimizes to inline mode, I want to show a
Picker with .segmented style between the minimized tab button and search button.
Expected Behavior (iOS 26 Photos App)
When scrolling up in the Photos app:
Tab bar minimizes to inline mode
A segmented control (Years/Months/All) appears in the center
Layout: [Tab Button] [Segmented Control] [Search Button]
Current Implementation
I'm using tabViewBottomAccessory with tabBarMinimizeBehavior:
struct PhotosMainView: View {
@Environment(ModelData.self) private var modelData
@State private var searchText: String = ""
var body: some View {
@Bindable var modelData = modelData
TabView {
Tab("Library", systemImage: "photo.on.rectangle") {
NavigationStack {
PhotosGridView()
.navigationTitle("Library")
}
}
Tab("Albums", systemImage: "square.grid.2x2") {
NavigationStack {
AlbumsGridView()
.navigationTitle("Albums")
}
}
Tab("Search", systemImage: "magnifyingglass", role: .search) {
NavigationStack {
PhotosGridView()
.navigationTitle("Search")
.searchable(text: $searchText)
}
}
}
.tabBarMinimizeBehavior(.onScrollUp)
.tabViewBottomAccessory {
TimelineAccessoryView()
.environment(modelData)
}
}
}
struct TimelineAccessoryView: View {
@Environment(ModelData.self) private var modelData
@Environment(\.tabViewBottomAccessoryPlacement) var placement
var body: some View {
Group {
if let placement = placement {
switch placement {
case .inline:
inlineView
case .expanded:
expandedView
}
}
}
}
@ViewBuilder
private var inlineView: some View {
@Bindable var modelData = modelData
Picker("View", selection: $modelData.timelineFilter) {
Text("Years").tag(TimelineFilter.year)
Text("Months").tag(TimelineFilter.month)
Text("All").tag(TimelineFilter.all)
}
.pickerStyle(.segmented)
.frame(maxWidth: 200)
}
@ViewBuilder
private var expandedView: some View {
Text("Expanded state")
}
}
Issues Encountered
1. Console logs show placement changes correctly:
placement: nil → expanded → inline
2. However, the segmented control doesn't appear visually in inline mode
- The accessory view seems to render, but nothing is visible on screen
- Only a small empty space appears where the control should be
3. AttributeGraph cycle warnings appear:
=== AttributeGraph: cycle detected through attribute 27160 ===
=== AttributeGraph: cycle detected through attribute 26304 ===
What I've Tried
1. ✅ Separating inline/expanded views into @ViewBuilder properties to avoid cycles
2. ✅ Using .onAppear and .onChange for debugging instead of direct prints in body
3. ✅ Confirming placement environment value changes correctly
4. ❌ The segmented control still doesn't display in inline mode
Questions
1. Is tabViewBottomAccessory the correct API to achieve this Photos app effect?
2. How should content be structured in .inline placement to display properly between tab button and search?
3. Are there additional modifiers or constraints needed for inline accessories?
4. Is there documentation or sample code showing this pattern?
Environment
- Xcode 17.0
- iOS 26.0
- iPhone 16 Simulator
- SwiftUI
Any guidance on the correct approach to implement this would be greatly appreciated. Thank you!
I am currently struggling with resolving what appear to be competing design issues, and (while I may be just demonstrating my own ignorance) I would like to share my thoughts in the hope that you may have useful insights.
For purposes of discussion, consider a large and complex data entry screen with multiple sections for input. For all of the usual reasons (such as reuse, performance management, etc) each of these sections is implemented as its own, separately-compiled View. The screen is, then, composed of a sequence of reusable components.
However, each of these components has internal structure and may contain multiple focusable elements (and internal use of .onKeyPress(.tab) {...} to navigate internally). And the logic of each component is such that it has an internal @FocusState variable defined with its own unique type.
So, obviously what I want is
on the one hand, to provide a tab-based navigation scheme for the screen as a whole, where focus moves smoothly from one component's internals to the next component, and
on the other hand ,to build components that don't know anything about each other and have no cross-component dependencies, so that they can be freely reused in different situations.
And that's where I'm stuck. Since focus state variables for different components can have different types, a single over-arching FocusState passed (as a binding) to each component doesn't seem possible or workable. But I don't know how else to approach this issue.
(Note: in UIKit, I've done things like this by direct manipulation of the Responder Chain, but I don't see how to apply this type of thinking to SwiftUI.)
Thoughts?
Summary
On iOS 26, the navigation bar unexpectedly switches to a Light appearance during/after a view transition while the device/app is in Dark Mode. This seems correlated with applying listStyle(.plain) to a List. Removing .plain prevents the issue, but my app’s layout requires it.
Sample code:
import SwiftUI
@main
struct iOS26NavigationTitleSampleApp: App {
var body: some Scene {
WindowGroup {
NavigationStack {
ContentView()
.navigationTitle("Root")
.navigationBarTitleDisplayMode(.inline)
}
}
}
}
struct ContentView: View {
var body: some View {
VStack {
NavigationLink {
ListView()
} label: {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
}
}
.padding()
.toolbar {
ToolbarItemGroup(placement: .navigation) {
Button("Test") {
}
Button("Test2") {
}
}
}
}
}
struct ListView: View {
var items: [Int] = Array(0..<100)
var body: some View {
List {
ForEach(items.indices, id: \.self) { idx in
cell(items[idx])
}
}
.listStyle(.plain)
.toolbar {
ToolbarItemGroup(placement: .navigation) {
Button("Test") {
}
Button("Test2") {
}
}
}
.navigationTitle("TTT")
}
private func cell(_ item: Int) -> some View {
Text("\(item)")
}
}
Steps to Reproduce:
Set the device to Dark Mode.
Launch the sample app. → The root view’s navigation bar is in Dark appearance (as expected).
Tap “Hello World” to navigate. → On the destination view, the navigation bar becomes Light.
Navigate back to the root view. → The root view’s navigation bar now also remains Light.
Expected Result
The navigation bar should consistently retain the Dark appearance throughout navigation.
Notes
Removing listStyle(.plain) stops the issue (navigation bar stays Dark).
Simulator: Could not reproduce on iOS Simulator.
Devices: Reproducible on physical device.
Environment
Device: iPhone 15 Plus
OS: iOS 26 (23A341)
Xcode: 26.0 (17A324)
When Home tab opened, there is some white shadow on the bottom and the top sides of the list. But when switching to other tab or return to Home tab this shadow disappearing for a second and appearing again.
Actual for iOS 26.0.1 on simulator and on real device.
Below is short example code that can reproduce issue.
When change
let pages = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal)
to
let pages = UIPageViewController(transitionStyle: .pageCurl, navigationOrientation: .horizontal)
issue is not reproduced.
import SwiftUI
@main
struct GlassTestApp: App {
var body: some Scene {
WindowGroup {
MainView()
.ignoresSafeArea()
}
}
}
struct MainView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UITabBarController {
let controller = UITabBarController()
let home = Home()
home.tabBarItem = UITabBarItem(title: "Home", image: UIImage(systemName: "house"), tag: 1)
let settings = UIHostingController(rootView: Settings())
settings.tabBarItem = UITabBarItem(title: "Settings", image: UIImage(systemName: "gearshape"), tag: 2)
controller.viewControllers = [home, settings]
return controller
}
func updateUIViewController(_ uiViewController: UITabBarController, context: Context) {
}
}
class Home: UINavigationController {
init() {
let pages = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal)
pages.setViewControllers([UIHostingController(rootView: Page1())], direction: .forward, animated: false)
super.init(rootViewController: pages)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
struct Page1: View {
var body: some View {
List {
ForEach(1...100, id: \.self) {
Text("\($0)")
}
}
.listStyle(.plain)
}
}
struct Settings: View {
var body: some View {
Text("Settings")
}
}
After returning from the child view to the parent, the latter one will simply disappear.
This is the full view. See itemsContent where I perform the navigation.
The last tapped rectangle in this example will simply disappear.
struct DashboardView: View {
@State var viewModel: DahsboardViewModel
@Namespace private var namespace
var body: some View {
ScrollView(.vertical) {
LazyVStack(spacing: 24) {
ForEach(viewModel.sections) { section in
VStack(spacing: 16) {
Text(section.title)
itemsContent(for: section)
}
}
}
}
}
func itemsContent(for section: DashboardSection) -> some View {
ForEach(section.items) { item in
NavigationLink {
PatternLearningRouter().rootView
.id(item.id)
.navigationTransition(.zoom(sourceID: item.id, in: namespace))
} label: {
Rectangle()
.fill(Color.yellow)
.frame(width: 80, height: 80)
.overlay {
Text(item.title)
}
.matchedTransitionSource(id: item.id, in: namespace)
}
}
}
}
XCode26 26.0.1(17A400)
iPhone 16 Pro, iOS 26.0.1
Note:
Only reproduced when I swipe back (not reproducing it when using back button)
Only reproduced on real device not simulator
I
I want a different color, one from my asset catalog, as the background of my first ever swift UI view (and, well, swift, the rest of the app is still obj.c)
I've tried putting the color everywhere, but it does't take. I tried with just .red, too to make sure it wasn't me. Does anyone know where I can put a color call that will actually run? Black looks very out of place in my happy app. I spent a lot of time making a custom dark palette.
TIA
KT
@State private var viewModel = ViewModel()
@State private var showAddSheet = false
var body: some View {
ZStack {
Color.myCuteBg
.ignoresSafeArea(.all)
NavigationStack {
content
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
Image("cute.image")
.font(.system(size: 30))
.foregroundColor(.beigeTitle)
}
}
}
.background(Color.myCuteBg)
.presentationBackground(.myCuteBg)
.sheet(isPresented: $showAddSheet) {
AddView()
}
.environment(viewModel)
.onAppear {
viewModel.fetchStuff()
}
}
.tint(.cuteColor)
}
@ViewBuilder var content: some View {
if viewModel.list.isEmpty && viewModel.anotherlist.isEmpty {
ContentUnavailableView(
"No Content",
image: "stop",
description: Text("Add something here by tapping the + button.")
)
} else {
contentList
}
}
var contentList: some View {
blah blah blah
}
}
First I tried the background, then the presentation background, and finally the Zstack. I hope this is fixed because it's actually fun to build scrollable content and text with swiftUI and I'd been avoiding it for years.
After writing the code, when debugging on VisionPro, the program will encounter a blocking situation when running from Xcode to VisionPro. It will take a long time for the execution information to appear on the Xcode console
[Also submitted as FB20636175]
In iOS 26.1 Seed 2 (23B5059e), ToolbarItem menus with .bottomBar placement cause the toolbar item to disappear and rebuild after the menu is dismissed, instead of smoothly morphing back. The bottom toolbar can take 1–2 seconds to reappear.
This also seems to coincide with this console error:
Adding 'UIKitToolbar' as a subview of UIHostingController.view is not supported and may result in a broken view hierarchy. Add your view above UIHostingController.view in a common superview or insert it into your SwiftUI content in a UIViewRepresentable instead.
This occurs both on device and in a simulator.
Sample Project
This sample ContentView includes two menu buttons—one in the bottom bar and one in the top bar. Dismissing the bottom bar menu causes a short delay before the button reappears, while the top bar menu behaves normally.
struct ContentView: View {
var body: some View {
NavigationStack {
Text("Tap and dismiss both menu buttons and note the difference.")
.navigationTitle("BottomBar Menu Issue")
.navigationSubtitle("Reproduces on iOS 26.1 Seed 2 (23B5059e)")
.toolbar {
// Control: top bar trailing menu animates back smoothly
ToolbarItem(placement: .topBarTrailing) {
Menu {
Button("Dismiss", role: .cancel) { }
Button("Do Nothing") { }
} label: {
Label("More", systemImage: "ellipsis.circle")
.font(.title3)
}
}
// Repro: delay before menu button reappears after menu dismissal
ToolbarItem(placement: .bottomBar) {
Menu {
Button("Dismiss", role: .cancel) { }
Button("Do Nothing") { }
} label: {
Label("Actions", systemImage: "ellipsis.circle")
.font(.title2)
}
}
}
}
}
}
Passwords App
This can also be seen in iOS 26.1 Seed 2 (23B5059e)'s Passwords app ("All" or "Passcodes" views):
Hey everyone. I have a macOS app written in SwiftUI. I have multiple SwiftUI Scenes and Views, but needed to write one specific window in AppKit (an NSPanel, to be specific). The problem I'm facing is- I'm not sure how to incorporate this NSPanel with the rest of my SwiftUI/Observable code. I'm relying on the SwiftUI app cycle.
For example, I have a boolean in my view model (observation tracked). I'd like to use this boolean to hide/unhide my NSPanel. Any way to cleanly hook into the viewmodel, or onto some specific observable variables would be very very helpful. Thank you everyone.
After creating a new weekly subscription option, I get inconsistent results for subscriptionPeriod. In local testing with a synced or a un-synced StoreKit file I am getting unit == .week (as expected) whereas in TestFlight I am getting unit == .day. This makes unit.localizedDescriptionsomewhat unusable in the paywall.
Am I missing something? Or is this bug or a limitation of StoreKit and/or TestFlight and/or newly created subscription options?
Affected code (in a custom SubscriptionStoreControlStyle):
private func priceDisplay(for pickerOption: Configuration.PickerOption) -> String {
var result = ""
if pickerOption.introductoryOffer != nil {
result += NSLocalizedString("then", comment: "") + " "
}
result += pickerOption.displayPrice
if let unit = pickerOption.subscriptionPeriod?.unit {
result += " / " + unit.localizedDescription
}
return result
}
private func percentageSaved(for pickerOption: Configuration.PickerOption, allOptions: [Product]) -> Int? {
guard let subscriptionPeriod = pickerOption.subscriptionPeriod, subscriptionPeriod != .weekly else {
return nil
}
let weeklyOption = allOptions.first { otherOption in
otherOption.subscription?.subscriptionPeriod == .weekly
}
guard let weeklyOption, weeklyOption.price > 0 else {
return nil
}
let percentageSaved = 100 - (pickerOption.price / (weeklyOption.price * 52)) * 100
return Int((percentageSaved as NSNumber).doubleValue)
}