Promisekit: Xcode 9 complains about dependency cycle in PromiseKit when using New Build System

Created on 13 Oct 2017  路  17Comments  路  Source: mxcl/PromiseKit

  • PromiseKit version: 4.4.0
  • Xcode version: 9.0, 9.1 beta 2
  • CocoaPods version: 1.3.1

When I change the build system for of my workspace to New Build System sometimes Xcode fails to build because it thinks it detected a dependency cycle and outputs the following error:

Showing All Issues
:-1: Dependency cycle detected between targets: 

target PromiseKit: CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler ->

node: /Users/user/Library/Developer/Xcode/DerivedData/App-bmiqkyncwgjbltanitqpzqehdaor/Build/Products/DebugDevServerAlt-iphonesimulator/PromiseKit/PromiseKit.framework/Headers/PromiseKit-Swift.h ->

target PromiseKit: Ditto /Users/user/Library/Developer/Xcode/DerivedData/App-bmiqkyncwgjbltanitqpzqehdaor/Build/Products/DebugDevServerAlt-iphonesimulator/PromiseKit/PromiseKit.framework/Headers/PromiseKit-Swift.h /Users/user/Library/Developer/Xcode/DerivedData/App-bmiqkyncwgjbltanitqpzqehdaor/Build/Intermediates.noindex/Pods.build/DebugDevServerAlt-iphonesimulator/PromiseKit.build/Objects-normal-asan/x86_64/PromiseKit-Swift.h ->

node: /Users/user/Library/Developer/Xcode/DerivedData/App-bmiqkyncwgjbltanitqpzqehdaor/Build/Intermediates.noindex/Pods.build/DebugDevServerAlt-iphonesimulator/PromiseKit.build/Objects-normal-asan/x86_64/PromiseKit-Swift.h/ ->

node: /Users/user/Library/Developer/Xcode/DerivedData/App-bmiqkyncwgjbltanitqpzqehdaor/Build/Intermediates.noindex/Pods.build/DebugDevServerAlt-iphonesimulator/PromiseKit.build/Objects-normal-asan/x86_64/PromiseKit-Swift.h ->

target PromiseKit: CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler

Nodes leading to the cycle:

node: /Users/user/Library/Developer/Xcode/DerivedData/App-bmiqkyncwgjbltanitqpzqehdaor/Build/Intermediates.noindex/Pods.build/DebugDevServerAlt-iphonesimulator/PromiseKit.build/Objects-normal-asan/x86_64/PromiseKit.swiftmodule

This is probably a bug in Xcode / new build system because it doesn't happen 100% of the time. Feel free to close if PromiseKit has nothing to do with this.

All 17 comments

Indeed, PromiseKit has nothing to do with this.

Maybe CocoaPods does though.

I have the same problem. Why does it happen only in PromiseKit, though?

PMK does not define its inter module dependencies, CocoaPods and Xcode are responsible I recommend opening a bug report with one of those two entities.

Some additional information for future reference: https://twitter.com/UINT_MIN/status/917518438003703808

The failure is due to importing PromiseKit's generated Swift header within PromiseKit here.

Apparently this "isn't supported", but it's a bug in the build system that the error message isn't explicit about it.

This is documented here in the developer documentation; scroll to "Referencing a Swift Class or Protocol in an Objective-C Header".

Could the categories in AnyPromise.h potentially be rewritten in Swift to avoid this behavior?

Oh interesting.

It's been a while, but I don't think we can rewrite in Swift since we are doing objc hackery. Maybe there's a better solution though.

And yeah, well I should have known this would break stuff.

Just curious, since I (we) are very eager to try out the new build system (Swift is so slow!), is anyone trying to tackle this? I haven't dug into how this project is structured too deeply, but maybe clever use of a submodule / subframework could sidestep this issue?

I will fix this when I have time, but currently I do not.

I use Carthage with all my projects. I recommend switching if possible. It has other advantages, for example one project went from having an incremental build time in the minutes to seconds.

I don't understand why Carthage is relevant here...the cycle is actually within PromiseKit itself right?

The issue is that PromiseKit imports its own bridging header, which is not supported by the new build system. It fails to report this condition correctly though in Xcode 9.2.

https://github.com/mxcl/PromiseKit/blob/2df8580c927fe2fb173f489c1e2e7df4ff880976/Sources/AnyPromise.h#L10

Carthage pre-builds the frameworks so there can be no dependency cycle.

Edit: well I am assuming the dependency cycle is generated only when PMK is a dependency. But either way Carthage by-passes it because it doesn't use the new build system.

Obviously we will fix this, but I don't have time currently.

Fix incoming, requires use of PMK 6 though.

Will accept a back port PR.

Fixed in PMK6 that I will push to CocoaPods this afternoon.

Still getting this issue with PMK 6.2.1. Any ideas?

Upgrade. We鈥檙e up to 6.8.3 now.

This still happens in 6.8.3
Strangely enough, the compile output error message says this:
Cycle path: Account -> Core -> Contracts -> Pods-Apps-Contracts -> PromiseKit -> Account
Account, Core, and Contracts are our own targets, so it seems like Xcode's problem in thinking PromiseKit depends on Account, which it clearly does not.

Cleaning always fixes this.

Open a new ticket please.

Was this page helpful?
0 / 5 - 0 ratings