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

Cartfile.lock emitted with incorrect dependency ordering #190

Closed
justinmakaila opened this issue Dec 2, 2014 · 12 comments · Fixed by #191
Closed

Cartfile.lock emitted with incorrect dependency ordering #190

justinmakaila opened this issue Dec 2, 2014 · 12 comments · Fixed by #191
Assignees

Comments

@justinmakaila
Copy link

This is somewhat similar to #147. I have framework that depends on another framework which uses Carthage to manage it's dependencies, i.e:

HLSKit
  |- PresentAPIClient
      |- Alamofire
      |- SwiftyJSON
      |- Swell

It successfully fetches and checks out all of the dependencies (barring the git-submodules), but then attempts to build the PresentAPIClient before SwiftyJSON and Swell.

Output:

~/W/S/HLSKit (master) $ carthage update
*** Fetching PresentAPIClient
*** Fetching Alamofire
*** Fetching SwiftyJSON
*** Fetching Swell
*** Checking out Alamofire at "1.1.2"
*** Checking out PresentAPIClient at "1.0.2"
*** Checking out Swell at "1.0"
*** Checking out SwiftyJSON at "2.1.2"
*** xcodebuild output can be found in /var/folders/pj/0_h5pbg1787dcz5j24_rs36m0000gn/T/carthage-xcodebuild.XvNuCT.log
*** Building scheme "Alamofire" in Alamofire.xcworkspace
*** Building scheme "PresentAPIClient" in PresentAPIClient.xcworkspace
// A bunch of build errors, most of which are from XCGccMakefileDependenciesParsePathsFromRuleFile

My log file highlights issues with messages reading:
use of undeclared type JSON <- The JSON type from SwiftyJSON
and
'Logger' is unavailable: cannot find Swift declaration for this class <- The logger from Swell

I've added Swell, Alamofire, and SwiftyJSON to the "Link With Binary Libraries" section of "Build Phases" (to my PresentAPIClient project), and I've also added a "Copy Files" phase with the frameworks.

I've noticed that ReactiveCocoa is used within this project, so I tried to clone it (Carthage) and run carthage update only to find that I get a very similar situation with ReactiveTask failing to build.

@jspahrsummers
Copy link
Member

I sincerely appreciate the issues you're filing, but could you please also include:

  1. The exact build errors you're receiving
  2. An example project that reproduces the issue (if possible)
  3. The steps you've taken to investigate and diagnose the issue

We want to help as much as we can, but our time is limited, so we'd like to make the most effective use of it as possible. Thank you! 🙇

@justinmakaila
Copy link
Author

Absolutely.

The build errors are contained in this log file.

You can use this project as an example, which uses this project as a dependency.

As mentioned above, I followed the instructions from the "Adding frameworks to unit tests or a framework" section of the README, which includes adding the dependencies (SwiftyJSON, Alamofire, and Swell) to my base framework (PresentAPIClient) in the "Link With Binary Libraries" section, and a new "Copy Files" build phase. I then added:

github "Present-Inc/PresentAPIClient" >= 1.0.1

to my Cartfile within HLSKit.

This is all reflected in my example project..

Let me know if you need anything else. Thanks!

@justinmakaila
Copy link
Author

Sorry, my global gitignore skipped the .lock file in EmbeddedFrameworks, adding it now.

@justinmakaila
Copy link
Author

For what it's worth, I ran carthage update in EmbeddedFrameworks, and when I dragged the .frameworks's in, I checked the "Copy items if needed" box, added the absolute paths, and then committed the results. The framework then built, and could be imported into the project.

But I don't think that's the desired effect.

@jspahrsummers jspahrsummers changed the title Using Carthage to manage dependencies within dependencies Cartfile.lock emitted with incorrect dependency ordering Dec 3, 2014
@jspahrsummers
Copy link
Member

I think I found the issue here. It looks like the Cartfile.lock within EmbeddedFrameworksContainer has an incorrect ordering. Since that ordering specifies the order in which dependencies are built, carthage build blindly follows it and—as you've seen—fails miserably.

I temporarily worked around the issue by manually reordering the top-level Cartfile.lock to reflect which projects actually need to be built before others:

github "ishkawa/Alamofire" "1.1.2"
github "Present-Inc/Swell" "1.0"
github "Present-Inc/SwiftyJSON" "2.1.2"
github "justinmakaila/EmbeddedFrameworks" "1.0"

Then I ran carthage build, and everything was successful. (Note, though, that any carthage update will clobber the order again.)

There's definitely a Carthage bug here. I'm very sorry about the trouble, but thank you for reporting it and creating a reproducible case! ❤️

@justinmakaila
Copy link
Author

That worked wonderfully on my example project, but I'm still running into similar issues in the application, I'm still getting unrecognized symbols. All of the dependencies are being built in the correct order, but they're not linking.

~/W/S/HLSKit (master) $ carthage bootstrap
*** Checking out Alamofire at "1.1.2"
*** Checking out Swell at "1.0"
*** Checking out SwiftyJSON at "2.1.2"
*** Checking out PresentAPIClient at "1.0.2"
*** xcodebuild output can be found in /var/folders/pj/0_h5pbg1787dcz5j24_rs36m0000gn/T/carthage-xcodebuild.ZNJZEo.log
*** Building scheme "Alamofire" in Alamofire.xcworkspace
*** Building scheme "Swell" in Swell.xcodeproj
*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
*** Building scheme "PresentAPIClient" in PresentAPIClient.xcodeproj
A shell task failed with exit code 65:
** BUILD FAILED **


