1
1

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.

Xcode 12.5でiOS 12以前のシミュレータで実行しようとすると(Realmが起因で)クラッシュする問題

Last updated at Posted at 2021-05-31

検証環境

  • Xcode 12.5
  • Realm 10.7.6
  • iOS 12.4 simulator
  • CocoaPods 1.10.1

事象

上記の環境でアプリを実行しようとするとクラッシュしました。

コンソールには以下のようなエラーが出力されました。

dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
  Referenced from: /.../myApp.app/Frameworks/RealmSwift.framework/RealmSwift
  Reason: image not found

どうやら、Xcode 12.5 + Realmの新しめのバージョン + CocoaPods利用の条件で発生するようです。

当面の回避策

Podfileの定義を以下のようにします。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'RealmSwift'
      target.build_configurations.each do |config|
        config.build_settings['OTHER_LDFLAGS'] = '$(inherited) -weak_framework SwiftUI'
      end
    end

  end
end

Realmのissueが上がっていて、とりあえずの回避策として上記が紹介されていました。
https://github.com/realm/realm-cocoa/issues/7234

補足情報(2021-05-31現在)

Realmのプルリクが上がっているようです。近々対応されそうです。
https://github.com/realm/realm-cocoa/pull/7268

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?