Archive for March 27, 2019

Wednesday, March 27, 2019

Swift 5 Released

Ted Kremenek:

Swift 5 is a major milestone in the evolution of the language. Thanks to ABI stability, the Swift runtime is now included in current and future versions of Apple’s platform operating systems: macOS, iOS, tvOS and watchOS. Swift 5 also introduces new capabilities that are building blocks for future versions, including a reimplementation of String, enforcement of exclusive access to memory during runtime, new data types, and support for dynamically callable types.

The main issue I’ve run into (which doesn’t seem to be part of any of the linked evolution proposals) is that the closure for Data.withUnsafeBytes() now gives you an UnsafeRawBufferPointer instead of an UnsafePointer<UInt8>, which is typically what I need to pass to other APIs. It was not obvious how to fix this because the initializers for UnsafePointer didn’t seem to apply, nor did the withUnsafePointer() free function. What I came up with was:

let unsafeBufferPointer = unsafeRawBufferPointer.bindMemory(to: UInt8.self)
let unsafePointer = unsafeBufferPointer.baseAddress!

I still don’t understand why baseAddress is defined as an optional or when it’s safe to force unwrap it.

Update (2019-03-28): Joe Groff:

baseAddress is optional so that it can hold a {NULL, 0} state for empty buffers. It is always nonnull if count > 0

An empty buffer is still a valid buffer; there are a lot of tradeoffs, but making baseAddress nullable seemed like the least bad, since many C APIs that ultimately consume these buffers also accept NULL with a zero count.

For the Data API, the count matches the Data’s count.

My takeway from this is that the Data API cannot be relied on to get you a UnsafePointer<UInt8> to pass to C because baseAddress could be nil if the Data is empty. This was never the case in my testing, but the API allows it, so force unwrapping is not a good idea.

I ended up writing an extension to provide a reliable UnsafePointer<UInt8>:

