Installing Swift 3 on Ubuntu Server 16.10
I recorded a video tutorial on installing Swift 3 on Ubuntu Server 16.10.
I recorded a video tutorial on installing Swift 3 on Ubuntu Server 16.10.
// MARK: - UIView Extension, or NSView
extension UIView {
/// Shake animation
func shake() {
let animation = CAKeyframeAnimation(keyPath: "transform.rotation")
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animation.duration = 1.0
animation.values = [-Double.pi / 6, Double.pi / 6, -Double.pi / 6, Double.pi / 6, -Double.pi / 7, Double.pi / 7, -Double.pi / 8, Double.pi / 8, 0.0 ]
layer.add(animation, forKey: "shake")
}
}
myView.shake()
Over the past couple of weeks, new versions of macOS, iOS, tvOS, and watchOS have been released. Along with them came a new Xcode and a new version of Swift.
When you open a project in the new Xcode, it immediately offers to convert the project to the new Swift version—either to version 2.3, which is almost unchanged as an intermediate version, or straight to the new Swift 3, which has quite a lot of changes.
Converting the project itself is not difficult, because Xcode has a built-in converter. I decided to try 2.3 first so as not to dive into the weeds of the changes. The working project converted without problems, and then dependency hell began. I use Carthage; all dependencies are compiled into a .framework that you import into your project. Once imported, you usually do not need to touch the project itself anymore, just rebuild the dependencies. In the first week after the release, many developers quickly shipped updates—a release for Swift 2.3 and a release for Swift 3. But not everyone. For example, SwiftyJSON: its developers disappeared for a while, and the framework is very popular. I had to dig around—the dependencies that had not been updated were fortunately picked up by third-party developers. They forked them, moved everything to Swift 2.3, and sent pull requests to the original repositories.
I had to spend some time replacing some dependencies with forks. And hooray, the project finally built. During the following week, the authors of all the dependencies I use had already shipped Swift 2.3 releases. With a clear conscience, I switched the dependencies back to the originals.
Naturally, it made sense to move to Swift 3 as soon as possible, because 2.3 is a temporary version and support for it will disappear in future Xcode releases. Besides, Swift 3 was promised to be, if possible, the last version that would break compatibility with previous versions.
Again, the project itself converted to Swift 3 without major issues. Not everything, but a lot. And whatever did not convert automatically, Xcode itself suggested fixes during compilation; for the most part I only had to click the mouse and let it apply them. Even though I waited until all dependencies were updated to Swift 3, I still had to sweat a bit. Incidentally, if a framework is compiled in Swift 2.3, you cannot include it in a Swift 3 project. And vice versa too. I cleared up various problems—and then a different kind of headache started. AlamoFire for Swift 3 did not just get updated, it got a major update—with renamed classes and API changes. As a result, I had to rewrite some methods by two thirds. Although in most cases I just had to swap argument order and rename things here and there. Plus, now to pass GET parameters, you have to add them to the URL string by hand; previously the parameters argument could do that, but now that data is sent in the request body as if we had filled in a form.
But in the end everything turned out fine, although the migration took time and effort. Onward, into the future.
P.S. The open-source version of Swift 3, which can run on Linux, still does not have a full implementation of the classes for working with networking. And the backend framework Perfect does not compile on Ubuntu 16.04. So Swift for the backend is postponed again for now.
In the new Swift 3 there is now a different initializer for NSNotification (now simply Notification; the NS prefix was dropped):
struct Config {
static let ShouldCloseBrowserNotification = "ShouldCloseBrowserNotification"
}
let notification = Notification(
name: Notification.Name(rawValue: Config.ShouldUpdateDialogNotification),
object: nil,
userInfo: nil
)
NotificationCenter.default.post(notification)
The name parameter does not look very nice now. But you can extend Notification.Name to make it look better:
extension Notification.Name {
static let shouldCloseBrowserNotification = Notification.Name("ShouldCloseBrowserNotification")
}
let notification = Notification(
name: .ShouldUpdateDialogNotification,
object: nil,
userInfo: nil
)
NotificationCenter.default.post(notification)
UIKit itself is structured in roughly the same way:

I had read mentions before that the Mac App Store is dead. About a month ago I hacked together my informer for Yandex AppMetrica and uploaded it to MAS. I started watching the charts (not for long, admittedly). In fact, there were 2 purchases at launch (I even know who both were from). The result surprised me.
Immediately first place in the Business category in the Russian Mac App Store. Of course, it is nice when your icon decorates the list of categories.
Still, just 2 purchases say that people really buy and download very few apps in the Mac App Store. Maybe free ones get downloaded more, but paid ones definitely do not. At least in Russia. It is nothing like the App Store for iOS apps. On top of that, the app reached 8th place in the store's overall top chart.
So it is not about the category. In other countries, apps are probably bought more often, but in Russia it is very little. Then again, piracy is much more widespread on macOS than on iOS, because there is no jailbreak hassle involved. That is probably why people here do not buy very often.
The secret is simple. Go to iconfinder.com, find a decent flat icon. It is usually in fairly muted tones. Download the SVG, open it in Sketch. Add gradients and shadows to the elements, and you get a contrasty, punchy icon. At least it is better than it was :)