I'm unable to figure out how to know when my app no longer has focus. ScenePhase will only change when the WindowGroup gets created or closed.
UIApplication.didBecomeActive and UIApplication.didEnterBackgroundNotification are not called either when say you move focus to Safari.
What's the trick?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,My iOS Swift app contains a in-house built framework (A), which is also using Swift. This framework includes 2 in-house built frameworks (B and C) using Objective-C."Embedded Content Contains Swift Code" is set to YES for the app and to NO for the A, B and C frameworks.When I try to submit the app to iTC, I get these errors:ERROR ITMS-90205: "Invalid Bundle. The bundle at 'yourapp.app/Frameworks/A.framework' contains disallowed nested bundles."...ERROR ITMS-90206: "Invalid Bundle. The bundle at 'yourapp.app/Frameworks/A.framework' contains disallowed file 'Frameworks'."...How can I fix those?
Is there a way to force a window to resize according to an aspect ratio? This is possible in AppKit via the NSWindow.contentAspectRatio property but I cannot find something similar for SwiftUI.
Basically, I want the window to maintain the aspect ratio of its contents.
Is .refreshable supposed to do anything on macOS? Works fine on iOS and iPadOS but it's not triggered on macOS. It's available since macOS 12 but the documentation doesn't mention anything about that.
https://developer.apple.com/documentation/swiftui/view/refreshable(action:)
Is it possible to have sections in a SwiftUI table? I cannot find any documentation or examples that show that it is.
This simple project just makes the Swift compiler crash in init(comparator: KeyPathComparator<RemoteComputer>):
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
enum CSItemOrderType: Int, Codable, CaseIterable, CustomStringConvertible {
case readableName
case lastConnectionDate
case numberOfConnections
var description: String {
switch self {
case .readableName: return "STR_NAME"
case .lastConnectionDate: return "STR_LAST_CONN_DATE"
case .numberOfConnections: return "STR_ORDER_MOST_CONNECTED"
}
}
}
struct CSItemOrder: Codable {
static let allCases = [CSItemOrder(type: .readableName),
CSItemOrder(type: .lastConnectionDate, order: .reverse),
CSItemOrder(type: .numberOfConnections, order: .reverse)]
static let allSortOrders = [KeyPathComparator(\RemoteComputer.readableName),
KeyPathComparator(\RemoteComputer.lastConnectionDate),
KeyPathComparator(\RemoteComputer.numberOfConnections)]
let type: CSItemOrderType
var order: SortOrder
var comparator: KeyPathComparator<RemoteComputer> {
switch type {
case .readableName: return KeyPathComparator(\RemoteComputer.readableName, order: order)
case .lastConnectionDate: return KeyPathComparator(\RemoteComputer.lastConnectionDate, order: order)
case .numberOfConnections: return KeyPathComparator(\RemoteComputer.numberOfConnections, order: order)
}
}
init(type: CSItemOrderType, order: SortOrder = .forward) {
self.type = type
self.order = order
}
init(comparator: KeyPathComparator<RemoteComputer>) throws {
switch comparator.keyPath {
case \RemoteComputer.readableName: self.init(type: .readableName, order: comparator.order)
case \RemoteComputer.lastConnectionDate: self.init(type: .lastConnectionDate, order: comparator.order)
case \RemoteComputer.numberOfConnections: self.init(type: .numberOfConnections, order: comparator.order)
default:
print("Unsupported keyPath: \(comparator.keyPath)")
throw ItemOrderError.unsupportedKeyPath
}
}
}
struct RemoteComputer: Codable, Hashable, Identifiable {
let id: Int
let name: String
let hostname: String?
let localIpAddress: String?
let vncPort: Int
let sshPort: Int
let publicIpAddress: String?
let publicPort: Int
let macAddress: String
let scVersion: String
let manualMode: Int
let uuid: String
let lastMappingStatus: String?
let isAwake: Bool
let unregistered: Bool
let osVersion: String?
let lastUpdate: Date
let remoteAddress: String?
let lastKeyboardLocale: String?
let macSystemShortcuts: [String: [Int32]]?
var readableName: String {
return name.removingPercentEncoding ?? name
}
var lastConnectionDate: Date {
return Date.now
}
var unwrappedPublicIpAddress: String {
return publicIpAddress ?? NSLocalizedString("STR_NOT_AVAILABLE", comment: "")
}
var numberOfConnections: Int {
return 0
}
}
enum ItemOrderError: Error {
case unsupportedKeyPath
}
This code works fine in previous betas or Xcode 15.
I don't know if this is a iOS 18.1 beta bug or some StoreKit server issues but Product.SubscriptionInfo.Status is returning an empty array in production even if the user has a valid subscription that is months away from expiring or renewing.
I myself ran into this issue this morning but of course everything is fine in development mode so that makes it quite challenging to debug.
Anyone else has this issue?
Hi everyone,
I’m running into a strange animation glitch when using a Menu inside a glassEffect container.
Here’s a minimal example:
import SwiftUI
struct ContentView: View {
@Namespace private var namespace
var body: some View {
ZStack {
Image(.background)
.resizable()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.ignoresSafeArea()
GlassEffectContainer {
HStack {
Button("b1") {}
Button("b2") {}
Button("b3") {}
Button("b4") {}
Button("b5") {}
Menu {
Button("t1") { }
Button("t2") { }
Button("t3") { }
Button("t4") { }
Button("t5") { }
} label: {
Text("Menu")
}
}
}
.padding(.horizontal)
.frame(height: 50)
.glassEffect()
}
}
}
What happens:
The bar looks fine initially:
When you open the Menu, the entire bar morphs into the menu:
When dismissing, the bar briefly animates into a solid rectangle before reapplying the glass effect:
Questions:
Is there a way to prevent that brief rectangle animation when dismissing the menu?
If not, is it possible to avoid the morphing altogether and have the menu simply overlay on top of the bar instead of replacing it?
Any ideas or workarounds would be greatly appreciated!
For some reason, a List will reset its selection to nil when the app is in the background.
Steps to reproduce the issue:
Run attached sample project
Once the app has launched, select a name in the sidebar
Move the app to the background
Wait a few seconds
Bring back the app to the foreground
Expected result:
The list selection should still be valid
Actual result:
The list selection is set to nil
Notes:
I’m using a StateObject, which should be the way to ensure that data isn’t regenerated when views are rendered. Is this a bug or something else needs to be taken care of?
class AppModel: ObservableObject {
@Published var selectedPerson: Person?
}
@main
struct NilListSelectionApp: App {
@StateObject var appModel = AppModel()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(appModel)
}
}
}
struct Person: Identifiable, Hashable {
let id: UUID
let firstname: String
init(firstname: String) {
id = UUID()
self.firstname = firstname
}
}
struct ContentView: View {
@EnvironmentObject private var appModel: AppModel
var body: some View {
NavigationSplitView {
SidebarView()
} detail: {
PersonView(person: appModel.selectedPerson)
}
}
}
struct SidebarView: View {
@EnvironmentObject private var appModel: AppModel
private let persons = [Person(firstname: "Joe"), Person(firstname: "Jane")]
var body: some View {
List(persons, id:\.self, selection: $appModel.selectedPerson) { person in
Text(person.firstname).tag(person)
}
.listStyle(.sidebar)
}
}
struct PersonView: View {
let person: Person?
var body: some View {
if let person {
Text(person.firstname)
}
else {
Text("No Selection")
}
}
}
I'm trying to create a List that allows multiple selection. Each row can be edited but the issue is that since there's a tap gesture on the Text element, the list is unable to select the item.
Here's some code:
import SwiftUI
struct Person: Identifiable {
let id: UUID
let name: String
init(_ name: String) {
self.id = UUID()
self.name = name
}
}
struct ContentView: View {
@State private var persons = [Person("Peter"), Person("Jack"), Person("Sophia"), Person("Helen")]
@State private var selectedPersons = Set<Person.ID>()
var body: some View {
VStack {
List(selection: $selectedPersons) {
ForEach(persons) { person in
PersonView(person: person, selection: $selectedPersons) { newValue in
// ...
}
}
}
}
.padding()
}
}
struct PersonView: View {
var person: Person
@Binding var selection: Set<Person.ID>
var onCommit: (String) -> Void = { newValue in }
@State private var isEditing = false
@State private var newValue = ""
@FocusState private var isInputActive: Bool
var body: some View {
if isEditing {
TextField("", text: $newValue, onCommit: {
onCommit(newValue)
isEditing = false
})
.focused($isInputActive)
.labelsHidden()
}
else {
Text(person.name)
.onTapGesture {
if selection.contains(person.id), selection.count == 1 {
newValue = person.name
isEditing = true
isInputActive = true
}
}
}
}
}
Right now, you need to tap on the row anywhere but on the text to select it. Then, if you tap on the text it'll go in edit mode.
Is there a way to let the list do its selection? I tried wrapping the tap gesture in simultaneousGesture but that didn't work.
Thanks!
Since iOS/iPadOS beta 6, I get a crash just by simply selecting an item in the sidebar of a navigation view. The selected item is part of an app mode, with conforms to the Observation protocol:
import SwiftUI
import Observation
@main
struct MREAApp: App {
@State private var appModel = AppModel.shared
var body: some Scene {
WindowGroup {
ContentView()
.environment(appModel)
}
}
}
@Observable class AppModel {
static var shared = AppModel()
var selectedFolder: Folder? = nil
}
struct Folder: Hashable, Identifiable {
let id = UUID()
let name: String
}
struct ContentView: View {
@Environment(AppModel.self) private var appModel
var folders = [Folder(name: "Recents"), Folder(name: "Deleted"), Folder(name: "Custom")]
var body: some View {
NavigationSplitView {
SidebarView(appModel: appModel, folders: folders)
} detail: {
if let folder = appModel.selectedFolder {
Text(folder.name)
}
else {
Text("No selection")
}
}
}
}
struct SidebarView: View {
@Bindable var appModel: AppModel
var folders: [Folder]
var body: some View {
List(selection: $appModel.selectedFolder) {
ForEach(folders, id: \.self) { folder in
NavigationLink(value: folder) {
Text(folder.name)
}
}
}
}
}
To reproduce the bug, just tap on one of the item.
Oddly enough, this works fine in the Simulator.
macOS 14 beta 5 is not affected either.
Apple folks: FB12981860
The new Mac virtual display feature on visionOS 2 offers a curved/panoramic window. I was wondering if this is simply a property that can be applied to a window, or if it involves an immersive mode or SceneKit/RealityKit?
It appears there's an issue with the Mac App Store's ability to process offer codes, unlike its iOS counterpart, which handles them seamlessly. Users attempting to redeem a code on their Mac are encountering a "Cannot redeem code. Try another code" error.
Considering the Mac App Store's long history, having been introduced nearly 13 years ago, it's high time for it to align with the iOS App Store's functionality. While it's close to 80% there, addressing these lingering issues would greatly improve the user experience.
FB13463658
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store
App Store Connect
Mac App Store
I understand this is a known issue, but it’s truly unacceptable that it remains unresolved. Allowing users to customize toolbars is a fundamental macOS feature, and it has been broken since the release of macOS 15.
How is it possible that this issue persists even in macOS 15.3 beta (24D5040f)?
FB15513599
import SwiftUI
struct ContentView: View {
@State private var showEditItem = false
var body: some View {
VStack {
VStack {
Text("Instructions to reproduce the crash")
.font(.title)
.padding()
Text("""
1. Click on "Toggle Item"
2. In the menu go to File > New Window
3. In new window, click on "Toggle Item"
""")
}
.padding()
Button {
showEditItem.toggle()
} label: {
Text("Toggle Item")
}
}
.padding()
.toolbar(id: "main") {
ToolbarItem(id: "new") {
Button {
} label: {
Text("New…")
}
}
if showEditItem {
ToolbarItem(id: "edit") {
Button {
} label: {
Text("Edit…")
}
}
}
}
}
}
So I've started using TestFlight for Mac but unlike its iOS counterpart, it seems like every single build uploaded and pushed to testers has to be reviewed by Apple.
This is not how that works on the iOS side.
Ex:
MyApp 4.1 build 1 -> Review required for both iOS and Mac
MyApp 4.1 build 2 -> Review required for Mac, not iOS
Is this a bug or by design? If so, this is crazy!