On macOS Monterey, cannot create shortcut actions with Catalyst - swift

We are trying to create shortcut actions with Catalyst.
Our app is already available on Mac, and we previously integrated the intents framework on iOS. So according to the WWDC21 "Meet Shortcuts on macOS" presentation, "it's likely that [we] have compiled out [our] Intents integration in the process of coming to Mac". So, it's no surprise that we cannot create shortcut actions for Mac in our app with Catalyst.
The WWDC presentation suggests to "make sure to audit your code to re-enable this functionality when running on macOS Monterey." We do not understand what we need to do based on this suggestion.
What we tried so far :
we managed to create shortcut actions for mac with Catalyst, in the app available at https://github.com/mralexhay/ShortcutsExample. So, the problem does come from our app.
we managed to create shortcut actions for iOS in our app
we tried to create a fresh intent extension in our app, but the shortcut actions are still available only on iOS, not on Mac.
Has anyone found a solution in a similar situation ?

When creating a shortcut action, Shortcuts get mixed up with app identifiers. You therefore need to delete all the compiled versions of your app.

I'm having a similar problem with this example "Meet Shortcuts on macOS", I haven't done anything with shortcuts before, but I have with AppleScripts. I have managed to sort out a couple of problem due to beta changes, but I end up with this method
let task = createTask(name: title, due: dueDate)
Which doesn't exist, worst still its suppose to return a Task to set to the CreateTaskIntentResponse.task property, but Task is already defined. So I can't really redefine it and besides it seems like it should be a generated type based on all the intent info I supplied.

Related

Launch my app by hotkeys and pass it arguments from Finder (macOS)

I'm only starting macOS programming. Did some tutorials, reading docs at developers.apple.com. Trying to implement a simple(?) thing, but can't seem to get the whole picture for now.
I want to be able to launch my app by pressing some hot keys combination. The app itself is just a window with a text field that has a list of selected files in Finder (if any).
Naturally, I'm not asking for a concrete implementation. But some hints and directions on the general structure, or on what concepts and classes to inspect would be very helpful.
macOS 10.13.4, Xcode 9.3.1, Swift 4
Probably the best approach is to implement a "service". See the Services Implementation Guide.
A service is a tool that appears in the Services submenu of the application menu and in contextual menus. It can be configured to be invoked by a hot key. The active application at the time the service is invoked cooperates by providing the current selection.

Assign command to the central soft button within javaMe

I have the mobile javaMe application that has been working on Nokia Phones. However, now I'm porting it to Samsung 5611, and I've faced with such a problem: no command is assigned on the central soft button, all of them are contained in the right-button menu. When the same midlet was launched on Nokia 3110c, one command was placed on central button, other ones (if >=2) were grouped into the options menu.
I tried Item.setDefaultCommand (no effect) and Display.getInstance().setThirdSoftButton(true) (such method not supported in SDK 3.4). Also I tried to change the type of one command to Ok or Screen, and change the priority, everything is without success.
Thanks in advance. Any idea will be helpful.
Sadly there's no way for the developer to decide exactly on which softbuttons the commands belong. It is the individual device that decides. Some devices has two softbuttons, and some has three.
You can fiddle a bit with priorities, but you still can't force commands to specific softbuttons.
That's high-level GUI (Form) for you.
If you want to have control of such things, you need to go with low-level GUI (Canvas / GameCanvas). Nowadays there are several APIs you can use to create Form-like low-level GUI. Check out LWUIT for example, which I imagine makes it easy for you to port your high-level code into low-level.
But even when using low-level coding, you have to be aware of different devices having different keycodes for the softbuttons.

Interacting with Siri via the command line in macOS

