I am experiencing a problem under Catalina while using Python 3.7.4 and 3.8.0.I am trying to click on the menu but it is not responding to mouse clicks until I switch to another window and then come back to the python app.You can see this by running the following code:import tkinter as tk
root = tk.Tk()
root.mainloop()I know this is minimal as a program, but it displays exactly what the issue is. Even with this minimal program you should still be able to click the 'python' menu next to the Apple icon on the menu and quit, but you cannot until you CMD+Tab/click out of the python window and then CMD+Tab/click back into the python window.Is there something wrong between Catalina and Python? Any idea what I can do to fix this behavior?My environment is macOS Catalina 10.15, Python 3.7.4 via pyEnv, and Visual Studio Code 1.39.2.
Post
Replies
Boosts
Views
Activity
I have never written anything using XCode. I have written in other languages such as Basic, Pascal, Assembler, Java, PHP and Python.I just never got around to learning C or C++, which is what XCode looks like to me, but it also resembles Python in my opinion. I have written a program in Python and I would like to convert it to a native macOS application and possibly even offer it through the App Store for macOS one day.I know XCode and Swift just went through a major revision with the release of macOS Catalina and the updates and information is still propogating for the learning sites and ebooks.I have attempted to follow the Apple Developer Tutorial for the Landmarks application because it shows that it will teach the learner how to deploy the application to all Apple platforms, but that tutorial has some inconsistencies that a newbie to XCode like myself has difficulty overcoming once I started section 2 (I've submitted Feedback to Apple for this issue).I have no real interest in developing for the iOS platform, or any other platform for that matter, at this time. So, I am looking for a macOS specific developer course or book I can use for learning XCode 11.*/SwiftUI 5.* environments.I checked out the free 24 page download for Hacking macOS by Paul Hudson from the Hacking With Swift site, but the in the 24 page sample it starts off having you create a macOS application and choosing "Cocoa Application", which is not an option in XCode 11.1. Is it the same and Apple just changed the name to just "App"? I'm skeptical to buy something when right off the bat there is an inconsistency with what the reader is encountering between the book and real world. Anyone have experience learning from that author? Back in my day the O'Reilly books were some of my goto sources for learning different languages. I looked there and it seems they're focused on iOS app development and nothing appears to be targeted for recent macOS development.I've searched through the forums for this question and didn't find anything that was as specific as this question.Thank you!Tom
I have written a macOS app that uses the iTunesLibrary framework. The app utilizes the media item's persistentID as provided by the iTunesLibrary framework to manage the settings for the track within my app.
I develop this app on an iMac (late 2015) using Xcode 12.4. I then distribute the app to my MacBook Air (2020 M1). I use Rsync to synchronize any music files from the Music Library that have been modified (lyrics/cover art, etc.), including the Music/Music/Music Library.musiclibrary database.
The need for the persistentID of the media item to remain consistent from one machine to the other is paramount for the app to work. Otherwise, the app is broken. This is why I am Rsyncing the library database.
I did not have an issue with this on macOS Big Sur 11.1 and earlier. The persistentID was being preserved on both machines and the software worked perfectly.
However, for some reason now the persistentID is not being persistent across machines. It is like the Music database on the Macbook Air is being touched/modified somehow and the persistentID of the media item is being changed before I even launch the Music app.
Upon Rsyncing the Music/Music/Music Library.musiclibrary database to the Macbook Air, then launching my app the persistentID does not exist. I then open Apple's Music app and the track is most definitely there, but the persistentID is now different.
Is Apple doing something with the Music app database in these latest releases? I have tried deleting everything from the Music/Music folder and Rsyncing the entire Music/Music folder from my iMac to the Macbook Air (a 2+ hour task), and the problem remains.
I have turned on visibility of hidden folders and I cannot see anything else that could be causing this issue in the Music folder. Should I be looking somewhere else?
I followed this - https://developer.apple.com/documentation/avfoundation/media_playback_and_selection/creating_a_basic_video_player_macos document to try and create a streaming video player in a macOS app and I am getting nothing but errors.
Here's my code:
import Cocoa
import AVFoundation
import AVKit
class ViewController: NSViewController {
@IBOutlet var playerView: AVPlayerView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
guard let url = URL(string: "https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8") else {
return
}
// Create a new AVPlayer and associate it with the player view
let player = AVPlayer(url: url)
playerView.player = player
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
When I run the code, I get the following errors in the console:
2021-03-27 09:24:44.920720-0500 Streamer[27640:1013041] [plugin] AddInstanceForFactory: No factory registered for id CFUUID 0x600002e22b60 F8BB1C28-BAE8-11D6-9C31-00039315CD46
2021-03-27 09:24:45.042030-0500 Streamer[27640:1013040] validateSessionInfo: bundleID is invalid. Please specify the bundleID for kRTCReportingSessionInfoClientBundleID
2021-03-27 09:24:45.042972-0500 Streamer[27640:1013054] startConfigurationWithCompletionHandler: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.rtcreportingd}
2021-03-27 09:24:45.043046-0500 Streamer[27640:1013054] startConfigurationWithCompletionHandler: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.rtcreportingd}
2021-03-27 09:24:45.071473-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.072119-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.072665-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.073682-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.074877-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.155189-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.155577-0500 Streamer[27640:1013055] [logging] volume does not support data protection, stripping SQLITE_OPENFILEPROTECTION* flags
2021-03-27 09:24:45.168271-0500 Streamer[27640:1013081] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service
2021-03-27 09:24:45.169487-0500 Streamer[27640:1013081] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:7 Err:-1 Errno:1 Operation not permitted
2021-03-27 09:24:45.169606-0500 Streamer[27640:1013081] [connection] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
2021-03-27 09:24:45.170098-0500 Streamer[27640:1013081] Connection 1: received failure notification
2021-03-27 09:24:45.171183-0500 Streamer[27640:1013081] Connection 1: failed to connect 10:-72000, reason -1
2021-03-27 09:24:45.171229-0500 Streamer[27640:1013081] Connection 1: encountered error(10:-72000)
2021-03-27 09:24:45.172760-0500 Streamer[27640:1013055] Task 9413249A-2C3E-4A40-B71B-394F5E95D197.1 HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000])
2021-03-27 09:24:45.174833-0500 Streamer[27640:1013084] Task 9413249A-2C3E-4A40-B71B-394F5E95D197.1 finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x6000020cb030 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask 9413249A-2C3E-4A40-B71B-394F5E95D197.1, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask 9413249A-2C3E-4A40-B71B-394F5E95D197.1"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8, NSErrorFailingURLKey=https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8, _kCFStreamErrorDomainKey=10}
2021-03-27 09:24:45.175255-0500 Streamer[27640:1013055] validateSessionInfo: bundleID is invalid. Please specify the bundleID for kRTCReportingSessionInfoClientBundleID
2021-03-27 09:24:45.176213-0500 Streamer[27640:1013040] sendOneMessageWithSessionInfo: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.rtcreportingd}
2021-03-27 09:24:45.176282-0500 Streamer[27640:1013081] sendMessageWithDictionary: Failed to get remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 0 named com.apple.rtcreportingd" UserInfo={NSDebugDescription=connection to service on pid 0 named com.apple.rtcreportingd}
2021-03-27 09:24:45.207079-0500 Streamer[27640:1012591] Metal API Validation Enabled
2021-03-27 09:24:45.233220-0500 Streamer[27640:1013081] fopen failed for data file: errno = 2 (No such file or directory)
2021-03-27 09:24:45.233272-0500 Streamer[27640:1013081] Errors found! Invalidating cache...
2021-03-27 09:24:45.288729-0500 Streamer[27640:1013081] fopen failed for data file: errno = 2 (No such file or directory)
2021-03-27 09:24:45.288805-0500 Streamer[27640:1013081] Errors found! Invalidating cache...
Is there a way to get the same results as:
%uname -m
arm64
or
%uname -m
x86_64
natively in swift without having to call a system process?
I'm trying to document my code using the Markdown, but it doesn't matter what I do, I am not seeing what I've typed show up when I ctrl-click a function and left click Show Quick Help.
Quick Help shows the parameters of the function, but it does not show the function description I typed or the description for the parameters that I typed.
Is there something I am doing wrong or I've not set within Xcode?
I went through the preferences and didn't see anything that appeared to affect displaying of Markdown.
I'm testing my user interface in light and dark mode settings and I have the "NSRequiresAquaSystemAppearance" set in my info.plist file and I was wondering if there is a way to override that setting at runtime, rather than having to constantly go to my info.plist and setting it manually between runs?
I'm searching for something like
NSApp.effectiveAppearance.setValue(true, forKey: "NSRequiresAquaSystemAppearance")
I am having an issue getting NSAppearance to work as described here in the documentation.
I am using Xcode 12.5.1 in macOS Big Sur 11.5.1. In my system preferences I have my computer set to Dark Aqua all the time. However, reading the linked document I should be able to force all my windows programmatically to use Aqua, but that is not the result I am getting with this.
import AppKit
class ViewController: NSViewController {
var progressBar: NSProgressIndicator?
weak var timer: Timer?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Force the appearance for testing
self.view.appearance = NSAppearance(named: .aqua)
let progressFrame = NSRect(x: self.view.frame.midX - view.frame.width / 2 + 30, y: self.view.frame.midY - 10, width: self.view.frame.width - 60, height: 20)
progressBar = NSProgressIndicator(frame: progressFrame)
self.view.addSubview(progressBar!)
progressBar?.isHidden = false
progressBar?.isIndeterminate = false
progressBar?.doubleValue = 0
progressBar?.maxValue = 1.0
startTimer()
}
func startTimer() {
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: true)
}
@objc func updateProgress() {
if progressBar!.doubleValue < 1.0 {
progressBar?.doubleValue += 0.02
} else {
timer?.invalidate()
progressBar?.doubleValue = 0
progressBar?.isHidden = true
}
}
}
Am I missing something?
I came across this question on S.O. while searching for how to open a new NSWindow / NSView on a connected display.
I converted the obj-c code to Swift as well as I could, but I cannot get it to work. I have the method set up inside an IBAction and I linked the action to a button I placed in the ViewController's View titled "Show External Display."
What am I doing wrong? Is there a good resource that can help me for working with connected displays using Cocoa/AppKit? I've read the docs, but still can't seem to get this working.
import Cocoa
class ViewController: NSViewController {
var externalDisplay: NSScreen?
var fullScreenWindow: NSWindow?
var fullScreenView: NSView?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
@IBAction func showExternalDisplayButtonClicked(sender: Any?) {
// Open a window on the external display if present
if NSScreen.screens.count > 1 {
externalDisplay = NSScreen.screens.last
let externalDisplayRect = externalDisplay!.frame
fullScreenWindow = NSWindow(contentRect: externalDisplayRect, styleMask: .borderless, backing: .buffered, defer: true, screen: externalDisplay)
fullScreenWindow!.level = .normal
fullScreenWindow!.isOpaque = false
fullScreenWindow!.hidesOnDeactivate = false
fullScreenWindow!.backgroundColor = .red
let viewRect = NSRect(x: 0, y: 0, width: externalDisplay!.frame.width, height: externalDisplay!.frame.height)
fullScreenView = NSView(frame: viewRect)
fullScreenWindow!.contentView = fullScreenView
fullScreenWindow!.makeKeyAndOrderFront(self)
}
}
}
Since upgrading to macOS 12.0.1 from 11.6 I am now getting this strange error in my debug console while running in Xcode 13.1:
2021-12-09 08:25:22.251548-0600 Test Player[66635:564515] [aqme] MEMixerChannel.cpp:1639 client <AudioQueueObject@0x7fd258943000; [0]; play> got error 2003332927 while sending format information
Through reading other posts and finding a site that shows information about various Apple API Errors, that site does not explain where to look or how to track down this error.
It appears the error is coming from CoreMediaIO specifically in CMIOHardware.h.
How do I get to the root of this error and fix it? It appears to not affect the compiling and running of the app, but I do not like to see these kinds of errors popping up.
The documentation here seems to be incomplete. There is no explanation of the appropriateFor property that is being passed in the example.
I do not understand the relevance of a desktop URL being passed in this example to create a temporary directory.
Example code I have found seem to always pass 'nil' to this property.
I ran into a problem with Catalina (and later) and the new Muisc.app while using the ITLibrary framework.
The ITLibrary.mediaFolderLocation and ITLibrary.musicFolderLocation methods no longer return the correct values. In fact, the fields in UserDefaults have not been updated on my system since moving from iTunes to Music because the library pointed to by “iTunes-media-folder-url“ points to an old iTunes library within the com.apple.AMPLibraryAgent suiteName.
After doing some digging and performing a dump of all UserDefaults and comparing them before and after manually switching my Music Library by option+Clicking the Music.app icon, there are no changes between the two dumps with respect to the Music.app. This leads me to believe the Music.app is not storing it's information in UserDefaults like iTunes used to.
Has anyone else run into this problem? Is there somewhere else one can look into the system to find what the last selected Music library was? I'm looking for a reliable workaround to know the location of the currently selected Music library.
I posted this question on SO as well.
I have code that opens a window and displays a view on a connected display. My goal is to detect a connection/disconnection of a connected display and show/remove the view accordingly. I have that part working fine.
The problem I am having is closing the window upon disconnection/interruption, but then if a subsequent connection is made, and upon creating the window and view again, I get a EXC_BAD_ACCESS error.
I tried a different approach by setting the connectedDisplayWindow and connectedDisplayView to nil, after calling close() on the window when a connected display is removed. Maybe I am misunderstanding the close() method?
Apple Documentation
If the window is set to be released when closed, a release message is sent to the object after the current event is completed. For an NSWindow object, the default is to be released on closing, while for an NSPanel object, the default is not to be released. You can use the isReleasedWhenClosed property to change the default behavior...
Just to make sure, I tried setting the isReleasedWhenClosed to true, but it did not change the problem.
The other thing I see in the console is about seven repeated error strings immediately upon disconnection of the connected display: 2022-04-10 10:28:11.044155-0500 External Display[95744:4934855] [default] invalid display identifier 67EE0C44-4E3D-3AF2-3447-A867F9FC477D before the notification is fired, and one more after the notification occurs: 2022-04-10 10:28:11.067555-0500 External Display[95744:4934855] [default] Invalid display 0x4e801884. Could these be related to the issues I am having?
See example code in attachments.
ViewController.swift
ConnectedDisplayView.swift
I commented out the nil settings for the connectedDisplayWindow and connectedDisplayView objects and the error at @main in AppDelegate went away, but then I get an error when trying to reinitialize the connectedDisplayWindow if the connected display is removed or the connection is momentarily interrupted.
Not really sure if this post belongs here, but it pertains to the iTunesLibrary Framework.
While looking through the iTunesLibrary framework, I came across the subject constant. However, I do not know how to set this within the Music app.
Is this a legacy feature of iTunes before Apple switched to Music with Catalina?
I looked through the preferences for Music and I do not see where to turn this feature on, nor is it available as a display column in Music while viewing songs as a list.
I have been managing my music by appending (Clean) for a non-explicit version of a song with explicit lyrics, or (Explicit) if a non-explicit version is not available.
It would be nice to not have to do this if this feature can be turned on in the Music app.
Before I spend money on Roku devices that support Airplay, I wanted to first ask:
Can Airplay simultaneously cast to multiple Airplay devices during a Keynote presentation? If not, is there a programatic solution like writing a system service to allow a multicast type thing to send the extended display out to multiple Airplay display devices?
I use my MacBook Air Silicon to do Keynote presentations in presenter mode through an extended display. My main display on the laptop can have multiple windows open that I use for reference and the Keynote presentation is on the extended display. Some of the facilities I go into are not properly wired with a splitter to send my presentations out to multiple displays for easy view by my attendees.