Xcode環境分離メモ

環境分離後、リリースビルドが通らない
エラー
なんちゃらかんちゃら No such file or directory
原因
ProductNameにサフィックスをつけていたこと(参考記事がよくなかった?)
解決
サフィックスを消す

リリース用のスキームを選択時、プレビューが表示されない
エラー
== PREVIEW UPDATE ERROR:
OptimizationLevelError: not building -Onone
”Sample App.app” needs -Onone Swift optimization level to use previews
== PREVIEW UPDATE ERROR:
OptimizationLevelError: not building -Onone
”Sample App.app” needs -Onone Swift optimization level to use previews
原因
リリースビルドのOptimization Levelが影響していた
解決
開発用スキームに切り替える
レベルを下げる(プロジェクト>ターゲット>Buid Setting>検索
Build Settings > SwiftCompiler - Code Generation
Optimization Levelとは?
- Xcode でビルドするアプリの最適化レベルを指定する設定項目
- この設定により、アプリのパフォーマンスとコードサイズに影響を与える
具体的な影響
パフォーマンス:
高い最適化レベルを選択すると、アプリの実行速度が向上しますが、コードサイズが大きくなります。
低い最適化レベルを選択すると、アプリの実行速度が低下しますが、コードサイズが小さくなります。
コードサイズ:
高い最適化レベルを選択すると、コードサイズが大きくなります。
低い最適化レベルを選択すると、コードサイズが小さくなります。
最適化レベルの種類
Xcode では、以下の最適化レベルが用意されています。
None (-Onone): 最適化なし
Debug (-O): デバッグ用
Release (-O2): リリース用
Fast (-O3): 高速化用
Smallest (-Os): コードサイズ最小化用
最適化レベルの選択
最適化レベルは、アプリの用途や目標に応じて選択する必要があります。
開発中: デバッグ用に Debug 設定を選択するのが一般的です。
リリース: リリース用に Release 設定を選択するのが一般的です。
パフォーマンスが重要: パフォーマンスが重要な場合は Fast 設定を選択できます。
コードサイズが重要: コードサイズが重要な場合は Smallest 設定を選択できます。
注意事項
高い最適化レベルを選択すると、デバッグが難しくなる場合があります。
最適化レベルを変更すると、アプリの動作が変わる可能性があります。

環境分離後、リリースビルドでRealmのクラッシュ
エラー
uncaught exception in notifier thread: N5realm2DB10BadVersionE: Unable to lock version 6 as it does not exist or has been cleaned up.
2024-02-15 21:08:37.897859+0900 まるまる App[453:1491634] uncaught exception in notifier thread: N5realm2DB10BadVersionE: Unable to lock version 6 as it does not exist or has been cleaned up.
libc++abi: terminating with uncaught exception of type realm::DB::BadVersion: Unable to lock version 6 as it does not exist or has been cleaned up.

SLocalizedDescription=exportOptionsPlist error for key "method": expected one of {}, but found app-store

Missing Info.plist value. A value for the Info.plist key 'CFBundleIconName' is missing in the bundle 'App.App'. Apps built with iOS 11 or later SDK must supply app icons in an asset catalog and must also provide a value for this Info.plist key. For more information see http://help.apple.com/xcode/mac/current/#/dev10510b1f7.

This bundle is invalid. The bundle identifier cannot be changed from the current value, 'App.App.watchkitapp'. If you want to change your bundle identifier, you will need to create a new application in App Store Connect.

Missing required icon file. The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 10.0. To support older versions of iOS, the icon may be required in the bundle outside of an asset catalog. Make sure the Info.plist file includes appropriate entries referencing the file. See https://developer.apple.com/documentation/bundleresources/information_property_list/user_interface

Metadata/Info.plist Mismatch. The value for bundle_identifier in the metadata.xml file does not match the value for CFBundleIdentifier in App [Payload/App.app].

Missing Icons. No icons found for watch application 'App.app/Watch/App Watch App.app'. Make sure that its Info.plist file includes entries for CFBundleIconFiles.

NSLocalizedDescription=exportOptionsPlist error for key "method": expected one of {}, but found app-store

WatchOS8.8でリリースビルド時だけ、特定の画面でクラッシュする
原因
多分、Optimization level のせい