The following build commands failed:
        Ld /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-dpqxmagvugkkdqdtasucydhgmpwn/Build/Intermediates/PresentAPIClient.build/Release-iphonesimulator/PresentAPIClient.build/Objects-normal/i386/PresentAPIClient normal i386
        Ld /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-dpqxmagvugkkdqdtasucydhgmpwn/Build/Intermediates/PresentAPIClient.build/Release-iphonesimulator/PresentAPIClient.build/Objects-normal/x86_64/PresentAPIClient normal x86_64
(2 failures)

jspahrsummers added a commit that referenced this issue Dec 4, 2014
jspahrsummers added a commit that referenced this issue Dec 4, 2014
If we have bad luck (as in #190), all our dependent nodes might get
passed in on the left-hand side, and would therefore not consider their
dependencies under the old algorithm.
@jspahrsummers jspahrsummers self-assigned this Dec 4, 2014
@jspahrsummers
Copy link
Member

Sorry, this got auto-closed because the original bug was fixed.

@justinmakaila Do you have codesigning certificates (and keys) for both iOS Development and iOS Distribution? That bit me while I was testing your example project.

@justinmakaila
Copy link
Author

Yes. Every project has the "Code Signing Identity" set to "iOS Developer" and "iOS Distribution"

Edit:
log here
^ I updated the log with the most recent output from carthage update --use-submodules --use-ssh

@jspahrsummers
Copy link
Member

The relevant errors seem to be:

ld: warning: ignoring file /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-eybdbacwubseydgpmtqolgnojoei/Build/Products/Debug-iphoneos/Alamofire.framework/Alamofire, missing required architecture x86_64 in file /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-eybdbacwubseydgpmtqolgnojoei/Build/Products/Debug-iphoneos/Alamofire.framework/Alamofire (2 slices)

ld: warning: ignoring file /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-eybdbacwubseydgpmtqolgnojoei/Build/Products/Debug-iphoneos/SwiftyJSON.framework/SwiftyJSON, missing required architecture x86_64 in file /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-eybdbacwubseydgpmtqolgnojoei/Build/Products/Debug-iphoneos/SwiftyJSON.framework/SwiftyJSON (2 slices)

ld: warning: ignoring file /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-eybdbacwubseydgpmtqolgnojoei/Build/Products/Debug-iphoneos/Swell.framework/Swell, missing required architecture x86_64 in file /Users/justinmakaila/Library/Developer/Xcode/DerivedData/PresentAPIClient-eybdbacwubseydgpmtqolgnojoei/Build/Products/Debug-iphoneos/Swell.framework/Swell (2 slices)

Off-hand, I don't know what the root cause is, and I'm afraid I don't have time to dig into it at the moment, but hopefully this narrowing-down is helpful.

/cc @Carthage/carthage in case anyone else can help further

@justinmakaila
Copy link
Author

I think I found a potential source for the issue...

I created more objects for the EmbeddedFrameworks project, and removed the "Copy Files" build phase. I created a class called Object in the EmbeddedFrameworksContainer project and added a import EmbeddedFrameworks line at it.

I ran another carthage update, and now I'm getting very similar errors that I'm getting in my main project where the project won't build.

EDIT:
I actually never removed the "Copy Files" build phase. No change.

@jspahrsummers
Copy link
Member

I just pulled justinmakaila/EmbeddedFrameworksContainer@e4813a9, and ran carthage bootstrap, which succeeded:

$ carthage bootstrap
*** Checking out Alamofire at "1.1.2"
*** Checking out Swell at "1.0"
*** Checking out SwiftyJSON at "2.1.2"
*** Checking out EmbeddedFrameworks at "1.1"
*** xcodebuild output can be found in /var/folders/bc/94873c7x4b97j9kczw008fh40000gn/T/carthage-xcodebuild.DfsJQ0.log
*** Building scheme "Alamofire" in Alamofire.xcworkspace
*** Building scheme "Swell" in Swell.xcodeproj
*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
*** Building scheme "EmbeddedFrameworks" in EmbeddedFrameworks.xcodeproj

I then opened the project and tried to build, which failed because EmbeddedFrameworks.framework didn't exist. I removed that broken reference and replaced it with a reference to Carthage.build/iOS/EmbeddedFrameworks.framework, and the error changed to:

/Users/justin/Temporary/EmbeddedFrameworksContainer/EmbeddedFrameworksContainer/Object.swift:13:17: error: use of undeclared type 'ExampleObject'
    var object: ExampleObject = ExampleObject()
                ^~~~~~~~~~~~~

This is because ExampleObject is not exported (since the default visibility is internal). Explicitly declaring the type and its constructor as public fixed the build in the EmbeddedFrameworksContainer for me.

@justinmakaila
Copy link
Author

So I scrapped every framework and artifact that was a result of Carthage (in my API application), re-linked everything, pushed it to git, pulled it in my HLSKit application, and everything built fine. Unfortunately, I can't say I know exactly what was causing my issues, but I can say that they're fixed now.

Thanks for sticking with the issue, I appreciate it.

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

Successfully merging a pull request may close this issue.

2 participants