Charts: Building via Carthage with BUILD_LIBRARY_FOR_DISTRIBUTION = YES fails
- I’ve read, understood, and done my best to follow the *CONTRIBUTING guidelines.
What did you do?
Attempted to build Charts 4.1.0 via Carthage with BUILD_LIBRARY_FOR_DISTRIBUTION set to YES. The following script was used:
# 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
echo 'BUILD_LIBRARY_FOR_DISTRIBUTION = YES' >> $xcconfig
export XCODE_XCCONFIG_FILE="$xcconfig"
carthage "$@"
This script was invoked via: ./carthage.sh bootstrap --platform iOS --use-xcframeworks
What did you expect to happen?
Charts to build.
What happened instead?
The build failed, with errors stemming from the Swift Algorithms package.
Charts Environment
Charts version/Branch/Commit Number: 4.1.0 Xcode version: 14.0 Swift version: 5.7 Platform(s) running Charts: iOS 13 and above macOS version running Xcode: macOS 12.5 and above
Demo Project
N/A (carthage.sh script above)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (6 by maintainers)
we are also using Charts in a Swift framework via Cocoapods. we have to turn on BUILD_LIBRARY_FOR_DISTRIBUTION. Chart is blocking us to use v4.* because of the SwiftAlgorithms dependency. without v4.1.0, we can’t use Charts in Xcode 14. Please provide a solution.
@pmairoldi We distribute a pre-built binary framework that depends on Charts (among other libraries), which we ask our users to pull in via Cocoapods or Carthage. Unfortunately, while our clients can choose between either package manager for Charts and the other dependencies, the build process for our framework is staunchly reliant on Carthage.
The only other alternative here is for us to disable
BUILD_LIBRARY_FOR_DISTRIBUTIONin our own framework, which we very much want to avoid.@matopeto That workflow is not going to be practical for most folks, and I would generally regard it as bad developer experience. Unforunately, I’m sad to say that https://github.com/danielgindi/Charts/pull/4912 is not a hollistic fix for this problem.
As stated above, the root of the problem here is in the interplay with Algorithms. We can either update Algorithms directly, or remove it from Charts altogether. After perusing the Charts codebase a bit, the latter might be the more practical option, since Algorithms is only used in a small handful of spots.