0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Devbox環境下でEASのiOSローカルビルドを成功させる

Last updated at Posted at 2025-06-28

結論

  • devboxが内部で色々な環境変数を定義している
  • そのためEASでビルド時にXcodeがビルドツールを見つけられない
  • 各種ビルドツールの環境変数をunsetし、明示的にDEVELOPER_DIRSDKROOTを環境変数に定義する
devbox.json
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.14.0/.schema/devbox.schema.json",
  "packages": ["nodejs@latest", "pnpm@latest"],
  "shell": {
    "init_hook": [
      "export PATH=/usr/bin:$PATH",
      "unset CC CXX LD AR AS NM RANLIB STRIP",
      "unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS",
      "unset NIX_CFLAGS_COMPILE NIX_LDFLAGS MACOSX_DEPLOYMENT_TARGET",
      "unset DEVELOPER_DIR",
      "export DEVELOPER_DIR=\"$(xcode-select -p)\"",
      "export SDKROOT=\"$(xcrun --sdk iphoneos --show-sdk-path)\""
    ]
  },
  "env": {
    "NODE_ENV": "development"
  }
}

背景

ExpoReact Nativeプロジェクトを触っていると、Expo goではなくEASビルドをして動作確認したくなる時がよくあります。
EASはクラウドでビルドすれば楽ちんですがビルド制限が以外と厳しく、個人開発者が開発開始当初ネイティブコンパイルが必要なパッケージをいれる度にビルドしていたらすぐに無料回数制限に達してしまいます。

ということで誰しもローカルビルドに行き着くのですが、環境構築にdevboxを使用しているとなぜかローカルビルドに失敗してしまいます。

例えば以下のようなエラーログです。

[RUN_FASTLANE] [!] Error building the application - see the log above
[RUN_FASTLANE] Error: The "Run fastlane" step failed because of an error in the Xcode build process. We automatically detected following errors in your Xcode build logs:
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
Refer to "Xcode Logs" below for additional, more detailed logs.
[CLEAN_UP_CREDENTIALS] Destroying keychain - /var/folders/7_/vmtcv9n141b7tycc6nsy8zyr0000gn/T/eas-build-ca6b9441-078b-48dd-a347-360a18f40e06.keychain
[CLEAN_UP_CREDENTIALS] Removing provisioning profile

Build failed

The "Run fastlane" step failed because of an error in the Xcode build process. We automatically detected following errors in your Xcode build logs:
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
- unknown type name 'ldiv_t'
- no member named 'ldiv' in the global namespace
- unknown type name 'lldiv_t'
- no member named 'lldiv' in the global namespace
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- use of undeclared identifier 'abort'
- reference to unresolved using declaration
- use of undeclared identifier 'wcschr'
- use of undeclared identifier 'wcspbrk'
- use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
- use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
- no matching function for call to 'wcschr'
- cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
- use of undeclared identifier 'wmemchr'
- reference to unresolved using declaration
- too many errors emitted, stopping now [-ferror-limit=]
Refer to "Xcode Logs" below for additional, more detailed logs.
[RUN_FASTLANE] ⚠️  ld: -rpath missing <path>
[RUN_FASTLANE] ⚠️  ld: -rpath missing <path>
[RUN_FASTLANE] ⚠️  ld: -rpath missing <path>
[RUN_FASTLANE]

❌  ld: unknown options: -Xlinker -isysroot -Xlinker -Xlinker -Xlinker -Xlinker -rdynamic -Xlinker -Xlinker -Xlinker -fobjc-link-runtime -Xlinker -Xlinker

