MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
521 stars 82 forks source link

Bug: `macos_dynamic_framework` fails to build #2722

Closed luispadron closed 10 months ago

luispadron commented 10 months ago

Description

When using a macos_dynamic_framework within a macos_application target's framework attribute the generated Xcode project fails when building the app target with:


Showing Recent Errors Only

Build target macOSLib.framework of project Integration with configuration Debug
note: Run script build phase 'Copy Bazel Outputs / Generate Bazel Dependencies (Index Build)' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'macOSLib.framework' from project 'Integration')

GenerateTAPI /Users/lpadron/Library/Developer/Xcode/DerivedData/Integration-bvjzmwsnpstwqddmgquklydydoxl/Build/Intermediates.noindex/EagerLinkingTBDs/Debug/Lib.framework/Versions/A/Lib.tbd (in target 'macOSLib.framework' from project 'Integration')
    cd /Users/lpadron/Development/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main
    /Applications/Xcode-15.0.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi stubify -isysroot /Applications/Xcode-15.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk /Users/lpadron/Library/Developer/Xcode/DerivedData/Integration-bvjzmwsnpstwqddmgquklydydoxl/Build/Intermediates.noindex/Integration.build/bazel-out/macos-arm64-min12.0-applebin_macos-darwin_arm64-dbg-ST-77d8e30e5cdb/bin/macOSApp/Source/macOSLib.framework/bin/Lib.framework/Versions/A/Lib -o /Users/lpadron/Library/Developer/Xcode/DerivedData/Integration-bvjzmwsnpstwqddmgquklydydoxl/Build/Intermediates.noindex/EagerLinkingTBDs/Debug/Lib.framework/Versions/A/Lib.tbd

error: no such file or directory: '/Users/lpadron/Library/Developer/Xcode/DerivedData/Integration-bvjzmwsnpstwqddmgquklydydoxl/Build/Intermediates.noindex/Integration.build/bazel-out/macos-arm64-min12.0-applebin_macos-darwin_arm64-dbg-ST-77d8e30e5cdb/bin/macOSApp/Source/macOSLib.framework/bin/Lib.framework/Versions/A/Lib'

no such file or directory: '/Users/lpadron/Library/Developer/Xcode/DerivedData/Integration-bvjzmwsnpstwqddmgquklydydoxl/Build/Intermediates.noindex/Integration.build/bazel-out/macos-arm64-min12.0-applebin_macos-darwin_arm64-dbg-ST-77d8e30e5cdb/bin/macOSApp/Source/macOSLib.framework/bin/Lib.framework/Versions/A/Lib'

Build failed    11/9/23, 9:50 PM    4.6 seconds

This same build target works with a normal bazel build command.

Reproduction steps

See the PR adding a macos_dynamic_framework target is failing when building macOSApp target: #2721

Expected behavior

The macos_dynamic_framework target builds successfully.

rules_xcodeproj version

main

Xcode version

15.0.0

Bazel version

main

rules_apple version

No response

rules_swift version

No response

Additional information

No response

luispadron commented 10 months ago

Seems like macos_dynamic_framework doesn't create the .framework file as expected according to: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

It's missing the Versions/A directory:

Lib.framework
├── Headers
│   └── Lib.h
├── Info.plist
├── Lib
└── Modules
    ├── Lib.swiftmodule
    └── module.modulemap
brentleyjones commented 10 months ago

Seems like macos_dynamic_framework doesn't create the .framework file as expected according to: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

So that's a rules_apple bug. We could fix it there.

I opened #2724 as a workaround for now. We want to disable that action anyway, since it's just extra overhead.

luispadron commented 10 months ago

It's actually not super clear if that's the required format or if it's an option one can use for versioned frameworks.

It looks like rules_apple has examples of versioned frameworks but only via the import rules.

If you have a better idea of the bug this might be, mind reporting it @brentleyjones?