Provenance-Emu / Provenance

iOS & tvOS multi-emulator frontend, supporting various Atari, Bandai, NEC, Nintendo, Sega, SNK and Sony console systems… Get Started: https://wiki.provenance-emu.com |
https://provenance-emu.com
Other
5.93k stars 686 forks source link

Carthage bootstrap fails on Apple Silicon #1514

Closed philcluff closed 3 years ago

philcluff commented 3 years ago

Running ./carthage.sh bootstrap --platform iOS or ./carthage.sh bootstrap --platform tvOS results in failure on MacOS 11.2.3 running on Apple Silicon (M1 Macbook Air)

➜  Provenance git:(develop) ./carthage.sh bootstrap --platform iOS
*** Checking out SQLite.swift at "0.12.2"
*** Checking out RxRealm at "a6fa47c1ba721b19a7c6da0d629bf7f0d7271d06"
*** Checking out SteamController at "v1.2"
*** Checking out RxDataSources at "4.0.1"
*** Cloning SQLite.swift
*** Cloning SteamController
*** Cloning RxRealm
*** Cloning RxDataSources
*** Checking out RxSwift at "5.1.1"
*** Cloning RxSwift
*** Checking out Reachability.swift at "v5.0.0"
*** Cloning Reachability.swift
*** Checking out realm-cocoa at "v5.5.0"
*** Cloning realm-cocoa
*** Checking out CocoaLumberjack at "3.7.0"
*** Cloning CocoaLumberjack
*** Checking out ZipArchive at "v2.2.3"
*** Cloning ZipArchive
*** Checking out QuickTableViewController at "v1.2.4"
*** Cloning QuickTableViewController
*** xcodebuild output can be found in /var/folders/9b/xr086_2j4m58ttj3pf8xfzz40000gn/T/carthage-xcodebuild.siynSC.log
*** Downloading realm-cocoa.framework binary at "v5.5.0"
*** Downloading RxSwift.framework binary at "Catalyst.1"
***  Skipped installing RxSwift.framework binary due to the error:
    "Incompatible Swift version - framework was built with 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51) and the local version is 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)."

    Falling back to building from the source
***  Skipped installing realm-cocoa.framework binary due to the error:
    "Incompatible Swift version - framework was built with 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1) and the local version is 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)."

    Falling back to building from the source
*** Building scheme "CocoaLumberjack" in Demos.xcworkspace
A shell task (/usr/bin/xcrun lipo -create /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Intermediates.noindex/ArchiveIntermediates/CocoaLumberjack/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/CocoaLumberjack.framework/CocoaLumberjack /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Products/Release-iphonesimulator/CocoaLumberjack.framework/CocoaLumberjack -output /Users/philc/Documents/Development/Provenance/Carthage/Build/iOS/CocoaLumberjack.framework/CocoaLumberjack) failed with exit code 1:
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Intermediates.noindex/ArchiveIntermediates/CocoaLumberjack/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/CocoaLumberjack.framework/CocoaLumberjack and /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Products/Release-iphonesimulator/CocoaLumberjack.framework/CocoaLumberjack have the same architectures (arm64) and can't be in the same fat output file

Building universal frameworks with common architectures is not possible. The device and simulator slices for "CocoaLumberjack" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.
➜  Provenance git:(develop) ./carthage.sh bootstrap --platform tvOS
*** Checking out SQLite.swift at "0.12.2"
*** Checking out realm-cocoa at "v5.5.0"
*** Checking out QuickTableViewController at "v1.2.4"
*** Checking out RxRealm at "a6fa47c1ba721b19a7c6da0d629bf7f0d7271d06"
*** Checking out ZipArchive at "v2.2.3"
*** Checking out Reachability.swift at "v5.0.0"
*** Checking out RxDataSources at "4.0.1"
*** Checking out RxSwift at "5.1.1"
*** Checking out CocoaLumberjack at "3.7.0"
*** Checking out SteamController at "v1.2"
*** xcodebuild output can be found in /var/folders/9b/xr086_2j4m58ttj3pf8xfzz40000gn/T/carthage-xcodebuild.eMRmYd.log
*** Downloading realm-cocoa.framework binary at "v5.5.0"
*** Downloading RxSwift.framework binary at "Catalyst.1"
***  Skipped installing RxSwift.framework binary due to the error:
    "Incompatible Swift version - framework was built with 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51) and the local version is 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)."

    Falling back to building from the source
