あるXcodeプロジェクトを、Xcode 12で開き、去年ぶりにビルドする際に遭遇した問題。carthage update
に失敗した。
Build Failed
Task failed with exit code 1:
/usr/bin/xcrun lipo -create ...
This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/.../carthage-xcodebuild.xxx.log
logを確認するも、Build自体は成功しているようだった。Carthage自体のバージョンも古いだろうし、とbrew update & brew upgrade carthage
した。(0.34.0 -> 0.38.0
)
そして再度、carthage updateを試みたが、、再度失敗。
Building universal frameworks with common architectures is not possible. The device and simulator slices for "XXX" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.
というわけで、エラーメッセージに記されている、--use-xcframeworks
オプションを加えてcarthage update
してみたところ、成功した。
またこれによって、ビルドの出力先も変わるので、プロジェクト設定(例えば)などの該当するパス指定は、この新しい方を参照するよう差し替える必要がある。
従来:
Carthage/Build/iOS/XXX.framework
--use-xcframeworks付き:
Carthage/Build/XXX.xcframework
この--use-xcframeworks
により生成されるのは、従来の.frameworkでなく、.xcframeworkで、このXCFrameworkはXcode 11で導入されたバンドルタイプで、シミュレータ/実機用など複数プラットフォームのフレームワークをひとつにバンドルするものだという。
So XCFrameworks are a new way to bundle up multiple variants of your framework in a way that will work across Xcode versions going forward.
A single XCFramework can contain a variant for the simulator, and for the device.
Not done yet.
Because a single XCFramework can also contain a variant for any of the platforms that Xcode supports.
Binary Frameworks in Swift / WWDC19