Xcode 12: carthage update --use-xcframeworks

p0dee
3 min readMay 17, 2021

--

ある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

参考: XCFrameworksに対応したCarthageを使ってみた

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response