しめ鯖日記

swift, iPhoneアプリ開発, ruby on rails等のTipsや入門記事書いてます

Xcode 7.0 について調べてみた

新しいXcodeの新機能が公開されていたので少し調べてみました。
全部ではないのですが、面白そうな機能をまとめてみました。

developer.apple.com

Swift2.0サポート

話題のSwift2.0がサポートされるようです。
大きな変更点は下の通りです。

Error Handling.

Error Handling. Now you can create routines that throw, catch and manage errors in Swift. You can surface and deal with recoverable errors, like “file-not-found” or network timeouts. Swift 2.0’s error handling interoperates seamlessly with NSError.

try/catchのような構文が採用されるようです。
エラー処理が今までと大分違った形になりそうですね。

Availability.

Availability features enable you to mark up methods with the OS that they are available on, providing compile time checking and preventing unavailable methods from being used. You can adopt new APIs while still deploying back to older OS versions, and provides compile-time errors when you’re using API that isn’t guaranteed to be available on the deployment target.

APIが使えるかどうかを見てくれるようです。
今までだと「メジャーバージョンが7以下だったら○○する」みたいに書いていた所を置き換えてくれそうです。

Testability.

With testability, you are now able to write tests of Swift 2.0 frameworks and apps without having to make all of your internal routines public. Use @testable import {ModuleName} in your test source code to make all public and internal routines usable by XCTest targets, but not by other framework and app targets.

@testable import {ModuleName}とテスト上に書くと必要なモジュールを持ってこれるようです。

Protocol extensions.

You can now add methods and properties to any class that conforms to a particular protocol, allowing you to reuse more of your code. For example, in the standard library, instead of having to use global functions for all of the generic algorithms in the standard library (such as map, filter, and sort), those generic algorithms are now available as methods on all of the collection types.

読んだ所プロトコルメソッドを追加できるようです。
Rubyのmix-inのような使い方ができるという事でしょうか。

Objective-cの新しい構文

Genericsnil許可かどうかの構文が提供されるようです。
nil許可はXcode6.3の__nullableとは違うのか気になる所です。

Free Provisioning

Develop on your own device. Part of being successful at debugging and testing is being able to run your app on a physical device. You’ve always been able to build and run on Simulator in the past, but running on a device required a complex set of steps to allow you to install and run your app. With Xcode 7, all you need is an Apple ID and you can develop and test on any device.

実機テストがAppleIDだけで行けるようになりそうです。
証明書の期限が切れたり秘密鍵の共有が必要だったりと辛い経験からついに開放されそうですね!

Debugging

Energy Gauge for iOS.

Xcode 7 brings insight into the energy usage of your iOS app with the energy gauge. iOS 9 has plumbed-in the ability to track energy on a per-process basis, which is surfaced in the energy report. This is a great way to gain insight into how your app is affecting battery life. You can see unexpected behavior, like high energy usage while you’re app should be just sitting idle or anomalous spikes in power consumption when you’re expecting a steady profile. Learn more about how to manage power for iOS apps in Energy Efficiency Guide for iOS Apps.

バッテリー消費量を出してくれるようです。
ゲームなどではかなり重宝しそうですね。