I use Siri on my phone and watch to create reminders on the go. When I'm in the office I don't want to disturb the quiet by using Siri, so I usually use an Alfred workflow that is integrated with the Reminders app, or use the Reminders app directly.
However, both have a rather clunky interface, and it would be much easier if I could just type at the command line:
$ siri "remind me to check stack overflow for responses to my question in 15 minutes"
macOS Sierra has introduced Siri to the desktop, but so far I have been unable to find a way to interact with Siri in any way other than literally talking out loud, and Spotlight does not match Siri with natural language comprehension.
Apple has announced the Siri SDK, but it seems primarily related to adding functionality to Siri, not for exposing the Siri API.
Does Apple expose any kind of API to Siri on macOS such that one could make Siri requests via the command line, system call, or other executable?
Note: I understand that this question could conceivably find a better home at Ask Different, Super User, or Unix & Linux. In the end, I decided that some programmatic integration with an API or SDK was the most probable solution, and thus Stack Overflow seemed the most appropriate place to post. If mods disagree, please do migrate to whichever community is best.
This isnt from the command line, but closer... and I haven't tested it, but in High Sierra there's a way to use Accessibility settings to enable you to use your keyboard to ask Siri questions.
How to enable it:
System Preferences > Accessibility > Siri.
Click in the box beside Enable Type to Siri so that a tick appears.
Now when you trigger Siri, a keyboard will appear into which you can type your query.
Snagged from here: https://www.macworld.co.uk/news/mac-software/how-use-siri-on-mac-3536158/
I was wanting the same feature today - I got it working but could be improved upon: https://youtu.be/VRLGCRrReog
TLDR is use LoopBack by Rogue Amoeba and change Siri’s input Mic to Loopback. Then Use the Say command in Terminal for example.
As mentioned by Brad Parks, you can enable 'Type to Siri' from the Accessibility menu. You can use this to interact with Siri using simulated keypresses.
I've created a simple Python script which behaves like requested in your question when invoked from the command line.
The script uses the keyboard Python module.
#!/usr/bin/python
import sys
import time
import keyboard
def trigger_siri():
keyboard.press('command+space')
time.sleep(0.3)
keyboard.release('command+space')
time.sleep(0.2) # Wait for Siri to load
if __name__=='__main__':
trigger_siri()
keyboard.write(sys.argv[1])
keyboard.send('enter')
Cliclick is a great (and free) tool for triggering mouse and keyboard events via the command line. After installing Cliclick, I enabled "Type to Siri" (System Preferences > Accessibility > Siri). I also changed Siri's keyboard shortcut to "Press Fn (Function) Space" (System Preferences > Siri). The other keyboard shortcut options require you to "Hold" a key, which can be done, but it makes things a bit trickier.
With all that done, I can invoke Siri from the terminal with something like this:
$ cliclick kd:fn kp:space ku:fn w:250 t:"turn on the living room lights" kp:return
Going a step further, if you are familiar with terminal aliases and functions, you can create a "siricli" function:
siricli(){
cliclick kd:fn kp:space ku:fn w:250 t:"$1" kp:return
}
Open a new terminal window after adding that function, and now you can invoke Siri from the command line like this:
siricli "turn on the living room lights"

Xcode 7.3 autocomplete is so frustrating

