pointfreeco / swift-navigation

Bringing simple and powerful navigation tools to all Swift platforms, inspired by SwiftUI.
http://pointfree.co
MIT License
1.99k stars 127 forks source link

Docc compilation error #55

Closed PierreCapo closed 1 year ago

PierreCapo commented 1 year ago

Hello, I am trying to build the documentation of my app (Product -> Build Documentation). However, it fails to compile for the _SwiftUINavigationState target in this project. image.

It looks like it is working for other TCA libraries, just this target in particular has this problem.

gasigo commented 1 year ago

I have the same problem with every framework that depends on this package. Is there anyone looking at this problem?

gasigo commented 1 year ago

Just for reference, it's impossible to build documentation for any target that uses this package.

tgrapperon commented 1 year ago

Hey @gasigo! Can you extract a repro (ideally) or tell us more about the way you're setting up your project, I'm not managing to reproduce the issue with various configurations I tried.

gasigo commented 1 year ago

Hey @gasigo! Can you extract a repro (ideally) or tell us more about the way you're setting up your project, I'm not managing to reproduce the issue with various configurations I tried.

Hey, @tgrapperon. We have a large project structure, so it'd be hard to replicate it on a sample project. But just so you have a better idea, we're using Tuist for an iOS project which is structured somewhat like this:

We're adding swift-composable-architecture as a SPM package using Tuist as well. The composable architecture package is being imported in multiple targets across the workspace and every place where it's used we see the same failure when generating documentation.

mbrandonw commented 1 year ago

FWIW I was able to build documentation for isowords, which is a large, modularized application. Perhaps this has something to do with Truist? Maybe you can try starting a project from scratch using Truist and see at what point documentation stops building.

PierreCapo commented 1 year ago

Now that I read it again, sorry for not adding more information in my first post. @gasigo that is funny because we are also using Tuist on our project too, so as @mbrandonw said we should probably look on Tuist side then 👍.

gasigo commented 1 year ago

We sure can try to start a project from scratch using Tuist, but given this is the only package with this problem, it's unlikely to be a problem on Tuist, but rather something that Tuist is making visible.

tgrapperon commented 1 year ago

This is likely related to the dynamic frameworks Tuist usually builds. This is not the norm when working with SwiftPM which defaults to static libraries. This is maybe something that should be handled from Tuist, or maybe by swiftui-navigation. It would be clearer with a repro.

gasigo commented 1 year ago

@tgrapperon I've setup a sample that produce the same issue we're having in this repo: https://github.com/gasigo/tuist-swiftui-navigation-docc. Let me know if you can reproduce it as well.

tgrapperon commented 1 year ago

Great. Can you bootstrap the project and add the workspace file to the repo? I can't generate it with Tuist apparently (I'm not a regular user myself).

gasigo commented 1 year ago

Great. Can you bootstrap the project and add the workspace file to the repo? I can generate it with Tuist apparently (I'm not a regular user myself).

@tgrapperon It should be there now.

tgrapperon commented 1 year ago

Sorry to bother you again. Would it be possible to attach here a zip of the whole repo in a buildable state? I think that a few files are not committed to git and I don't really know how to regenerate them. I tried tuist generate and other similar commands without success. In its current state, any target from the workspace doesn't build.

gasigo commented 1 year ago

@tgrapperon I've managed to get a compressed version of it here: https://drive.google.com/file/d/1en4v1wkALxpVxEIY72b53VaNIuJzdUTq/view?usp=sharing, I don't think it's possible to upload a file here AFAIK. Also, I've removed the .gitignore file from the repository and pushed everything that was missing, so it might work if you update your local version, otherwise, feel free to download from the link.

tgrapperon commented 1 year ago

Yes, you can upload files here using drag and drop, but I think that the 200MB of your archive was too much for this to work (or it took too long).

I can confirm that I can reproduce the issue. I tried to create a dynamic framework that starts with an underscore, create a distinct app, dynamically link with this framework, and Xcode was able to build the documentation for this app and the framework just fine. If the issue is created by the leading underscore, it resemble to a Tuist issue then.

Otherwise, I'm not really seeing things that are exotic/different enough to create issues with this module. The internal helper it has are also used in other libraries that are building fine.

gasigo commented 1 year ago

@tgrapperon Just to confirm I understand, your assumption is that the problem is with Tuist not being able to handle a framework name that starts with an underscore, is that correct?

tgrapperon commented 1 year ago

Yes, that's my assumption (no more). This is the only thing that stands out in this case. I've tried to replicate the setup manually, and it worked. One thing we can try is to fork TCA and SwiftUINavigation, remove the underscore, and create a Tuist project that'd work with these forks (this is the part where I'm not able to help). I've pushed two no-underscore branches in my forks for you to check. You can update to your example to rely on

.package(url: "https://github.com/tgrapperon/swift-composable-architecture", branch: "no-underscore"),

Please let me know if it solves the issue.

gasigo commented 1 year ago

@tgrapperon Tested it again using the branch you created and now it works. Seems like the problem is indeed the underscore

tgrapperon commented 1 year ago

Good to know. It really seems to be a Tuist-related issue then, as we also confirmed above that Xcode is able to build the documentation of underscored frameworks and apps linking underscored frameworks.

PierreCapo commented 1 year ago

Wow interesting. I am not with a computer those days, but afterwards I will open a PR on Tuist side to fix this. Or @gasigo if you have time you can also open a PR if you got time, let me know. Thanks for the help @tgrapperon . Closing this issue 👍

gasigo commented 1 year ago

@PierreCapo I'm opening an issue on Tuist repo now. I'll link it here once it's done. Can you wait just a bit before closing it? Might help other people with the same problem to have a link to the tuist issue.

@tgrapperon Can you keep the no-underscore branch up so I can use it in the tuist issue?

gasigo commented 1 year ago

Tuist issue: https://github.com/tuist/tuist/issues/5087

ThePragmaticArt commented 1 year ago

This definitely belongs on the Tuist side of things. The source being how Tuist handles multiple platform support/deployments :(. I recently started experiencing the same issue.

danieleformichelli commented 1 year ago

JFYI: Tuist dependency manager is mapping SPM packages to Xcode targets, hence it needs to provide a bundleID. Being _ not a valid character for a bundleID, it is replacing it with -, but it looks like Xcode can't handle well bundleID starting with - 😅 Should be fixed in this Tuist PR, using . instead of - when replacing _

PierreCapo commented 1 year ago

Oh nice, thanks for the insight and the fix @danyf90 🤩