Environment:
Xcode16, iOS 18.1 official version
Background:
I created a control center widget using a custom sf symbol
Phenomenon:
When I first installed it, it displayed normally in the control gallery, but when I recompiled and installed it again, the icon disappeared when I looked at it again in the control gallery. I used Console to check the error log and found that its output was' No image named 'my_custom _symbol_name' found in asset catalog for/private/var/containers/Bundle/Application/F977FCFB-DA1C-4924-8613-50531CA2A364/MyDemoApp. app/PlugIns/MyDemoApp Extension. apex '. I found that this uuid was not consistent with the uuid I print during debugging, as if the control gallery had done some kind of caching;
Additionally, when I added my Control to the Control Center, it was able to display normally, and the only issue was with the Control Gallery
Attempted method:
-Using the system SF Symbol, it works fine and can be displayed normally in the control gallery after recompilation. However, once I switch another SF Symbols, the icons in the control gallery do not update after recompilation and installation
-Restarting the device, the same issue still persists
Is this a system bug or did I make a mistake? Looking forward to someone helping, thank you
My Code:
@available(iOSApplicationExtension 18.0, *)
struct MySearchControlWidget: ControlWidget {
let kind = "MySearchControlWidget"
let title = "My Title"
var body: some ControlWidgetConfiguration {
let intent = MyCommonButtonControlWidgetIntent()
StaticControlConfiguration(kind: kind) {
ControlWidgetButton(action: intent) {
Label("\(title)", image:"my_custom_symbol_name")
}
}
.displayName("\(title)")
}
}
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Post
Replies
Boosts
Views
Activity
xcode16,iphone16,iOS 自定义navigationItemLeftBar,设置 navigationController?.interactivePopGestureRecognizer?.delegate = self,侧划返回一半,点击屏幕,界面卡死。
18系统之前的手机,或者非iphone16的手机没有问题。
I am trying to understand why I am seeing crash reports for my code that creates a view from a NIB like the code below. The crash occurs when referencing contentView which should have been bound when the NIB was loaded.
Am I missing something here other than checking the result of the loadNibNamed function call?
class MyView: NSView {
@IBOutlet var contentView: NSView!
init() {
super.init(frame: NSRect(x: 0, y: 0, width: 84.0, height: 49.0))
commonInit()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func commonInit() {
Bundle.main.loadNibNamed("MyView", owner: self, topLevelObjects: nil)
translatesAutoresizingMaskIntoConstraints = false
contentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentView)
contentView.frame = self.bounds
}
I am using iphone 11 with ios version 18.1 and I found one issue in call recording during FT audio call. Call gets dropped as soon as call recording start. This bug is also reproducible on iphone 14 pro max having same ios version. I tried it 5/5 times and it is 100% reproducible. Can you please help to fix this issue. This is really a serious quality concern as per apple standards.
Hi
I have tried the code given on link https://developer.apple.com/documentation/appdistribution/fetching-and-displaying-managed-apps. This code is not compilable in Xcode 16.1.
After some fixes i am able to run the code but i am getting Error registering for message: [App catalog changed]: An unspecified, unrecoverable error occurred.
Kindly help me with this.
Hi, my I know what is wrong with my code, I have a unintended border around my game although there is no padding, can someone help me thanks!
This is my code:
`
We've created a test app to highlight the problem: https://www.dropbox.com/scl/fi/3hl63t772qeguc1bxr9xi/Test.zip?rlkey=pofk3ji2s93ucq3r1l8m39z0u&dl=0
As you can see we have enforced exclusive touch in the init method, a solution which worked until iOS 18 which now doesn't work anymore.
How can we force exclusive touch on SwiftUI in iOS 18+?
I've looked at lots of Grid examples. I've seen it documented that views within a GridRow are treated as if they were in an HStack. That's not happening for me. I have to explicitly put them into an HStack or they are treated as new rows.
Here's my code:
@State private var gridRows : Int = 4
@State private var gridCols : Int = 2
@State private var myItems : [Int] = Array(0...8)
var body: some View
{
Group
{
if myItems.count > 0
{
ScrollView([.vertical])
{
Grid(alignment: .leading)
{
ForEach(0..<gridRows, id: \.self)
{ rowNdx in
GridRow
{
HStack // <<---
{
ForEach(0..<gridCols, id: \.self)
{ colNdx in
Text("\(rowNdx) \(colNdx)")
}
}
}
}
}
}
}
}
}
With the HStack I get (as expected).
0 0 0 1
1 0 1 1
2 0 2 1
3 0 3 1
Without the HStack I get
0 0
0 1
1 0
1 1
...
What have I done wrong?
On iOS you can create a new Lock Screen that contains a bunch of emoji, and they'll get put on the screen in a repeating pattern, like this:
When you have two or more emoji they're placed in alternating patterns, like this:
How do I write something like that? I need to handle up to three emoji, and I need the canvas as large as the device's screen, and it needs to be saved as an image. Thanks!
(I've already written an emojiToImage() extension on String, but it just plonks one massive emoji in the middle of an image, so I'm doing something wrong there.)
In the Explore enhancements to App Intents WWDC video at the 11 minute mark I see this UI in the Widget configuration.
My question is, how do I configure my Widget to use this UI in the intent configuration? I tried using all different sorts of types and am unable to reproduce it in my app
Hi, after updating Xcode to Version 16.1, I started a new multiplatform project targeting macOS and iOS. Everything worked fine until I added Firebase SDK 11.4 (using Swift Package Manager). Now, I'm facing an issue where the preview is not possible with "My Mac" after adding Firebase SDK, even with a very simple view like:
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
#Preview {
ContentView()
}
However, previewing with iPhone or iPad works fine. This is really frustrating. When I run the app on a simulator (Mac, iPhone, or iPad), everything works perfectly.
The error shown is Cannot preview in this file: Failed to launch [AppName] with the following path: /Users/[myname]/Library/Developer/Xcode/DerivedData/[AppName-gemeoxpjlzrshfifmgmqrkcxdeiz/Build/Products/Debug/FirebaseFirestoreInternal.framework/FirebaseFirestoreInternal
Run Destination: macOS 15.1.
What I have tried so far:
Cleaned the build folder
Re-installed Firebase SDK
Any insights would be greatly appreciated! Thank you!
Hello, I recently have crashes on my application, it results in many crashes with different reasons, here are the different main reasons:
AttributeGraph: AG::Graph::update_main_refs(AG::AttributeID)
SwiftUICore: closure #1 in ViewLayoutEngine.explicitAlignment(_:at:)
SwiftUICore: __swift_instantiateGenericMetadata
My main problem is that these crashes appeared without any major changes to my app, and they never happen when I emulate the app from xcode whether on a simulator or a real device. I have other crashes with other errors I can provide them if necessary.
So I have a lot of trouble identifying where the errors come from, I tried to activate zombie objects, and address sanitizer without it revealing anything. Thanks in advance for the answers.
We're seeing sporadic crashes on devices running iOS 18.1 - both beta and release builds (22B83). The stack trace is always identical, a snippet of it below. As you can tell from the trace, it's happening in places we embed SwiftUI into UIKit via UIHostingController.
Anyone else seeing this?
4 libobjc.A.dylib 0xbe2c _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 30
5 libobjc.A.dylib 0xb040 weak_register_no_lock + 396
6 libobjc.A.dylib 0xac50 objc_storeWeak + 472
7 libswiftCore.dylib 0x43ac34 swift_unknownObjectWeakAssign + 24
8 SwiftUI 0xeb74c8 _UIHostingView.base.getter + 160
9 SwiftUI 0x92124 _UIHostingView.layoutSubviews() + 112
10 SwiftUI 0x47860 @objc _UIHostingView.layoutSubviews() + 36
Hello!
I am trying to remove a photo from my Photos Library using PhotosUI. I run into this error when I attempt to delete it:
"Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
No photos access scope requirements declared for changes
Failed to log access with error: access= accessor:<> identifier:82068C12-FD10-4DE2-9867-B4406FBFB706 kind:intervalEvent timestampAdjustment:0 visibilityState:0 assetIdentifierCount:0 accessCount:0 tccService:kTCCServicePhotos, error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.privacyaccountingd" UserInfo={NSDebugDescription=connection to service named com.apple.privacyaccountingd}
Hello, I have a small lightweight macOS application that includes a medium widget but the widget does not update with new data as often as I'd like. I understand that in apple's WidgetKit documentation they mention that apple controls when the widget updates due to battery life concerns, but I'd like to know if theres any way at all to control when the widget updates or when I think it makes sense to do so if I am not able to control how often it refreshes new data.
https://github.com/Alexx1105/MacStat-v2.1
DESCRIPTION OF PROBLEM
When my Document-based macOS SwiftUI app starts up, it always presents a document picker. I would like it to open any documents that were open when the app last quit, and if none were open, open an "Untitled" document. I understand that there is a setting in System Settings-> Desktop & Dock ("Close windows when quitting an application") that will cause windows to reopen when it is turned off, but I'd like to give users a chance to opt-in for reopening docs even when that is turned on, since it is difficult to find, on by default, and might not be the desired behavior for all apps. I don't see any way to get a list of currently open documents to persist them at shutdown.
And even if that's considered a bad idea, I'd at least like a way to prevent the Document picker from being shown at startup and instead create an Untitled document if no documents were open.
Ideally, I'd like a way to provide this functionality in SwiftUI that doesn't require macOS 15 or later
STEPS TO REPRODUCE
Create a SwiftUI macOS document application in Xcode using the provided template, Give it any name you want
Run it, create a new ".exampletext" document, save it.
Quit the app with the document open.
Re-run the app, document picker is shown.
Cancel the document picker and quit the app with no windows shown.
Re-run the app, document picker is shown.
Hi,
Im developing a data centric App using SwiftData, I noticed that the device I use for testing doesn't sync its data with the simulator although both have same Apple Account ? What's Im missing here ? arched is my project settings.
Kind Regards
I want to create master details relationship between patient and vitals signs so which of option codes below are better performance wise ? Option one is master - details done manually ..
option 1
@Model
class TestResult {
@Attribute(.primaryKey) var id: UUID
var patientID: UUID
Option 2
@Model
final class Vital {
var patient: Patient?
In Swift 6, stricter concurrency rules can lead to challenges when making SwiftUI views conform to Equatable. Specifically, the == operator required for Equatable must be nonisolated, which means it cannot access @MainActor-isolated properties. This creates an error when trying to compare views with such properties:
Error Example:
struct MyView: View, Equatable {
let title: String
let count: Int
static func ==(lhs: MyView, rhs: MyView) -> Bool {
// Accessing `title` here would trigger an error due to actor isolation.
return lhs.count == rhs.count
}
var body: some View {
Text(title)
}
}
Error Message:
Main actor-isolated operator function '==' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode.
Any suggestions?
Thanks
FB: FB15753655 (SwiftUI View cannot conform custom Equatable protocol in Swift 6.)
Hi,
I'm trying to create a UICollectionView where the cell high is automatic. Cells contains a UILabel with all anchors to the contentView of the cell.
It seems to work but I have a strange behavior with longer text, on reload data and on device rotation: Cells do not display the whole text or they change row, both randomly.
To create my collection view I first create the collection view with a custom flow layout setting the automatic size on viewWillAppear:
let collectionViewFlowLayout = CustomFlowLayout()
collectionViewFlowLayout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
collectionView = UICollectionView(frame: .zero, collectionViewLayout: collectionViewFlowLayout)
and I have also overridden:
override func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
collectionView.setNeedsLayout()
self.collectionView.layoutIfNeeded()
self.collectionView.collectionViewLayout.invalidateLayout()
//self.collectionView.reloadData()
}
Then, I created the custom layout as follow:
import UIKit
final class CustomFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributesObjects = super.layoutAttributesForElements(in: rect)?.map{ $0.copy() } as? [UICollectionViewLayoutAttributes]
layoutAttributesObjects?.forEach({ layoutAttributes in
if layoutAttributes.representedElementCategory == .cell {
if let newFrame = layoutAttributesForItem(at: layoutAttributes.indexPath)?.frame {
layoutAttributes.frame = newFrame
}
}
})
return layoutAttributesObjects
}
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
guard let collectionView = collectionView else {
fatalError()
}
guard let layoutAttributes = super.layoutAttributesForItem(at: indexPath)?.copy() as? UICollectionViewLayoutAttributes else {
return nil
}
layoutAttributes.frame.origin.x = sectionInset.left
if(indexPath.section == 0){
layoutAttributes.frame.size.width = collectionView.safeAreaLayoutGuide.layoutFrame.width - sectionInset.left - sectionInset.right
} else if (indexPath.section == collectionView.numberOfSections - 1){
let width = ScreenUtility.getCollectionCellWidthForElement(in: collectionView, sectionLeft: sectionInset.left, sectionRight: sectionInset.right, minimumInteritemSpacing: minimumInteritemSpacing, multiplier: 3)
layoutAttributes.frame.origin.x = ScreenUtility.getCollectionCellOriginForElement(in: collectionView, at: indexPath, forElementHavingWidth: width, sectionLeft: sectionInset.left, sectionRight: sectionInset.right, minimumInteritemSpacing: minimumInteritemSpacing, multiplier: 3)
layoutAttributes.frame.size.width = width
} else if (indexPath.section == collectionView.numberOfSections - 3) || (indexPath.section == collectionView.numberOfSections - 4){
let width = ScreenUtility.getCollectionCellWidthForElement(in: collectionView, sectionLeft: sectionInset.left, sectionRight: sectionInset.right, minimumInteritemSpacing: minimumInteritemSpacing)
layoutAttributes.frame.origin.x = ScreenUtility.getCollectionCellOriginForElement(in: collectionView, at: indexPath, forElementHavingWidth: width, sectionLeft: sectionInset.left, sectionRight: sectionInset.right, minimumInteritemSpacing: minimumInteritemSpacing)
layoutAttributes.frame.size.width = width
} else {
let width = ScreenUtility.getCollectionCellSizeForElementFullRow(in: collectionView, sectionLeft: sectionInset.left, sectionRight: sectionInset.right)
layoutAttributes.frame.origin.x = ScreenUtility.getCollectionCellOriginForElementFullRow(in: collectionView, sectionLeft: sectionInset.left, sectionRight: sectionInset.right)
layoutAttributes.frame.size.width = width
}
return layoutAttributes
}
}
And finally on collection view cells:
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
setNeedsLayout()
layoutIfNeeded()
let targetSize = CGSize(width: layoutAttributes.frame.width, height: 0)
layoutAttributes.frame.size = contentView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
return layoutAttributes
}
override func prepareForReuse() {
self.nameLabel.text = ""
self.idLabel.text = ""
self.contentView.setNeedsLayout()
self.contentView.layoutIfNeeded()
}
Let me show you an example on the iPad that is the worst.
First Time I open the collection view I have cells on wrong rows and not sized properly
Then I rotate the device portrait and the cells are fine
On landscape again it changes behavior:
This is just an example, things happens apparently randomly, and also sometimes cells disappear (I think the height is set to 0).
I really do not understand why, cells width seems to be computed correctly, and cell label is set via setter:
open var step: String = "" {
didSet {
nameLabel.text = step
nameLabel.sizeToFit()
self.contentView.setNeedsLayout()
self.contentView.layoutIfNeeded()
}
}