6
3

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 5 years have passed since last update.

【bitrise】Undefined symbols for architecture x86_64が出る時に疑う事

Last updated at Posted at 2020-02-19

自分がハマったのでtipsの共有です。

問題

bitriseで何回ビルドを行っても**「Undefined symbols for architecture x86_64」**というエラーが出るので困り果てていたのですが、すごく些細な理由で問題が起きていました。

原因

XcodeのSchemeで、Gather coverage forにチェックマークしていないのに、bitrseのXcode tests for iOSのステップで、Generate code coverage files?のオプションをyesにしていることが原因です。

bitriseのテストステップは内部でxcodebuildを使ってテストを実行しているのですが、これをyesにするとGCC_GENERATE_TEST_COVERAGE_FILESというオプションがYESでコマンドに渡されるようになります。

Gather coverage forをyesにすると、xcodeproj内のxcschemeのcodeCoverageEnabledというフィールドがYESになるのですが、この項目がYESではないのに GCC_GENERATE_TEST_COVERAGE_FILES=YESのオプションを渡しているためエラーが発生したようです。

xcodebuild.sh
set -o pipefail && env "NSUnbufferedIO=YES" xcodebuild "-workspace" "Some.xcworkspace" "-scheme" "Some" "build" "COMPILER_INDEX_STORE_ENABLE=NO" "test" "-destination" "id=DDD6FC97-6DB4-40D9-89AB-0B9C5541B18B" "-resultBundlePath" "/var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/XCUITestOutput157008135/Test.xcresult" "GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES" "GCC_GENERATE_TEST_COVERAGE_FILES=YES" | xcpretty "--color" "--report" "html" "--output" "/Users/vagrant/deploy/xcode-test-results-CanDO.html

解決

bitrseのXcode tests for iOSのステップで、Generate code coverage files?のオプションをnoに設定した発生しなくなりました。

そもそも収集していないのに生成しようとすると、タイトルのUndefined symbols for architecture x86_64というエラーが投げられるようです。

Bitriseでハマった時のデバッグ

デバッグに効果的だった方法を書き残しておきたいと思います。

  1. ローカルとCIの環境がバラバラにならないように、パッケージ管理の仕組み(Bundlerなど)を使う
  2. CIのログを読んで、ローカルで同じコマンドを実行してみる

特に2番目は大事で、CIはVM立ち上げるのが遅いのでちょっと変えて試してがやりにくくて、デバッグはし辛いです。なので、手元で同じコマンドを打って、どのようなコマンド,オプションの渡し方をすればこの問題は解決するのか。というところから逆算でCIのステップを直していくのが効果的でした。

6
3
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
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?