There is a new autocomplete in Xcode. Probably might be useful because it checks not only beginning of names etc. But I found that very often it doesn't find a class name or a const name at all etc. I need to type in entire name by myself. Over all I found it makes my life harder and coding more time consuming. Is there a way to switch to the old way it used to work?
Xcode 7.3.1
In Xcode > Preferences > Text Editing
uncheck Enable type-over completions
restart Xcode
It seems that clearing the checkbox "Enable type-over completions" in XCode -> Preferences -> Text Editing does the trick. At least in my case autocompletion fell back to a sort of old way, so it could autocomplete the class name that I had to type in manually before that.
This is by no means an adequate solution, BUT it has allowed me to (barely) maintain my sanity the past few days:
After every build, you need to trash your Derived Data folder. You can find this folder in Xcode > Preferences > Locations > Derived Data. Just trash the whole thing and it'll kick off a re-indexing step that should restore proper autocomplete functionality.
Unfortunately, I've found that once I build, the autocomplete behavior reverts to its broken state.
just open Xcode derived data folder and delete the folder
/Users/yourUserName/Library/Developer/Xcode/DerivedData
then restart Xcode, now autocompletion works like a charm
I have the impression that some 'parts' of autocompletion simply fail after a while. I use to restart the Mac to get it back working. But sometimes it fails quite soon again.
Maybe the answer of #Alex Bykov combined with a restart will do the trick.
Anyway: auto-completion of Xcode always was crap. AppCode used to get it much better. Unfortunately not yet with swift.
Closed Xcode, opened Xcode, let it index, it worked.
it doesn't find a class name
As a work-around, you can try to press
Command + Shift + K and Command + B
Several times,it works temporarily.
Xcode 7.3.1
I will share another posible reason, that after couple of days we found out. We have multiple schemes, and in one of them, the bridging header was importing a file that didn't exist anymore. So, it didn't break while compiling and running (the header belongs to another scheme) but it caused the autocompletion to break (couldn't find any objective-c class).
Hope it would help someone!
After having tried different methods:
Delete Derived Data
Switching Module Enabled off in Build Settings
Full Clean
Relaunch
Only this worked:
Find any commented out (/* abc */) code after #end in your files and delete.
Credit to Max_B:
https://forums.developer.apple.com/thread/7439
In my case, other projects were auto-completing correctly. If all your projects fail to correctly predict code, then it might be a different issue, and the other answers might work.
I ran into this issue while trying to make an OS X app and I was able to fix this issue by making sure that the Xcode 7.3 documentation and the OS X 10.11.4 documentation was actually downloaded. Doing this fully restored my autocomplete functionality. My full instructions are below as well as in my answer to a similar question: https://stackoverflow.com/a/39420664/3444925
I had this problem myself and after looking through all the other similar questions & answers about this, I couldn't find a solution. However, I finally found what worked for me.
Go to Xcode -> Preferences -> Components. There you will probably find a screen that looks like the following:
This shows that the documentation has not has not been downloaded and therefore, any attempts to re-index or re-build the application without downloading the documentation would prevent you from being able to use the autocompletion functionality.
Once I downloaded the Xcode 7.3 Documentation and the OSX 10.11.4 Documentation, this was enough for me to get the autocomplete functionality back (I was trying to build an OS X app, so feel free to download as much documentation as is relevant for you).
I didn't run into this until I created a couple of new class files. Other classes worked fine, but autocomplete would NOT work for anything in the new files...
FIX (for me) - I had to add those files to ALL of my targets, including the unit test targets even though I wasn't using them yet.

VSCode plugins and thoughts on alpha release

So I'm starting to guess Javascript wasn't the best choice for VSCode to be based on. It is pretty much the same as SublimeText and even slower, though the debugger and code intel is awesome and far beyond Sublime's capabilities.
The thing is I suddenly got a chrome-like inspector frame on the right side of the window, which caught my attention and got me googling about it (too bad almost nobody is talking about vscode yet so it's a pain to even find some info), and found out another person got the same weird issue. Somebody told him that F12 opens the inspector like a normal web app so you can look under the hood (which os most likely bullcrap since it makes no sense, probably just a bug).
The thing is I decided to test out keypresses, and discovered Fn+Shift+Cmd+F12 opens a new window with a weird button and a web inspector, which has no utility at all, but it's there so I got curious and messed up with it for a while. Bad idea since it crashed the entire app.
All this story has the point of warning about how Javascript is not as stable and independent as Objective C, since it's obviously working on top of V8 and Webkit and whatnot, any of which multiply its chances to crash.
Sublime has also crashed for me a couple times, but it does Atom Saving (operating system's native autosave that stores every change in the filesystem so app crashes don't affect the files).
VSCode is not native and is in a very alpa state (version 0.1.0 as today), so this is kind of a feedback for them and a warning for other users, posted here because there is a link for this stackoverflow community on their website, and is the only community-driven way of feedback they have.
I wish they open the development so others can contribute or, at least, do like SublimeText which isn't open but supports extensibility thru plugins and python console.
Now, the question:
Is there a way to make Sublime plugins work here?
The keybindings you have found are used by us internally to debug VSCode quickly in case we notice a problem. We simply forgot to remove them, kind of like how Ctrl+Alt+Delete happened :).
We will remove these keybindings with our next update, to avoid confusion, in a couple of weeks.
We have plans on supporting plugins, we have made progress on this story, but we were not happy enough with the API, and we decided to further validate and improve it before making it public, to avoid as much as possible future API breakage.
As for the actual question, it is not possible to run Sublime plugins in VSCode, for similar reasons why it is not possible to run Sublime plugins in Eclipse or in Visual Studio. There is, however the possibility of code sharing between plugins developed for different platforms, see for example Omnisharp, which is shipped with VSCode and for which there is a Sublime plugin.
You're complaining about VSCode being created using HTML, CSS and JavaScript and not something like C# or Objective C. You do realize that since day one the following Apple apps were made with a similar hybrid approach of Objective C and HTML, CSS and JavaScript. These are apps that millions of people use: iOS: iTunes app, iTunes Store app, App Store, and on desktop: iTunes, App Store.
Visual Studio Code is a preview, meaning something that just left alpha stage development and is in early, early, early beta, like just a week ago. So there are lots of things that are still missing or not totally working yet. The Visual Studio team is working at three-week sprints and intend to update the product at that pace, so if you've downloaded it, don't expect it to have every possible feature yet. This is a preview. Explore it. If it doesn't fit your current workflow, don't use it. Stick with what you have. But keep an eye on it because it will evolve steadily over the coming months.
I tried F12 in VSCode on windows and it opened the Dev Tools window, which makes sense since it's built on GIT's open source editor Atom & Chrome.
Sublime plugins? No, you can't use ST3 plugins in Atom, but hopefully we'll be able to use Atom plugins in VSCode once plugins are included in VSCode.
At the moment VSCode don't have any functionality for plugins, but it's coming soon see forum
There is also menu item under help in VSCode for reporting issues and suggesting features.
Me too would like Plugins for VS Code. As I would like a WakaTime plugin as I'm spending so much time working in it :). Both on Mac as in Windows.
I also discovered F12 one day but just thought: 'wow pretty cool!' and nothing more. But hey, I'm a webdev.. :)
It's now october and it's still there. And I hope it will stay. Just like crrl+alt+delete. #Sebastian I agree with #JimmyBoh, the whole preamble of this question is probably better suited to be put on a forum. Otherwise this question will probably be closed as 'not constructive'. To prevent other non-answers like this one :).