swiftlang / swift-docc-plugin

Swift Package Manager command plugin for Swift-DocC
https://swiftpackageindex.com/apple/swift-docc-plugin/1.3.0/documentation/swiftdoccplugin
Apache License 2.0
316 stars 54 forks source link

Text("Hoge", bundle: .module) fails to output static site #77

Open KC-2001MS opened 6 months ago

KC-2001MS commented 6 months ago

In the SwiftUI library, I have defined a structure that contains Text("Hoge", bundle: .module) in the body variable. In this case, the build fails when the static site is built with Makefile. If Text("Hoge", bundle: .module) is replaced with Text("Hoge"), the build succeeds. The following libraries are affected by this phenomenon. https://github.com/KC-2001MS/OnboardingUI

Note: This error occurred in all releases, including the main repository and the latest version.

Checklist

Expected behavior

The following command should output the static site of the project for the specified target in the specified path

DOCC_TARGET = hoge
DOCC_DIR = ./docs

.PHONY: docc
docc:
    swift package --allow-writing-to-directory $(DOCC_DIR) \
        generate-documentation --target $(DOCC_TARGET) \
        --disable-indexing \
        --transform-for-static-hosting \
        --hosting-base-path hoge \
        --output-path $(DOCC_DIR)

Actual behavior

Describe or copy/paste the behavior you observe.

swift package --allow-writing-to-directory ./docs \
        generate-documentation --target home \
        --disable-indexing \
        --transform-for-static-hosting \
        --hosting-base-path home \
        --output-path ./docs
warning: 'onboardingui': found 2 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    /Users/keisuke/Documents/オープンソース開発/OnboardingUI/Sources/OnboardingUI/Localizable.xcstrings
    /Users/keisuke/Documents/オープンソース開発/OnboardingUI/Sources/OnboardingUI/PrivacyInfo.xcprivacy
Building for debugging...
Build complete! (0.25s)
Generating documentation for 'OnboardingUI'...
warning: 'onboardingui': found 2 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    /Users/keisuke/Documents/オープンソース開発/OnboardingUI/Sources/OnboardingUI/Localizable.xcstrings
    /Users/keisuke/Documents/オープンソース開発/OnboardingUI/Sources/OnboardingUI/PrivacyInfo.xcprivacy
Building for debugging...
/Users/keisuke/Documents/オープンソース開発/OnboardingUI/Sources/OnboardingUI/UI/View/Parts/OnboardingButton.swift:52:39: error: type 'Bundle?' has no member 'module'
            Text("Continue", bundle: .module)
                                     ~^~~~~~
error: fatalError

error: unspecified("fatalError")
make: *** [docc] Error 1

This is the actual representation in the above repository.

Steps to Reproduce

  1. Download the following repository
  2. Check that line 52 of OnboardingButton.swift is Text("Continue", bundle: .module)
  3. Go to the folder of this repository in Terminal and execute make docc.
  4. rewrite line 52 as Text("Continue") and repeat the action in 3. Check for errors in 3 and 4, respectively.

Workaround

Temporarily rewrite Text("Hoge", bundle: .module) to Text("Hoge") when outputting a static site.

Swift-DocC Plugin Version Information

Swift-DocC plugin version: 1.3.0 1.2.0 1.1.0 1.0.0 main Swift Compiler version: swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5).

PS

My apologies if I am using this incorrectly. I would appreciate it if you could point it out to me.