I followed a tutorial on SwiftUI and macOS (and wow was it worth it, I understand more of what I was doing wrong before!). After the tutorial was done, I thought, okay, let's try adding CloudKit to it. Which was rather trivial to do, I was impressed. Then I thought, ok, let's try being able to have local or CloudKit, depending on runtime. But when I did that, the file was opened readonly, due to "Store opened without NSPersistentHistoryTrackingKey but previously had been opened with NSPersistentHistoryTrackingKey."
This seems to be something a lot of people have run into, but for some reason I haven't found any actual fixes. Anyone know?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I put a cromulent plist file in /Library/LaunchAgents; I load it for the current user using launchctl bootstrap gui/501 $plistfile. Great!
But if I then log in as a different user, without rebooting, it doesn't run. I can't do a bootstrap for a user who isn't there; I can't do a launchctl load for an agent. This seems like I'm missing something, but googling hasn't helped me a lot.
(On top of all that, I am pretty positive this used to work, but I may be thinking back to MacOS not macOS.)
This query should find everything with a display name of "Safari." That should include, for example, /Applications/Safari.app.
[bigbook:/tmp] sef% mdfind 'kMDItemDisplayName == "Safari"c'
/Library/Application Support/Apple/Safari
/Library/Apple/System/Library/Assistant/Plugins/Safari.assistantBundle/Contents/MacOS/Safari
/Users/Shared/Previously Relocated Items 1/Security/System/Library/AssetsV2/com_apple_MobileAsset_MacSoftwareUpdate/f7b05c91052116c046919f72de2c03a86cabcf3e.asset/AssetData/payloadv2/ecc_data/System/Library/Templates/Data/Applications/Safari.app
/Users/Shared/Previously Relocated Items/Security/Developer/SDKs/MacOSX10.6.sdk/System/Library/PrivateFrameworks/Safari.framework/Versions/A/Safari
/Users/Shared/Previously Relocated Items/Security/Developer/SDKs/MacOSX10.7.sdk/System/Library/PrivateFrameworks/Safari.framework/Versions/A/Safari
/Users/sef/Applications/Microsoft Office 2004/Office/Themes/safari
/Users/sef/Library/Application Support/SyncService/LastSync Data/Safari
And yet, /Applications/Safari.app is in fact missing from there.
Why? (This used to work. But then mds was broken on my machine, so I bit the bullet and upgraded to Monterey. Multiple Monterey systems are showing this weird behaviour.)
I was surprised I could not find such a template in Instruments / xctrace; maybe it's in something else and I couldn't find it?
(I am trying to figure out why my throughput got slow. Is it because a mutex is too heavy? Or is there a lot of contention over the lock? How long do the locks tend to be held? Etc.)
Specifically, it doesn't find anything. (Now, this isn't a huge deal, I was just playing with some queries related to another issue I had, and found that I couldn't search that way.)
Is this expected? eg, mdfind 'kMDItemFSName == "/"' finds nothing.
root# malloc_history /tmp/stack-logs.60147.10f5f7000.agent-tests.0EDkOu.index -callTree
malloc_history[60193]: [fatal] unable to read input graph: The data couldn’t be read because it isn’t in the correct format.
I ran my program as
root# env MallocDebugReport=stderr MallocGuardEdges=1 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocScribble=1 MallocErrorAbort=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib ./test/agent-test
(The program then segfaults, which looks to be due to a memory stomper.)
This was discussed a bit, but it was a while ago, and I asked recently on the thread, but let's see if I can get more information this way.
Normally if you're a process doing UDP I/O, you use a timeout of some sort (usually with recvfrom, or a read with an alarm signal or something). How is a network extension supposed to know that? Or is it supposed to assume that if a process signals done-with-writing, that it should treat both directions as closed? (This is definitely not the case with TCP, of course.)
UDP has never really been my strong point in networking programming -- too late to only have it available, and too early to find TCP problematical for my needs. 😄
I searched and couldn't find anything, which shocks me, I can't be the only person to ask this. Therefore my search skills are once again demonstrated to be weak.
Given an EKCalendar, I can get the source thence sourceIdentifier... but that's just a UUID; can I get the actual URL for that? I assume it's somewhere?
Playing with EventKit, I wanted to test requesting access. Which I did once. Yay.
Now it's stuck in System Settings... and I don't know how to reset it. (This is on Ventura.)
We have our own root CA that is installed with our application. For non-MDM installs, the system asks if the user wants to do that, which is all well and good.
It also used to ask us when removing that certificate. It doesn't now. So now I am wondering if I dreamed it, except other people say they also got prompted and don't now.
It's being installed and removed using the security command, in scripts.
I just wrote code for our app to use ASWebAuthenticationSession for 3rd-party authentication (in particular, YUBIKEYS WOOHOO). Our app registers a URI scheme of x-com-kithrup for launch services events, so I used x-com-kithrup-yubi for ASWebAUthenticationSession.
Only, I didn't change the back end, so it still redirects to x-com-kithrup://success on a successful login. And... ASWebAuthenticationSession is still calling the handler when it gets a URL with the x-com-kithrup URI, instead of the x-com-kithrup-yubi URI scheme.
I was trying to have a date picker show up conditionally; it seems to work for iOS, but macOS (13, haven't tried it on 14 yet) it ... doesn't. In particular, if I select "custom" in this code, and then click on a date part, it brings up the graphical picker, and I can select a date, but then... it doesn't go away. Clearly I am doing something wrong, but is it clear to anyone who isn't me what that is?
import SwiftUI
extension View {
/// Hide or show the view based on a boolean value.
///
/// Example for visibility:
///
/// Text("Label")
/// .isHidden(true)
///
/// Example for complete removal:
///
/// Text("Label")
/// .isHidden(true, remove: true)
///
/// - Parameters:
/// - hidden: Set to `false` to show the view. Set to `true` to hide the view.
/// - remove: Boolean value indicating whether or not to remove the view.
@ViewBuilder func isHidden(_ hidden: Bool, remove: Bool = false, disable: Bool = false) -> some View {
if hidden {
if !remove {
self.hidden()
.disabled(disable)
}
} else {
self
}
}
}
enum ExpireType: CustomStringConvertible, Hashable, CaseIterable {
case never
case oneWeek
case twoWeek
case oneMonth
case sixMonth
case custom
func expires(given date: Date) -> Date? {
let calendar = Calendar.current
switch self {
case .never:
return nil
case .custom:
return nil
case .oneWeek:
return calendar.date(byAdding: .weekOfYear, value: 1, to: Date())
case .twoWeek:
return calendar.date(byAdding: .weekOfYear, value: 2, to: Date())
case .oneMonth:
return calendar.date(byAdding:.month, value: 1, to: Date())
case .sixMonth:
return calendar.date(byAdding: .month, value: 6, to: Date())
}
}
var description: String {
switch self {
case .never: return "Never"
case .custom:
return "Custom"
case .oneWeek:
return "One week"
case .twoWeek:
return "Two weeks"
case .oneMonth:
return "One month"
case .sixMonth:
return "Six months"
}
}
}
struct ExpireDatePicker: View {
@State var expires = Date()
@State var expireType = ExpireType.never
@State var didChange = false
@State var dateString = ""
@State var showDatePicker = false
private func updateText() {
if self.expireType == .never {
self.dateString = ""
} else if self.expireType == .custom {
self.dateString = self.expires.formatted(.dateTime.day().month().year())
} else {
self.dateString = self.expireType.expires(given: Date())!.formatted(.dateTime.day().month().year())
}
}
/*
* For the expire date, we want to let
* the user pick one of the predfined dates,
* or a custom date.
*/
var body: some View {
VStack(alignment: .trailing) {
let _ = print("showDatePicker \(self.showDatePicker)")
Picker("Expiration date", selection: self.$expireType) {
ForEach(ExpireType.allCases, id: \.self) { et in
Text(String(describing: et))
.tag(et)
}
}
ZStack(alignment: .trailing) {
Text(dateString)
.fontWeight(.ultraLight)
.isHidden(self.showDatePicker, disable: true)
/*
* This does not work well.
* I can't get it to disappear,
* or relinquish control
*/
DatePicker("", selection: self.$expires, displayedComponents: .date)
.datePickerStyle(.compact)
.isHidden(!self.showDatePicker, disable: true)
}
}
.onChange(of: self.expireType) { to in
self.showDatePicker = (to == .custom)
self.updateText()
}
.onChange(of: self.expires) { to in
print("expires changed to \(self.expires)")
self.showDatePicker = false
}
}
}
Our project uses CMake, which generates a .xcodeproj bundle. Our project has an existing network extension (Transparent Proxy Provider); I'm trying to add a second one, which is a packet filter. Xcode is extremely unhappy:
error: Multiple commands produce '/Build/mybuild/Entitlements.plist'
note: Target 'PacketFilter' (project 'project') has write command with output /Build/mybuild/Entitlements.plist
note: Target 'ProxyProvier' (project 'project') has write command with output /Build/mybuild/Entitlements.plist
My problem is: I can't tell what is generating the Entitlements.plist file! If I build each of those two targets separately, it does get generated. But if I search for "Entitlements" in the bundle, there is nothing. So I am unable to tell what is going on.
Each of the extension targets has their own entitlements file -- each of them has their own CMakeLists.txt file, and has this setting:
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.entitlements"
but something -- and I assume it's CMake, although I can't find anything that does that -- is producing a rule somewhere that says it creates Entitlements.plist. And it's doing it outside of the project.xcodeproj bundle?
How can I track this down and/or fix it?
We have a Transparent Proxy Provider, and a Packet Filter. They both get activated on app startup, and then when that's done, I call code to set the preferences to enable them.
That is basically done by having the request:didFinishWithResult: method check the identity of the request, determine whether it was activation or deactivation, and then call the appropriate function to do the preferences load/save dance.
However, from the logs, it looks like the preferences-handling code sometimes only gets called for one of them (and, strangely, almost always the packet filter).
Is this a known issue? I'd guess something about multiple calls to load/save preferences happening at the same time?
Now that I can build again, I'm back to experimenting, this time using Firebase. To display my items, I set up a Table, and this mostly works, barring a couple of minor, crashy details.
I've got
@State var selectedItems = Set<Item.ID>()
private var tableData: [Item] {
return self.items.sorted(using: self.sortOrder)
}
var body: some View {
Table(self.tableData, selection: self.$selectedItems, sortOrder: self.$sortOrder) {
TableColumn("Item", value: \.name)
TableColumn("Count", value: \.count) { item in
Text("\(item.count)")
}
}
Edited down a bit but that's the basics.
The two problems I've got are:
When I select a row, it flashes but does not stay highlighted
If I select the same row again, it crashes with:
Fatal error: Duplicate elements of type 'Optional<String>' were found in a Set.
This usually means either that the type violates Hashable's requirements, or
that members of such a set were mutated after insertion.
I put in a willSet for the selectedItems which was not particularly helpful.
This doesn't happen with the CoreData version, so I assume it's something wonky about Firebase. Or my limited skills.
Searching for this crash doesn't seem to show anything useful.