func mjtWithUnsafePointer<ResultType>(_ body: (UnsafePointer<UInt8>) throws -> ResultType) rethrows -> ResultType {
    return try withUnsafeBytes { (rawBufferPointer: UnsafeRawBufferPointer) -> ResultType in
        let unsafeBufferPointer = rawBufferPointer.bindMemory(to: UInt8.self)
        guard let unsafePointer = unsafeBufferPointer.baseAddress else {
            var int: UInt8 = 0
            return try body(&int)
        return try body(unsafePointer)

even though the callee likely won’t actually access it given that the size is zero.

Update (2019-03-29): I should also note that the automatic Swift 5 conversion failed and then beachballed for all my projects. It was easy enough to update them manually, though.

CorelDRAW Comes Back to the Mac

Agen Schmitz:

Returning to the Mac after 18 years, Corel has revived its vector graphics editor for macOS with the release of CorelDRAW Graphics Suite 2019. (The last CorelDRAW release for the Mac was CorelDRAW 11 in 2001.) In addition to the CorelDRAW 2019 vector illustration software, the suite includes Photo-Paint 2019 for image editing, AfterShot 3 HDR for raw photo processing, Font Manager 2019 (along with over 1000 TrueType and/or OpenType fonts), and thousands of clipart files, sample digital images, and vehicle wrap templates.


It’s nice to see CorelDRAW Graphics Suite 2019 providing some competition for Adobe’s Creative Cloud for significantly less money—the subscription works out to $16.50 per month, compared to Creative Cloud’s $52.99 per month. And Corel offers a perpetual license for those who dislike subscriptions.

Apple’s Services Event

Mark Gurman (Hacker News):

Apple’s three big hardware markets -- smartphones, personal computers and tablets -- are stagnating. To keep growing, the company has been trying to sell its existing device owners services such as Apple Music subscriptions, iCloud storage and AppleCare warranties.


The venue itself indicates the importance of the event to Apple. The company has only used the Steve Jobs Theater at its new headquarters twice since it opened two years ago. The first time, Apple debuted the iPhone X. The second time, it launched the iPhone XS and latest Apple Watch. To ensure all attention will be on services, Apple took the rare step of announcing several new hardware products on its website last week, including upgraded AirPods, iPads, and iMacs.

Kyle Howells:

Apple the product company has great incentives to behave well and make great stuff.

Apple as a services company is incentivised to become another horrible creepy company.

Apple’s services push is a very dangerous direction for the companies future.

Tim Schmitz:

This was a weird Apple event in that almost everything they announced won’t be available for months. I guess they had to pick a time to start rolling things out, but it feels odd that there’s not much you can use now.

Dave Nanian:

Seriously, though: did we just spend two hours finding out that 90% of that is not ready until Fall, and most of it had no price?

So…why did we have an event again?

Nilay Patel:

Apple event all done. My main takeaway is that nothing seems to be quite ready yet?

Dave Nanian:

This vaguely reminds me of when Microsoft decided to do MSNBC, MSN and Slate, back in the day.

Jon Stokes:

Wow, so I see that Apple has announced a whole raft of Apple-specific ways for me to pay for stuff I already pay for: news, games, credit card services, entertainment. Since I don’t have an Apple tattoo, nor do I blog about how I’ve been iPad-only since 2009, why should I care?

Tanner Bennett:

This whole presentation felt # a bit Black Mirror-y. It’s like Apple wants to own every part of your life, from content you consume to finances. But I guess they just want to join the club.

Rick Tetzeli:

There have been good Apple events and bad Apple events since Tim Cook took over as CEO seven and a half years ago, but there has been nothing like today’s event. For the first time that I can recall, Apple brought nothing to the table but its power.

Paul Haddad:

I had deleted all these apps prior to 12.whatever. I guess Apple wanted me to reconsider? Can I have that option when people delete my apps?

Ben Thompson:

That leaves an unmentioned fourth audience: Wall Street. […] At the time Cook only mentioned improving the iPhone trade-in process, but it certainly seems possible that announcing so many new services so far ahead of their launch was an attempt to deliver on that promise ahead of the company’s next earnings call.


It appears that Apple is attempting to thread the finest of needles: by not having players available on Android, Windows, or the web, Apple TV+ acts as another extension of Apple’s integrated model, differentiating Apple’s hardware in the process. The problem, though, is that creating or acquiring content is a fixed cost: that means that the economically optimal approach is to make that content available as widely as possible, increasing leverage on those fixed costs. Thus the partnerships with Amazon, Roku, and smart TV manufacturers.


That leaves Cook’s final line: At Apple, the customer is, and always will be, at the center of everything that we do.

Frankly, with the possible exception of Apple Arcade, it is hard to see this sentiment in yesterday’s announcements; I’m not saying any of these services are customer hostile, but most of them are imitations of what other companies are already doing, the revenues of which Apple wants a cut of.

Nick Heer:

I’m cautiously optimistic that this is the path Apple is chasing. But I am also fighting an inner voice that wonders if this is driven by bean counters in search of recurring revenue. Apple is obviously chasing services as their next big product category; Tim Cook has been completely transparent about that in earnings calls and public appearances. Assuming — generously — that Apple Arcade and Apple TV Plus are each ten dollars per month, it’s easy to think that there are customers who will be spending

Greg Lipper:

Lingering concern is that Apple’s new services focus is aimed at improving its numbers for Wall Street rather than solving its customers’ problems. That’s kind of deadly for a company in the long run.


Today’s event was about an Apple that may still have their sights of some important values compared to other behemoths, but where the focus is on the fervent belief that whole-banana-ism needs to extend to every corner of everyone’s life. Behemoths like Apple, Amazon, Google and Microsoft act as if they need to have fingers in every pie, provide solutions to every problem, build complete stacks.

Even people who loved Think Different and who still love Apple know there’s more to reading News than Apple News+ (or indeed the normal Apple News app), more to games than Apple Arcade (and indeed indie games have been turning conventions inside out for decades) and more to TV than Apple TV+. Regardless of whether they include good products, Apple is starting to insult both the people who use their products and the heroes they hopefully still respect.


Update (2019-03-29): M.G. Siegler:

I believe I’ve seen every single Apple event over the past decade-plus. Yesterday’s was without question the weirdest I’ve ever seen. So weird that I’m still trying to wrap my head around it. Twitter is helping me a bit, but jotting some notes down before I read others’ thoughts will help me more. Here goes.


“You can see how important these services are for us.” That is one way to put it. Sheesh.

Update (2019-04-08): Jean-Louis Gassée:

Another observer I know privately sees the growing network of services as a defensive move: They make life increasingly safe and pleasant, which is a way to keep Apple customers “inside”, to make sure they stay in the ecosystem.


In Evans’ analysis, trust is at the center of the relationship between Apple Services and its customers:

“Trusted, secure, private, no ads, no scams, no tricks you have to watch for (scammy in-app purchases in games, scammy/weird credit card charges) — it’s all curated.”

Will customers appreciate, intellectually, this new relationship? Perhaps. But at the visceral level — the one that really counts — Apple’s new promise can work. This is a much better way to think (and emote) about the new Services than reducing the analysis to yet another ding to our pocketbooks.

The Talk Show:

Special guest Peter Kafka — executive editor at Recode and longtime reporter in the fields of media and technology — joins the show to discuss the announcements at last week’s “Show Time” event: Apple News+, Apple Card, Apple Arcade, and Apple TV Channels and TV+.

He and Gruber are “equally confused.”