Failed to launch home screen widget in iOS 14 Simulator - widget

Error Details:
SendProcessControlEvent:toPid: encountered an error: Error
Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show
Widget 'com.anupam.iOS14Feature.widgetExtension' error: Error
Domain=SBAvocadoDebuggingControllerErrorDomain Code=2 "Please specify
the widget kind in the scheme's Environment Variables using the key
'_XCWidgetKind' to be one of: 'BillPayCheckerWidget',
'CommitCheckerWidget'" UserInfo={NSLocalizedDescription=Please specify
the widget kind in the scheme's Environment Variables using the key
'_XCWidgetKind' to be one of: 'BillPayCheckerWidget',
'CommitCheckerWidget'}." UserInfo={NSLocalizedDescription=Failed to
show Widget 'com.anupam.iOS14Feature.widgetExtension' error: Error
Domain=SBAvocadoDebuggingControllerErrorDomain Code=2 "Please specify
the widget kind in the scheme's Environment Variables using the key
'_XCWidgetKind' to be one of: 'BillPayCheckerWidget',
'CommitCheckerWidget'" UserInfo={NSLocalizedDescription=Please specify
the widget kind in the scheme's Environment Variables using the key
'_XCWidgetKind' to be one of: 'BillPayCheckerWidget',
'CommitCheckerWidget'}., NSUnderlyingError=0x7fc70d618350 {Error
Domain=SBAvocadoDebuggingControllerErrorDomain Code=2 "Please specify
the widget kind in the scheme's Environment Variables using the key
'_XCWidgetKind' to be one of: 'BillPayCheckerWidget',
'CommitCheckerWidget'" UserInfo={NSLocalizedDescription=Please specify
the widget kind in the scheme's Environment Variables using the key
'_XCWidgetKind' to be one of: 'BillPayCheckerWidget',
'CommitCheckerWidget'}}} Domain: DTXMessage Code: 1
--
System Information
macOS Version 10.15.6 (Build 19G73) Xcode 12.0 (17200.1)

likely because you changed the kind string inside of your :widget struct. Go to edit your scheme, and in arguments, change the name of _XCWidgetKind to one of your new kind names. Literally just loaded this fix into my simulator as i typed this lol.

If you have multiple widgets, in my case I have two widget.
Static Configuration widget
Intent Configuration widget
And, when you run your widget extension target, you need to specify which widget you want to run.
Product -> Scheme -> Edit scheme
Enable _XCWidgetKind and provide the wiget struct name [in my case "Selectable_OTP_Extn"]
Enable XCWidgetDefaultView & _XCWidgetFamily

I tried other answers but for multiple Widgets (i.e. WidgetBundle) only this answer helped me: https://stackoverflow.com/a/64000716/2095408 (comment other Widgets and leave just 1 Widget uncommented).

If you have many different widgets in your app, you need to tell Xcode which one you are going to debug, you can't debug all of them at the same time, that's what _XCWidgetKind is for, so add the Class name of your widget works.

Related

Use logger name if MDC key missing

I am using logback with a third party package which sets an identifier in the MDC when its code is running. The rest of the time, this identifier is not set. So if I use a PatternLayout of [%X{id}] %m%n, then I see messages like
[Foo] Foo running
[Bar] Bar running
for messages related to the package. However, the rest of my log statements look like
[] Thing happened
The %X{id} is useful information when it exists, but I would like the logger name to be used when it is not. I tried
[%X{id:-%logger{20}}]
and
[%X{id:-logger{20}}]
but neither used the logger name as a default value.
I could write a custom layout that sets id to the logger name if it is not set, forwards to the layout and then clears field. Is there a simpler way to do this?

How can I avoid duplicated symbol errors when I use static libraries with Cocoapods?

I've got a executable target called Foobar, a static library holding some common code called FoobarCommon, and a test target specifically for the common code called FoobarCommonSpecs.
Unsurprisingly, I have made both Foobar and FoobarCommonSpecs depend on the FoobarCommon library.
The Podfile looks something like the below:
target 'FoobarCommon' do
pod 'ReactiveCocoa'
...
end
target 'Foobar' do # links against to FoobarCommon in Xcode
...
end
target 'FoobarCommonSpecs' do # links against to FoobarCommon in Xcode
pod 'LLReactiveMatchers', :git => 'https://github.com/lawrencelomax/LLReactiveMatchers.git'
end
LLReactiveMatchers is a Pod that depends on ReactiveCocoa.
Note that in this situation, ReactiveCocoa is prsent in both FoobarCommon and also in FoobarCommonSpecs
The Problem
Whenever I run FoobarCommonSpecs, I get many duplicate symbol errors for ReactiveCocoa.
I want to say to Cocoapods that it should just IGNORE LLReactiveMatcher's dependency on ReactiveCocoa. It should just let Xcode do its job and it should link with the copy of ReactiveCocoa found in FoobarCommon. How do I do that?
Does the link_with directive have anything to do with anything?

PhpStorm to support registry pattern

