Create Custom Symbols with Multicolour Support for XCode

While developing an iOS / MacOS app in Swift recently, we had the requirement for a few symbols beyond what is available in SF Symbols. After trying unsuccessfully to create our own, we came across a fantastic Mac app Create Custom Symbols. This app very easily takes an svg created in your favourite drawing tool (shout out to Affinity Designer 2) and creates a custom symbol file compatible with Xcode. I noticed that the web page for Create Custom Symbols notes that it has no support for multicolor symbols, but it turns out that it isn’t necessary for multicolor support [Read on…]

Updating a WatchOS Complication from an API Call

Our free App, Can I Skate, has had a complication for a couple of years now. In fact I wrote the app partly to see how to develop complications and widgets. Keeping the complication updated with fresh status information from the web API has always been complicated and painful and flaky. Every time someone would complain that the watch complication wasn’t showing the right state I’d groan and mutter something about caching and tell them to just wait a bit, hoping they’d get bored and forget about it so I could also. A recent update made me look at the [Read on…]

GO incorrect package name in workspace module

I got this error that I found to be somewhat mysterious when I tried to run go test in a module that was part of a go multi-module workspace. Turned out to be a simple copy and paste error. I had copied an entire directory to make a new module and had forgotten to change the package name in the .mod file. Here’s the directory structure: I’m really loving the workspace feature btw, if you’re doing anything serverless then it’s a much simpler build structure. I’ll try to do a post on using a workspace for a serverless project in [Read on…]

Simple trick to insert a static date in Postgres using Golang sqlx

While writing some tests I tried to use a static date in a NamedExec call and got this message: I was surprised that the pgsql driver would mistake a static value for a named parameter. Turns out that the issue lies in the way the sqlx NamedExec function parses the input SQL string before handing it off. There’s a simple work around that didn’t seem well documented. You can escape the ‘:’ character with another ‘:’ character. So to format a date to pass through cleanly this is how I format it: Hope this helps someone, or me when I [Read on…]

How to Use BuildContext with Async Safely

If you’ve ever received the DON’T use BuildContext across asynchronous gaps. message in Flutter you’re in good company. I keep getting it, fixing it, then forgetting what I did when I get it next time. The solution is very simple, don’t do that in stateless widgets and always check if the widget is mounted. It is made slightly more complicated by the fact that the docs on the linter error are either wrong or out of date. Build Context The Wrong Way Here’s why this is bad. This is a button handler called from the onPress method of some button in [Read on…]

Simple Time Control For Dart Unit Tests

Controlling time in a unit test allows you to test code that depends on the passage of time like Timer or time comparisons. Dart makes it easy as long as you use the Clock package in code that gets dates instead of using DateTime directly. For any code using Clock time can be controlled through the FakeAsync package. Example Time Test Two key things to note in this example test. First that the test is wrapped in the fakeAsync method. Second that the first time clock is used is inside the fakeAsync wrapper. That’s important, if you access the clock [Read on…]

AWS Websocket 403 Using PostToConnect

Using the V2 Golang SDK for AWS and trying to call PostToConnection from a Lambda I was consistently getting this 403 error result: I was trying to make the call from a different stack than the websocket connection was on so I thought that might be the problem. After much research the issue actually turned out to be simpler than that. There is nothing special about the stack that requires extra permission (unless the stages are in different regions, I haven’t done that yet but it looks like there is more work required if you are). The issue for me [Read on…]

Simple Close Button Handling for Flutter Snackbar

Adding a close button to a snackbar in Flutter is simple, however there is one subtlety to be aware of. If the view closes before the snackbar does then you can no longer get the ScaffoldMessenger from context in the close handler. Instead you need to pass the ScaffoldMessenger into the closure so that it remains available after the view closes. Wrong Way This approach will work most of the time, unless the view has already been disposed when the close button is clicked. Since snackbars are often used for errors or other termination handlers it is fairly common for [Read on…]

Success With AWS Web Socket Endpoint Configuration

I had a lot of trouble getting the API Gateway socket management calls to work using the AWS SDK V2 version of the Golang SDK. The problem was that I was not invoking the right endpoint. So that I remember in the future how to do this and to help anyone having similar problems here’s the magic formula I finally learned. Endpoint Value First you need to know the endpoint to use to make calls against. You can either look it up in the AWS console or get it dynamically from the request. I chose to get it from the [Read on…]

Working AWS Websocket JWT Authorizer

I was trying to add JWT authentication to an AWS web socket endpoint and it wasn’t working. My problem was simple and it was even spelled out mentioned in passing somewhere in the AWS docs and it still took me a long time to figure it out. The answer is that only request style authenticators are supported, not token. The docs say that here in that it doesn’t mention a token authorizer and explicitly states that only request is supported here. This post also makes the same point. In Serverless the configuration for the authorizer looks like this: Then a [Read on…]