DynamicColor icon indicating copy to clipboard operation
DynamicColor copied to clipboard

Broken release builds – misconfigured SwiftUI dependency

Open t0rst opened this issue 5 years ago • 11 comments

Describe the bug Since v5.0.0 DynamicColor.framework does not build in release, so breaking release build of host apps. Reproducible in your own demo app.

To Reproduce Steps to reproduce the behavior:

  1. Open DynamicColorExample.xcodeproj in Xcode 11.3
  2. Select target iOSExample + Generic iOS Device
  3. Build
  4. Build of DynamicColor.framework fails with error:
~/Dev/External/Graphics/DynamicColor/Sources/SwiftUIColor.swift:30:18: error: use of undeclared type 'Color'
public extension Color {

Expected behavior build does not fail

Smartphone (please complete the following information): any

Additional context Suspect this is because the framework is not declaring correct dependency on SwiftUI.framework - needs to be added as optional linked framework. This is problematic for projects that do not want to introduce dependency on SwiftUI. Would also help if you could split your podspec into a basic that excludes SwiftUIColor.swift and a subspec that adds it for those who need it; still leaves Carthage users in a bind. Alternatively, duplicate your targets to provide with & without SwiftUI versions of the frameworks. (No plans here to adopt SwiftUI until its well past version 2.)

t0rst avatar Feb 07 '20 16:02 t0rst

Untitled 35

t0rst avatar Feb 07 '20 16:02 t0rst

For anyone suffering from this, I did a temporary fork to work around it → this added to my podfile:

# pod 'DynamicColor', '~> 5'
# ...latest podspec not yet pushed to CocoaPods/Specs.git..
# pod 'DynamicColor', :git => 'https://github.com/yannickl/DynamicColor.git', :tag => '5.0.0'
# ...5.0.0 will not build in release - https://github.com/yannickl/DynamicColor/issues/59 - so..
  pod 'DynamicColor', :git => 'https://github.com/t0rst/DynamicColor.git', :tag => '5.0.1'

t0rst avatar Apr 04 '20 14:04 t0rst

Thanks for creating the fork @t0rst - saved me when I hit this same problem.

I've be able to get the original repo working by bumping up all the deployment targets to latest (ie SwiftUI compatible) versions. It would seem the @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) at line 29 of SwiftUIColor.swift isn't working to exclude the extension during release builds. [My projects deployment target is iOS 13.4 so that shouldn't be a problem]

richardgroves avatar May 12 '20 17:05 richardgroves

Further experimenting and I can get it to build by just adjusting the iOS Deployment version to 11.0 on the DynamicColor and iOSExample targets. But I haven't tried Mac/TvOS/Watch builds.

richardgroves avatar May 12 '20 17:05 richardgroves

I have a fork of DynamicColor at https://github.com/NoodlFroot/DynamicColor that has raised the deployment target for iOS to 11.0 and now does build for iOS release configurations at least.

I'll test some more and make a pull request when happy all is ok.

richardgroves avatar May 13 '20 11:05 richardgroves

@richardgroves your fork hasn't worked for me, when trying to build for "Profile", I get the same build error (using Swift PM)

guidedways avatar May 16 '20 01:05 guidedways

Hi @guidedways - I'm not seeing this. If I build the DynamicColor iOSExample for profile it is fine, and building my project that depends on this for Profile is fine.

I'm targeting the iPad Air (3rd generation) (13.4.1) simulator and same with iPad Pro 12.9 (iOS 13.4.1) and iPhone X (iOS 13.3.1)

What is the target device / simulator of you project? Does it build ok for the 'Generic iOS Device' target?

Can you show the SwiftPM Settings used?

richardgroves avatar May 16 '20 13:05 richardgroves

@guidedways - ok, I've managed to reproduce the problem on my project that includes it via a SwiftPM dependency - before it was using a stale cache version that didn't use my fork. I'll look into why it works differently in SwiftPM dependency from the Example xcode project.

richardgroves avatar May 16 '20 13:05 richardgroves

Ok @guidedways - fixed it (I hope...!)

I had to add platforms: [.iOS(SupportedPlatform.IOSVersion.v11)] to the DynamicColour package file to limit it to iOS 11 - it seems SwiftPM will build the packages for a lower version even if the final project including it has a higher version.

.package(url: "https://github.com/NoodlFroot/DynamicColor", from: "5.0.2") should give you a good dependency.

richardgroves avatar May 16 '20 13:05 richardgroves

Update Pull request has been created that fixes the swift package version as well as CocoaPods.

richardgroves avatar May 18 '20 16:05 richardgroves

Fixed in #63, please close

grgar avatar Jun 29 '23 16:06 grgar