Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Building universal frameworks with common architectures is not possible." error #3146

Open
arielelkin opened this issue Mar 12, 2021 · 28 comments

Comments

@arielelkin
Copy link

arielelkin commented Mar 12, 2021

  • carthage install method: [ ] .pkg, [x] homebrew, [ ] source
  • which carthage: /usr/local/bin/carthage
  • carthage version: 0.37.0
  • xcodebuild -version: Xcode 12.4

I've added SPM support to my library, PocketSVG, but for some reason that has broken the pre-existing Carthage support.

This is what happens when I run carthage build --no-skip-current in my library's root dir:

*** xcodebuild output can be found in /var/folders/13/jh62fb214m394xbztdjkl2vm0000gn/T/carthage-xcodebuild.tIYkoX.log
*** Building scheme "PocketSVG-Package" in PocketSVG.xcodeproj
A shell task (/usr/bin/xcrun lipo -create /Users/arielelkin/Library/Developer/Xcode/DerivedData/PocketSVG-dzlvljxmlvgxeleefahougoqtbux/Build/Intermediates.noindex/ArchiveIntermediates/PocketSVG-Package/IntermediateBuildFilesPath/UninstalledProducts/appletvos/PocketSVG.framework/PocketSVG /Users/arielelkin/Library/Developer/Xcode/DerivedData/PocketSVG-dzlvljxmlvgxeleefahougoqtbux/Build/Products/Release-appletvsimulator/PocketSVG.framework/PocketSVG -output /Users/arielelkin/PocketSVG/Carthage/Build/tvOS/PocketSVG.framework/PocketSVG) failed with exit code 1:
fatal error: /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/arielelkin/Library/Developer/Xcode/DerivedData/PocketSVG-dzlvljxmlvgxeleefahougoqtbux/Build/Intermediates.noindex/ArchiveIntermediates/PocketSVG-Package/IntermediateBuildFilesPath/UninstalledProducts/appletvos/PocketSVG.framework/PocketSVG and /Users/arielelkin/Library/Developer/Xcode/DerivedData/PocketSVG-dzlvljxmlvgxeleefahougoqtbux/Build/Products/Release-appletvsimulator/PocketSVG.framework/PocketSVG 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 "PocketSVG" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.
@tmspzz
Copy link
Member

tmspzz commented Mar 15, 2021

Can you clear DerivedData and try again?

@arielelkin
Copy link
Author

Hi @tmspzz

The issue is still there after clearing DerivedData.

You can reproduce it by cloning the library:
https://github.com/pocketsvg/pocketsvg

and running carthage build --no-skip-current

@arielelkin
Copy link
Author

Hi @tmspzz Any updates? Were you able to reproduce the issue?

@tmspzz
Copy link
Member

tmspzz commented Mar 22, 2021

@arielelkin No sorry, I'm not currently looking into this

@command-tab
Copy link

command-tab commented Apr 2, 2021

I'm also encountering this while trying to build an existing project using Alamofire 5.4.1:

$ carthage build --platform iOS
*** xcodebuild output can be found in /var/folders/j3/7pf540td3xncn7jdqtb62_ph00058y/T/carthage-xcodebuild.4j9gJ4.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
A shell task (/usr/bin/xcrun lipo -create /Users/callen/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/Alamofire/4.8.1/Build/Intermediates.noindex/ArchiveIntermediates/Alamofire\ iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework/Alamofire /Users/callen/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/Alamofire/4.8.1/Build/Products/Release-iphonesimulator/Alamofire.framework/Alamofire -output /Users/callen/Projects/port80/archives-library-kiosk-app/Carthage/Build/iOS/Alamofire.framework/Alamofire) failed with exit code 1:
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/callen/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/Alamofire/4.8.1/Build/Intermediates.noindex/ArchiveIntermediates/Alamofire iOS/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Alamofire.framework/Alamofire and /Users/callen/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/Alamofire/4.8.1/Build/Products/Release-iphonesimulator/Alamofire.framework/Alamofire 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 "Alamofire" both build for: arm64
Rebuild with --use-xcframeworks to create an xcframework bundle instead.

carthage 0.37.0
macOS 10.15.7
Xcode 12.4
Intel Mac

@kmpnz
Copy link

kmpnz commented Apr 7, 2021

Hey @arielelkin. I've encountered a similar problem and it is not the perfect solution, but you can use the same workaround as described here https://github.com/Carthage/Carthage/blob/master/Documentation/Xcode12Workaround.md to fix this problem. Cheers

@Rolando-Barbella
Copy link

Rolando-Barbella commented Apr 13, 2021

I have the same issue:

carthage 0.37.0
macOS Big Sur
Xcode 12.4
Mac M1

Does it not work at all with Apple Silicon?

@byzeagle
Copy link

I have the same problem with Tesseract-OCR-iOS.

Carthage 0.37.0
macOS Big Sure
Xcode 12.4
Mac M1

@dbmrq
Copy link