In my code I use Registry pattern like that:
$data = Registry::get('classA')->methodOfClassA($param1, param2);
Registry class stores instances of some classes in internal array, so in any place of my code I can call class methods for handy functions like in line above.
But, the problem is that PHP-storm does not autocomplete when I type:
Registry::get('classA')->
And, that is worse, it does not go to declaration of the method "methodOfClassA" when I hover mouse cursor holding mac-button (analogue of control-button on windows)
I suppose, that IDE AI is not so good to recognise cases like that, but maybe there is some tricks to do that in a hard way? hardcoding classes+method names in some file and so on...
At least, I want it to understand to go to method declaration when I click method name...
Any advices?
http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
This link describes it all -- it is already used by multiple projects/frameworks/code-generation helpers, like Magento, for example (some other can be found mentioned in the comments of the actual ticket).
For other situations you may want to check out DynamicReturnTypePlugin plugin (Settings | Plugins | Browse repositories...) -- have not tried myself and therefore cannot comment how good/fast/laggy it is.
You can always indicate the variable type in two steps:
/** #var $foo MyClass */
$foo = $this->get('MyClass');
$foo->bar(); // autocomplete works

How can I assign sequences to constants in the CONSTANTS section of a TLA+ configuration file?

I've tried
CONSTANTS seq = <<5,6,7>>
but TLC gives me a syntax error:
Error: TLC found an error in the
configuration file at line 1. It was
expecting = or <- and didn't find it.
I've also tried to include the Sequences module in the configuration file, to no avail.
So... what do I have to do to assign a sequence?
I don't remember ever facing this problem and my TLC is too rusty to try and give you a first hand answer (I just restarted using the TLA+ toolbox).
From the post linked bellow, however, I figure that you can't instantiate constants with sequences through the TLC config files.
http://bbpress.tlaplus.net/topic/creating-a-sequence-from-a-set
Even though the question is old, leaving an answer may help future TLAers.
You can't directly assign to a constant in the TLA+ file. If you're using the toolbox, write CONSTANTS seq, then in the model add the tuple you want as an ordinary assignment.
So it turns out that you need a separate .tla file for that. Suppose you have "Main.tla" as you source file. You want MyConst to have value <<1,2,3>>. TLA+ toolbox generates MC.tla where it puts the constants:
---- MODULE MC ----
EXTENDS Main, TLC
const_uniq12345 = <<1,2,3>>
====
in MC.cfg, there will be the line
CONSTANT MyConst <- const_uniq12345
Note that MyConst = const_uniq12345 won't work -- if you use = instead of <-, MyConst will contain model value const_uniq12345 instead of <<1, 2, 3>>
I used https://github.com/hwayne/tlacli to be able to run TLC from command line (TLA toolbox has awful UX), and I was able to supply a tuple constant with help of extra .tla file like this. I used meaningful name instead of const_uniq12345 too, of course. Had to call java -cp /path/to/tla2tools.jar ... manually, though (got the full command using --show-script option of tlacli), because currently tlacli doesn't handle <- in the config.

How to resolve naming conflicts when multiply instantiating a program in VxWorks

I need to run multiple instances of a C program in VxWorks (VxWorks has a global namespace). The problem is that the C program defines global variables (which are intended for use by a specific instance of that program) which conflict in the global namespace. I would like to make minimal changes to the program in order to make this work. All ideas welcomed!
Regards
By the way ... This isn't a good time to mention that global variables are not best practice!
The easiest thing to do would be to use task Variables (see taskVarLib documentation).
When using task variables, the variable is specific to the task now in context. On a context switch, the current variable is stored and the variable for the new task is loaded.
The caveat is that a task variable can only be a 32-bit number.
Each global variable must also be added independently (via its own call to taskVarAdd?) and it also adds time to the context switch.
Also, you would NOT be able to share the global variable with other tasks.
You can't use task variables with ISRs.
Another Possibility:
If you are using Vxworks 6.x, you can make a Real Time Process application.
This follows a process model (similar to Unix/Windows) where each instance of your program has it's own global memory space, independent of any other instance.
I had to solve this when integrating two third-party libraries from the same vendor. Both libraries used some of the same symbol names, but they were not compatible with each other. Because these were coming from a vendor, we couldn't afford to search & replace. And task variables were not applicable either since (a) the two libs might be called from the same task and (b) some of the dupe symbols were functions.
Assume we have app1 and app2, linked, respectively, to lib1 and lib2. Both libs define the same symbols so must be hidden from each other.
Fortunately (if you're using GNU tools) objcopy allows you to change the type of a variable after linking.
Here's a sketch of the solution, you'll have to modify it for your needs.
First, perform a partial link for app1 to bind it to lib1. Here, I'm assuming that you've already partially linked *.o in app1 into app1_tmp1.o.
$(LD_PARTIAL) $(LDFLAGS) -Wl,-i -o app1_tmp2.o app1_tmp1.o $(APP1_LIBS)
Then, hide all of the symbols from lib1 in the tmp2 object you just created to generate the "real" object for app1.
objcopymips `nmmips $(APP1_LIBS) | grep ' [DRT] ' | sed -e's/^[0-9A-Fa-f]* [DRT] /-L /'` app1_tmp2.o app1.o
Repeat this for app2. Now you have app1.o and app2.o ready to link into your final application without any conflicts.
The drawback of this solution is that you don't have access to any of these symbols from the host shell. To get around this, you can temporarily turn off the symbol hiding for one or the other of the libraries for debugging.
Another possible solution would be to put your application's global variables in a static structure. For example:
From:
int global1;
int global2;
int someApp()
{
global2 = global1 + 3;
...
}
TO:
typedef struct appGlobStruct {
int global1;
int global2;
} appGlob;
int someApp()
{
appGlob.global2 = appGlob.global1 + 3;
}
This simply turns into a search & replace in your application code. No change to the structure of the code.