[RUN_FASTLANE]     Run script build phase '[CP-User] [Hermes] Replace Hermes for the right configuration, if needed' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'hermes-engine' from project 'Pods')
[RUN_FASTLANE] ▸ ** ARCHIVE FAILED **
[RUN_FASTLANE] ▸ The following build commands failed:
[RUN_FASTLANE] ▸ Ld /Users/braveryk7/Library/Developer/Xcode/DerivedData/Projectdevelopment-akfubkvcbarahdcknrksrftxpitz/Build/Intermediates.noindex/ArchiveIntermediates/Projectdevelopment/InstallationBuildProductsLocation/Applications/Projectdevelopment.app/Projectdevelopment normal (in target 'Projectdevelopment' from project 'Projectdevelopment')
[RUN_FASTLANE] ▸ Archiving workspace Projectdevelopment with scheme Projectdevelopment
[RUN_FASTLANE] ▸ (2 failures)
[RUN_FASTLANE] Exit status: 65
[RUN_FASTLANE]
[RUN_FASTLANE] +---------------------------------------+
[RUN_FASTLANE] |           Build environment           |
[RUN_FASTLANE] +-------------+-------------------------+
[RUN_FASTLANE] | xcode_path  | /Applications/Xcode.app |
[RUN_FASTLANE] | gym_version | 2.228.0                 |
[RUN_FASTLANE] | sdk         | iPhoneOS18.5.sdk        |
[RUN_FASTLANE] +-------------+-------------------------+
[RUN_FASTLANE]
[RUN_FASTLANE] Looks like fastlane ran into a build/archive error with your project
[RUN_FASTLANE] It's hard to tell what's causing the error, so we wrote some guides on how
[RUN_FASTLANE] to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
[RUN_FASTLANE] Before submitting an issue on GitHub, please follow the guide above and make
[RUN_FASTLANE] sure your project is set up correctly.
[RUN_FASTLANE] fastlane uses `xcodebuild` commands to generate your binary, you can see the
[RUN_FASTLANE] the full commands printed out in yellow in the above log.
[RUN_FASTLANE] Make sure to inspect the output above, as usually you'll find more error information there
[RUN_FASTLANE]
[RUN_FASTLANE] [!] Error building the application - see the log above
[RUN_FASTLANE] Error: The "Run fastlane" step failed with an unknown error. Refer to "Xcode Logs" below for additional, more detailed logs.
[CLEAN_UP_CREDENTIALS] Destroying keychain - /var/folders/7_/vmtcv9n141b7tycc6nsy8zyr0000gn/T/eas-build-1d136160-6f3b-4528-a64e-b6c54feac9ee.keychain
[CLEAN_UP_CREDENTIALS] Removing provisioning profile

Build failed

The "Run fastlane" step failed with an unknown error. Refer to "Xcode Logs" below for additional, more detailed logs.

これらはdevboxが起動時に環境変数を設定することでローカル(Mac)のビルドツールにアクセスができなくなってしまっていることが原因です。
そこで、冒頭示した通りdevbox shell時にコマンドが自動的に実行されるようにinit_hookを指定します。

devbox.json
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.14.0/.schema/devbox.schema.json",
  "packages": ["nodejs@latest", "pnpm@latest"],
  "shell": {
    "init_hook": [
      "export PATH=/usr/bin:$PATH",
      "unset CC CXX LD AR AS NM RANLIB STRIP",
      "unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS",
      "unset NIX_CFLAGS_COMPILE NIX_LDFLAGS MACOSX_DEPLOYMENT_TARGET",
      "unset DEVELOPER_DIR",
      "export DEVELOPER_DIR=\"$(xcode-select -p)\"",
      "export SDKROOT=\"$(xcrun --sdk iphoneos --show-sdk-path)\""
    ]
  },
  "env": {
    "NODE_ENV": "development"
  }
}

色々な環境変数をunsetしていますが、関係がありそうなものを片っ端から指定したのでもしかしたらもっと少なくても良いかもしれません。

devbox.json
"export DEVELOPER_DIR=\"$(xcode-select -p)\"",
"export SDKROOT=\"$(xcrun --sdk iphoneos --show-sdk-path)\""

この2つについては将来的にXcodeやSDKのバージョンが変わっても良いように動的生成にしてありますが、明示的に指定したい場合はハードコートしても良いかもしれません。
チーム開発等で「むしろ特定のSDK以外はエラーにする」という方針が決まってるならそっちの方が良いと思います。

devboxはいいぞ

devboxはまだまだ割とマイナーな部類(だと思ってるけどどうなんでしょう)で情報も少なく環境構築のデファクトスタンダードにはなっていませんが、とにかく様々な環境を閉じ込めるという意味ではdocker以上に手軽でnodebrewのようなバージョン管理ソフトよりも多機能と至れり尽くせりです。

チーム開発でもdevbox.jsondevbox.lockさえgit管理しておけばあとはcloneしてdevbox shellと打つだけ、楽ちん。

かくいう僕も「6つの開発環境管理ツールを経てDevboxが一番バランスが良さそうだと思いました」という記事を読んで「なにこれええやん!」と使い始めて数ヶ月程度なのですが現状非常に満足しています。

開発環境の構築をより簡単にしてくれるツール Devbox」にもよくまとまっているのでぜひExpo, React Nativeプロジェクトにも採用してみてください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?