18
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Swift]リリースビルドのビルドを失敗させる

Last updated at Posted at 2022-08-13

リファクタリングや、リリースバージョンによるマイグレーションなど、コードを書いている時には仮の実装をしておくが、リリース時には絶対に実装しなくてはいけないコードが時々あります。
リリース後にソースコードから

// ここはリリース前に書き換える

といったコメントが出てきた肝が冷えた体験がある人もいるのでは無いでしょうか。

Swiftでは#error()でビルドを失敗させることができるため、次のように記述することでデバッグビルド以外でビルドを失敗させることが出来ます。

#if !DEBUG
#error("リリース前に必ず実装する")
#endif

これでリリースビルドは作られなくなり、安全にコードを運用することが出来ました

18
7
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?