***  Skipped installing realm-cocoa.framework binary due to the error:
    "Incompatible Swift version - framework was built with 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1) and the local version is 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)."

    Falling back to building from the source
*** Building scheme "CocoaLumberjack" in Demos.xcworkspace
A shell task (/usr/bin/xcrun lipo -create /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Intermediates.noindex/ArchiveIntermediates/CocoaLumberjack/IntermediateBuildFilesPath/UninstalledProducts/appletvos/CocoaLumberjack.framework/CocoaLumberjack /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Products/Release-appletvsimulator/CocoaLumberjack.framework/CocoaLumberjack -output /Users/philc/Documents/Development/Provenance/Carthage/Build/tvOS/CocoaLumberjack.framework/CocoaLumberjack) failed with exit code 1:
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Intermediates.noindex/ArchiveIntermediates/CocoaLumberjack/IntermediateBuildFilesPath/UninstalledProducts/appletvos/CocoaLumberjack.framework/CocoaLumberjack and /Users/philc/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/CocoaLumberjack/3.7.0/Build/Products/Release-appletvsimulator/CocoaLumberjack.framework/CocoaLumberjack have the same architectures (arm64) and can't be in the same fat output file

Building universal frameworks with common architectures is not possible. The device and simulator slices for "CocoaLumberjack" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.

Expected:

Dependencies to be installed correctly.

Actual:

Dependency installation fails.

Reproduce:

  1. Follow https://wiki.provenance-emu.com/installation-and-usage/installing-provenance/building-from-source#setup instructions on an Apple Silicon mac
  2. Run ./carthage.sh bootstrap --platform tvOS

APP VERSION

APP SOURCE

INSTALLED BY

PLATFORM

iOS/tvOS VERSION

philcluff commented 3 years ago

Interestingly, the ./carthage.sh contains the recommended workaround: https://github.com/Carthage/Carthage/blob/master/Documentation/Xcode12Workaround.md

Trying under Rosetta now and it seems to be going better.

philcluff commented 3 years ago

This does indeed work through Rosetta, EG:

arch -x86_64 ./carthage.sh bootstrap --platform tvOS
philcluff commented 3 years ago

OK, so this worked for the initial dependency install, but then faltered on the final step of the build where carthage is invoked again:

PhaseScriptExecution Carthage /Users/philc/Library/Developer/Xcode/DerivedData/Provenance-epvxvaisnwwgdqgrbcgisfjvoish/Build/Intermediates.noindex/Provenance.build/Release-appletvos/ProvenanceTV.build/Script-0CO5J70NW5JDTTZ5BCHAVYZE.sh (in target 'ProvenanceTV' from project 'Provenance')
    cd /Users/philc/Documents/Development/Provenance
    /bin/sh -c /Users/philc/Library/Developer/Xcode/DerivedData/Provenance-epvxvaisnwwgdqgrbcgisfjvoish/Build/Intermediates.noindex/Provenance.build/Release-appletvos/ProvenanceTV.build/Script-0CO5J70NW5JDTTZ5BCHAVYZE.sh

/Users/philc/Library/Developer/Xcode/DerivedData/Provenance-epvxvaisnwwgdqgrbcgisfjvoish/Build/Intermediates.noindex/Provenance.build/Release-appletvos/ProvenanceTV.build/Script-0CO5J70NW5JDTTZ5BCHAVYZE.sh: line 2: /usr/local/bin/carthage: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code

This is because under Brew running natively on Apple Silicon, carthage would be installed at /opt/homebrew/bin/carthage as per https://docs.brew.sh/Installation:

This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon) 

I worked around it by just symlinking:

sudo ln -s /opt/homebrew/bin/carthage /usr/local/bin/carthage

And I was able to produce a working build 🎉

mrjschulte commented 3 years ago

This has been fixed and is covered in the steps detailed in: https://github.com/Provenance-Emu/Provenance/issues/1527