LoginSignup
2
2

More than 3 years have passed since last update.

Xcode 12 + XcodegenでCycle Inside ______エラーでテストターゲットがビルド通らない問題

Posted at

問題

Cycle inside <redacted>Tests; building could produce unreliable results. This usually can be resolved by moving the shell script phase '[CP] Embed Pods Frameworks' so that it runs before the build phase that depends on its outputs.
Cycle details:
→ Target '<redacted>Tests' has copy command from '/Applications/Xcode12.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework' to '<redacted>/Library/Developer/Xcode/DerivedData/<redacted>-bxjgdjscysiavpfrzmquaqdkncsl/Build/Products/Debug-iphonesimulator/<redacted>.app/Frameworks/XCTAutomationSupport.framework'
○ Target '<redacted>Tests': CodeSign <redacted>/Library/Developer/Xcode/DerivedData/<redacted>-bxjgdjscysiavpfrzmquaqdkncsl/Build/Products/Debug-iphonesimulator/<redacted>.app/PlugIns/<redacted>Tests.xctest/Frameworks/CryptoSwift.framework
○ That command depends on command in Target '<redacted>Tests': script phase “[CP] Embed Pods Frameworks”

Xcode 12にアップデートした後にテストターゲット実行してみたら上記のエラーがでまくっていました😭

色々調べてみて以下のStackOverflow issue見つかって
https://stackoverflow.com/questions/64556134/xctest-running-tests-fails-with-cycle-inside-x-building-could-produce-unreliab
なるほど〜ってなったけど。。。🤔

image.png

Xcodegenでプロジェクト生成しているためチェック外してもxcodegen走るたびに外さないといけなくなってしまう。。。

もしXcodegenでできる方法知っている方いたら教えて欲しいけど自分が探しても何もなくて以下の作戦で解決できました

フィックス

Xcodeproj to the rescue!
https://github.com/CocoaPods/Xcodeproj

こちらのスクリプトだけで簡単に外せた

require 'xcodeproj'
project_path = './Project.xcodeproj'
project = Xcodeproj::Project.open(project_path)

project.targets.select{ |target| target.name == "Unit Tests" }.each do |target|
    target.build_phases.select{ |phase| phase.display_name == "Embed Frameworks" }.each do |phase|
        phase.files.each do |file|
            file.settings["ATTRIBUTES"].delete("CodeSignOnCopy")
        end
    end
end

project.save()

これでブランチ切り替わった後に以下の感じでフックされるように設定
xcodegen generate
pod install
no-codesign-script.rb (なぜかpost-installに入れたら上手く行かなかった🤔)

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