dbmrq commented Apr 18, 2021

Using this script worked for me (I was using it for the original issue, tried to build without it and got this problem; went back to the script and everything worked 🤷🏻‍♂️).

@Rolando-Barbella
Copy link

@dbmrq Do you have a Mac M1?

@dbmrq
Copy link

dbmrq commented Apr 18, 2021

@dbmrq Do you have a Mac M1?

Nope!

And I just found out that while Carthage compiles the frameworks using the script I mentioned, the resulting frameworks do not work on the project with the latest version of Xcode! :(

@nfranke
Copy link

nfranke commented May 4, 2021

Same problem trying to build Alamofire.

@springlo
Copy link

springlo commented Jun 2, 2021

./carthage.sh update --platform "iOS"      

carthage.sh:

# carthage.sh
# Usage example: ./carthage.sh build --platform iOS

set -euo pipefail

xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT

# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
# the build will fail on lipo due to duplicate architectures.

CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3)
echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig

echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig
echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig

export XCODE_XCCONFIG_FILE="$xcconfig"
carthage "$@"

@gotev
Copy link

gotev commented Jun 9, 2021

The above is working with xcode 12.x. Just tried with XC13 beta on macOS 12 Monterey Beta:

Xcode 13.0
Build version 13A5154h
xcode-select version 2388. installed in /Applications/Xcode-beta.app/Contents/Developer
swift-driver version: 1.26 Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)
Target: x86_64-apple-macosx12.0

and it does not work anymore, giving lipo errors.

I tried adding also this to the temporary xcconfig but with no luck:

EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300__BUILD_13A5154h = arm64 arm64e armv7 armv7s armv6 armv8
EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))

not sure if the needed variable name still follows previously known patterns:

  • EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300
  • EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300__BUILD_13A5154h

Has anyone tried this?

code-gabriel added a commit to gamechanger/Moya that referenced this issue Jun 10, 2021
@mkotzjan
Copy link

I changed my carthage.sh to match Xcode 13 as @gotev suggested:

#!/bin/bash

# carthage.sh
# Usage example: ./carthage.sh build --platform iOS

set -euo pipefail

xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT

# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
# the build will fail on lipo due to duplicate architectures.

CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3)
echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig

echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1300__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig
echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig

export XCODE_XCCONFIG_FILE="$xcconfig"
/usr/local/bin/carthage "$@"

This worked for me on macOS 11.6 using Xcode Version 13.0 beta (13A5154h)

@gotev
Copy link

gotev commented Sep 27, 2021

I also confirm it now works on xcode 13.0

@oligazar
Copy link

oligazar commented Oct 19, 2021

Tried the version of the script of @mkotzjan with Xcode 13.0 and getting " and getting: "The file “Cartfile.resolved” couldn’t be opened because there is no such file.".

Any ideas how to overcome this?

Failed to read file or folder at /Users/Admin/Development/elie/DuoTone/materials/ios/parts/duotone-academy-ios/Cartfile.resolved: Error Domain=NSCocoaErrorDomain Code=260 "The file “Cartfile.resolved” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/Admin/Development/elie/DuoTone/materials/ios/parts/duotone-academy-ios/Cartfile.resolved, NSUnderlyingError=0x7fe7bc426900 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}```

@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 9, 2022
@command-tab
Copy link

Poke

@nrj
Copy link

nrj commented Feb 3, 2022

This is still an issue for me on an M1 Mac.

@mkotzjan
Copy link

mkotzjan commented Feb 3, 2022

This is still an issue for me on an M1 Mac.

@nrj I do not have a M1 for testing. Does the solution I posted before work for you? probably not since the architecture differs...

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
@gnachman
Copy link

This is still happening. Should I commit to using the workaround script indefinitely? Based on the ongoing breakage and the lack of recent updates, I'm concerned that Carthage may be sunset soon. Is it a good idea to begin using it?

@stale stale bot removed the stale label Apr 24, 2022
@adamlaska
Copy link

adamlaska commented Apr 26, 2022 via email

@nfranke
Copy link

nfranke commented May 17, 2022

This is still a problem with a fresh install of Xcode 13 on ARM Macs.

@gotev
Copy link

gotev commented May 17, 2022

Since my last post here, all the projects on which I'm working have been fully switched to SPM, so I sunsetted Carthage. A great experience so far with SPM. Specially from Swift 5.5 onwards, things have been vastly improved.

Carthage has been a huge part of my day by day for a long time and served its purpose very well, allowing me to have clean projects and to stick to apple standards more easily, without messing around. Carthage also made migration to SPM easier to do. A big thanks to this community and kudos to all the people which contributed to and runs this project.

@nfranke
Copy link

nfranke commented May 17, 2022

I later read the README that says "and require XCFrameworks when building on an Apple Silicon Mac" which does fix the issue (while causing others.)

@alex-fos
Copy link

Bye, Carthage! It was always a pain to use. Switching all projects to SwiftPM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests