Custom intent is being confirmed over and over again, and never handled - ios

I've inherited a codebase that implements a half-baked implementation of custom intents and shortcuts. One issue that I can't figure out is the one described by the title.
On paper, everything seems to work. When the confirm() method's completion handler is called, the response code passed is '.ready'; the UI extension boots up correctly, everything. In the UI extension, cancellation works great. However, when "confirm" is pressed in the UI extension, it just runs through the same confirmation flow again.
So why is the handle() method in my intent handler not being called? Is there something I'm missing? Anyone see any holes in what I'm describing? Unfortunately I can't put large swathes of code into this post, but if anyone would like to see anything specific just let me know and I'll start adding small snippets.

Ran it on a real device and it worked. Not an ideal solution (especially if you're doing watch stuff, with those ridiculous build times) but it works.
SoupChef had the same issue for me & a coworker of mine, so we went ahead and filed a bug report with Apple as well.

Related

Reverse engineering. How to see the code executed before the breakpoint

Once in a game I was playing, a smart person wrote a cheat that allows you to disconnect all players from the server. I became interested in how it is possible to create protection against this. The situation was aggravated by the fact that the person who created the cheat distributed it to other players and disconnecting from the server became a regular event.
I got the source code of this cheat, I will show a fragment with a "connection switch":
I figured out how the cheat works. In the LLDB debugger, I found the Disconnect() function, it is called just when the "cheater" uses the cheat. In the disassembler, I decided to just remove Disconnect (), of course this is stupid, because I violated the logic of the game because of which I could not play. As a result of something, this function was called for me, I need to find out what code was executed before the breakpoint with Disconnect ()
Well its hard to tell, but my suggestion is you add some Debug.Log prints in certain scripts you think could be called before the disconnection happens, I know this sounds like a tedious work but you probably have some scripts you think could be called before. Else I would search for some keyword like "kickall" and be sure to set "all files in project" option so that it shows all possible candidates. I hope this serves you

SwiftUI / iOS 14: How to restore last active document (state?) with document-based (DocumentGroup) app

I am working with Xcode's provided SwiftUI multi-platform, document-based app template.
Everything so far has been "smooth sailing", if you will, however I have no been able to figure out something I though was "built in":
If, for some OS management reason the app gets "killed" (or if intentionally, by stopping it in Xcode), when relaunched, the app "forgets" the document the user was working on, and starts up showing the document browser instead.
I looked on the documentation, and found an article titled "Restoring your app's state with SwiftUI" - this article offers sample code for a non-document-based app, but for the life of me I cannot even begin to understand what it is I am supposed to do to adapt it to a doc-based (DocumentGroup) scenario.
I "understand" the concept of SceneStorage, I was even able to persist some random text declared as a SceneStorage property of the example ContentView, but I cannot understand how am I supposed to use this to, when relaunching the app, have the last open document, well, back open.
I sort of tried to do this at the #main code declaration, but could not make it work.
Also, Google has NOT been my friend in this case - have not been able to find a single example of this particular scenario anywhere.
I know I might pass as a "noob" (I am...) and that this is fairly new, so I should expect lack of "stuff" around, and that this should not be so hard, so please forgive my "noob-iness" in advance.
If anyone has any idea about how to achieve this, or can point me to a WORKING sample with a document-based/DocumentGroup app, I will be eternally grateful.

how to know that where exactly app getting stuck in xcode?

My app gets stuck for a specific operation and that operation is too big having so many method calls and services requests, so i cannot put breakpoints on each method and debug, is there any other way i can get to know where exactly my app is stucked in xcode?
The operation wasn't too big to write the code, so it isn't too big to add breakpoints, logging statements, assertions and so on.
The only other way that works sometimes is taking a long shower in the morning, not thinking about work at all, and suddenly the realisation what you did wrong jumps to your mind. It has worked for me sometimes, but the first method is more reliable.
If you have reason to believe that the most time is spent in one operation, just let it run with the debugger attached and then press the pause button and see where you are...
A somewhat niftier approach would be to start with Instruments (i.e. the Time Profiler). It's easy to use and should be the first weapon of your choice for performance issues.
You can set a conditional break point in Xcode to debug a specific condition, for more detail go through Jeffrey Sambells blog!

XCode: Find which event was fired without a breakpoint

I'm sorry if this post is in the wrong area, please advise me on where to move it if needs be.
I've just been passed a project from a previous developer and to be honest the repository is horrendous, the previous developer used awful naming conventions, the code is completely serial, no XCAssets, XIB's or Storyboards were used and I'm finding the whole project very hard to navigate - oh and no comments! What sort of developer leaves no comments...
So far it has taken me 4 hours to fix problems that would normally take a matter of minutes due to having to scour through 200 different source files.
I was wondering if there is a way to tell the debugger to stop each time a function is called on a click events - basically on the UI there is a button which is displaying the wrong dialog, due to awful naming conventions I am finding it near impossible to locate the place in the source for me to make changes.
Any advice would be appreciated (I have told the team I am planning to rebuild the whole app, but we are due to launch next week).
Welcome to the world of programming. You are able to add a custom forwarding delegate to the AppDelegate on the Main start up that will intercept events such as the ones you described above via
int retVal = UIApplicationMain(argc, argv, #"MyListenerHere", nil)

Adding pin on mapView is not working on appstore version

I have submitted my app and been accepted couple of weeks ago. However, I have an issue that one of my critical functionality which is adding pin is not working but it works in building version. Adding pin requires URL connection. Could you please look at the answer that I get from apple developer and guide me please?
It shouldn't be causing your problem (at least not directly), but in general
having networking code like this live inside your UI code is very problematic
for a number of reasons:
-On general architecture grounds, it's a large violation of the MVC (model
view controller) architecture. The pin annotation is obviously heavily tied
to your UI (the view), while networking is clearly part of your backend (the
model).
-Because iOS REQUIRES the main thread to remain responsive, attaching code
that does IO or computation to the main thread is inherently risky. It can be
done and work well, but doing it incorrectly will inevitably lead to crashes.
NSURLConnection works in background and interactions with UI should go on main thread.
So, if you add your pin at the connectionDidFinish method for example, you should do like this:
[mapView performSelectorOnMainThread:#selector(addAnnotation:) withObject:yourAnnotation waitUntilDone:[[NSThread currentThread] isMainThread]];
Hope that helps you. I wrote from windows but the line should work.
I'm not exactly sure about what you are trying to achieve. Are App folks complaining because you are fetching URL directly in the Main thread ? Could you just send a code snippet showing how you fetch urls ?
One option would be to drop the pin (not tied to URL connection at all) and once the pin drops, load your data for the callout or annotation (which is what I'm assuming you are doing). You can always put a loading indicator or progressHUD up to tell the user they need to wait for something. It isn't exactly ideal, but in instances where you need to wait for data, what are you going to do?
Apple really doesn't care about blocking the UI so long as the user is aware you are blocking it. Like a progress bar or progress HUD. The user can see the app is still working and doing something. Not showing anything and having the UI just freeze while it waits for the main thread/main loop to return isn't going to work. It is just bad design and Apple will likely ding you for it.

Resources