LoginSignup

Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

4
7

More than 3 years have passed since last update.

【swift】 ビルドができず、unable to open fileのエラー

Posted at

1.状況

git cloneしてswiftのコーディングをしようとしたが、
ファイルが開かず、シミュレーションも起動しない。

スクリーンショット 2020-07-23 16.25.34.png

Showing All Issues
/Documents/practice_swift/Pods/Target Support Files/Pods-todoapp/Pods-todoapp.debug.xcconfig: unable to open file (in target "todoapp" in project "todoapp")

2.原因

cocoapodsのインストールがなかった。

cocoapodsとは、

iOSアプリ作成のためのライブラリ管理をしてくれるもの
https://cocoapods.org/

cocoapodsのインストールをします。

 $ sudo gem install cocoapods

 $ sudo gem update –system
 $ sudo gem install -n /usr/local/bin cocoapods
 $ pod setup

git cloneしたプロジェクトファイルに移動してインストールをします。

 $ pod deintegrate
 $ pod install

結果は良さそう。DBの役割のRealmもインストールされている。

Downloading dependencies
Installing Realm (5.1.0)
Installing RealmSwift (5.1.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.

もう一度xcodeでビルディングしてみる
スクリーンショット 2020-07-23 16.36.41.png

ビルディング成功!やった!
スクリーンショット 2020-07-23 16.38.21.png

4
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
isaatsu0131

@isaatsu0131

バックエンドエンジニアです。
Linked from these articles

Comments

externvoid@github
@externvoid@github(extern void)
(Edited)

参考になった。M1 Macで

sudo gem install ffi
pod install

が失敗するのでTerminal.appをRossetaモードで起動してやり直したら成功した。
ffiのインストール先は

[1839@18:52]#ls -l ffi-1.15.5/lib/ffi_c.bundle  [/Library/Ruby/Gems/2.6.0/gems]
-rwxr-xr-x  1 root  wheel  192392  4 25 20:56 ffi-1.15.5/lib/ffi_c.bundle
[1842@18:57]#otool -L ffi-1.15.5/lib/ffi_c.bundle
ffi-1.15.5/lib/ffi_c.bundle:
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/libruby.2.6.dylib (compatibility version 2.6.0, current version 2.6.8)
	/usr/lib/libffi.dylib (compatibility version 1.0.0, current version 30.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
[1844@19:11]#file ffi-1.15.5/lib/ffi_c.bundle   [/Library/Ruby/Gems/2.6.
ffi-1.15.5/lib/ffi_c.bundle: Mach-O 64-bit bundle x86_64

Home Brewを使えばaarm64版のffi, つまりlibffi.aをインストールできるらしい。(未確認)
ちなみに、bundleは2種類あるMacの共有ライブラリDynamic Linking, Dynamic Loadingのうちの後者だ。fileコマンドの出力がそう語っている。拡張子は何でもよく、soでもOK.
[C言語] 共有ライブラリと静的ライブラリを整理する - Qiita

前者と後者の決定的な違いは何かと、気になるところだが、
.soや.dylibや.aファイル、共有ライブラリなどについて調べてみた - kanonji’s diary

これを読んでもよく分からん。しかし、Linkingはライブラリから関数だけを取り出して実行プログラムに取り付ける。たとえば、printfを使う実行プログラムはlibstd.bundleから該当箇所だけ動的にリンクする。
Loadingはもっと大きな単位でつまり、サブプログラム単位で実行時に呼び出される。これが大きな違いの様だ。pluginの動作がこれに該当する。e.g. Apache Web ServerがSSLモジュールを読み込む。
pluginは動作が終わればunloadされるが、Linkingされたprintfはunloadされることはない。

Dynamic Linking vs. Dynamic Loading | Baeldung on Computer Science

0

Let's comment your feelings that are more than good

Being held Article posting campaign

そうだ!TestRailを使ってみよう!!

~
View details

CodeAGIで実際にコードを自動生成してレビューを投稿しよう!

~
View details
4
7

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address