Matteo Gavagnin

Blog

Magic Keyboard 2

Apple all but confirmed that the next MacBook Pro models will be unveiled tomorrow and will include support for Touch ID and a custom bar is going to replace the current top row of keys in the embedded keyboard.

Pay MacBook Pro

The above image is already on your Mac if you installed the latest macOS Sierra 10.12.1 update. Check for yourself looking at

/System/Library/PrivateFrameworks/PassKitUI.framework/Versions/A/Resources/ApplePaySplashSA.tiff

Besides the lack of a visible physical power button and of the Esc key, Steve Troughton Smith suggested that developers, in order to populate the Magic Bar with custom controls, will need to create extensions much like the ones used in watchOS 1.

Dynamic Framework with CocoaPods support

A short and compact guide to create a basic redistributable framework with CocoaPods support. This example is intended to work on iOS, but the same principles can be applied to watchOS, tvOS and macOS.

Create a new Xcode project and select Cocoa Touch Framework.

Framework

For redistributable libraries Objective-C is still the language-to-go. But you can also choose to write them in Swift if the host apps are willing to include the swift runtime.

Framework

Framework

Blurred Rounded UIView

Maps and Apple Music apps in iOS 10 include a brand new way to present modal contents: a floating semi-modal view. Widgets and notifications have been redesigned to be presented with a similar shape.

Due to beta developer agreement I cannot share screenshots of those features. However you can have a look at them visiting the dedicated iOS 10 preview page on Apple’s website.

Unfortunately the technique used in iOS 8 and 9 to round the corner won’t work anymore: you’ll end up with rounded corners and a transparent background instead.

There’s an entire thread on Apple’s Developer Forums with motivations behind this change (you need to register as developer to read it).

However the trick is to avoid using layer.mask on the view that contains the UIVisualEffectView as subview or on the UIVisualEffectView itself as we used to do. Instead you are supposed to use layer.maskView or, if you just need rounded corners, the layer.cornerRadius property associated with layer.masksToBounds = true.

I’ve also found that if you try to add an external shadow to the container view’s layer, you’ll end up without blur. The trick is to set the shadow inside func layoutSubiviews() override method.

libjpeg-turbo with bitcode

For a little side project I’m developing for iOS, I needed to build libjpeg-turbo.

Unfortunately the binary provided by the project maintainers doesn’t include bitcode and even if at the moment it’s not compulsory (unless you are targeting WatchOS), I like to be future proof, as Apple will eventually require it to be included in every app binary.

I’ve found a dedicated repository by David Hoerl with instructions to build libjpeg-turbo for iOS, but unfortunately it doesn’t include bitcode too.

In the issues on GitHub there’s a build script to build with bitcode enabled, but with the current SDK versions it fails.

MacDown fork

I just forked MacDown, a popular open-source markdown editor for Mac as I have a few ideas to improve it to better suit my needs.

I’m looking to add some features that I wasn’t able to find in any other Mac editor to help me write blog posts. This blog like many others is powered by Jekyll, a ruby application capable to parse markdown formatted text files and generate a static website.

What I’m missing from MacDown is the ability to seamlessly write and preview my posts exactly1 as they will appear on the website. I’m currently able to do it with the combination of 7 apps:

  • Atom (or any other text editor like MacDown itself) to write the post and
  • Terminal, to run the command bundle exec guard that launches
  • Guard that tells
  • Jekyll to regenerate the pages as soon as the file is modified and saved to disk, and also run
  • guard-livereload that in combination with the
  • LiveReload Safari Extension can reload the page in
  • Safari as soon as a new version is available.

What I’m aiming for is to be able to reduce the amount of apps needed to obtain the same result. With just 40 added and 4 removed lines to the MacDown source code, I made a hack to remove from the workflow Atom, Guard, guard-livereload, the LiveReload Safari Extension and Safari itself reducing the needed apps to just three2.

  1. MacDown itself can live preview the document with a custom theme, or you can use Marked if you prefer to use a more capable external application. However using them you won’t be able to preview the page exactly as it will appear on your production website. 

  2. Full disclosure: I’ve also added Xcode as dependency because to change the file to preview I need to recompile the app, but that’s a rough hack, as I already said. 

 
twitter telegram github email
Leave this world a little better than you found it1