Open luispadron opened 4 months ago
Do we maybe need something similar to: https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/2722
I tested using just macos_framework
and it fails as well:
The dylib doesn’t seem to exist in derived data. But if I copy it there manually then it works correctly
Similar to the other issue, rules_apple
is creating a framework with the wrong layout:
$ tree /Users/brentley/Developer/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main/
bazel-out/darwin_arm64-dbg-macos-arm64-min14.0-applebin_macos-ST-1fae1195bb35/bin/macOSApp/Source/Lib.framework
/Users/brentley/Developer/rules_xcodeproj/examples/integration/bazel-output-base/rules_xcodeproj.noindex/build_output_base/execroot/_main/bazel-out/darwin_arm64-dbg-macos-arm64-min14.0-applebin_macos-ST-1fae1195bb35/bin/macOSApp/Source/Lib.framework
├── Headers
│ └── Lib.h
├── Info.plist
├── Lib
└── Modules
├── Lib.swiftmodule
│ ├── arm64.swiftdoc
│ └── arm64.swiftmodule
└── module.modulemap
Once it creates macOS frameworks with the correct layout, then this will start working automatically.
Ah gotcha! Interestingly though I can't repro in the integration examples, previews work there for the macOS app
For the app it worked, but it didn't work when I added a preview to macOSLib.framework
.
@brentleyjones So I started looking at properly making frameworks for macOS with the structure described in: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html
It's a non-trivial change to the rules and while we should definitely do it, I'll likely need more help to get that change done.
In the meantime, we've been able to work around this by symlinking the framework to the expected Versions/A
path. Could rules_xcodeproj do this for us for preview builds while the rules are updated, thoughts?
We symlink the frameworks to versions in bazel-out, so we can't really modify them. Because of this I'm not sure there is an easy way for us to solve it on the rules_xcodeproj side.
I'm not opposed to doing something on this side, but anything would still have to be performant (which is what the symlink was made to address), correct, and forward compatible. If you think doing that work would be easier, I won't stop you 😁.
Description
I have a
macos_dynamic_framework
target we use for distribution, this works fine for normal builds in BwB but when trying to use previews we get the following error:Previews crash log
== DATE: Friday, February 23, 2024 at 2:37:57 PM Eastern Standard Time 2024-02-23T19:37:57Z == PREVIEW UPDATE ERROR: LinkDylibError: Failed to build AnalyticsView.swift Linking failed: no such file or directory: '/Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Products/Debug/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-8f63b8dd0af6/bin/Code/DeveloperTools/EchoPlugins/DesktopPlugins/AnalyticsDesktopPlugin.framework/Versions/A/AnalyticsDesktopPlugin' clang: error: no such file or directory: '/Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Products/Debug/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-8f63b8dd0af6/bin/Code/DeveloperTools/EchoPlugins/DesktopPlugins/AnalyticsDesktopPlugin.framework/Versions/A/AnalyticsDesktopPlugin' ================================== | BuildInvocationError | | /Users/lpadron/Development/cash-ios/Code/DeveloperTools/EchoPlugins/DesktopPlugins/EchoDesktopPlugins.xcodeproj/rules_xcodeproj/bazel/ld.sh -F /Applications/Xcode-15.1.0.app/Contents/SharedFrameworks -Xlinker -reproducible -target arm64-apple-macos13.0 -isysroot /Applications/Xcode-15.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -O0 -L/Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Intermediates.noindex/EagerLinkingTBDs/Debug -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode-15.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift @/Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Intermediates.noindex/EchoDesktopPlugins.build/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-8f63b8dd0af6/bin/Code/DeveloperTools/EchoPlugins/DesktopPlugins/AnalyticsDesktopPlugin.framework/DerivedSources/link.params /Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Products/Debug/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-8f63b8dd0af6/bin/Code/DeveloperTools/EchoPlugins/DesktopPlugins/AnalyticsDesktopPlugin.framework/Versions/A/AnalyticsDesktopPlugin /Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Intermediates.noindex/EchoDesktopPlugins.build/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-8f63b8dd0af6/bin/Code/DeveloperTools/EchoPlugins/DesktopPlugins/AnalyticsDesktopPlugin.framework/Objects-normal/arm64/AnalyticsView.1.preview-thunk.o -o /Users/lpadron/Library/Developer/Xcode/DerivedData/EchoDesktopPlugins-helyoquiuggduwgcebfpozcjrbeg/Build/Intermediates.noindex/Previews/AnalyticsDesktopPlugin/Intermediates.noindex/EchoDesktopPlugins.build/bazel-out/macos-arm64-min13.0-applebin_macos-darwin_arm64-dbg-ST-8f63b8dd0af6/bin/Code/DeveloperTools/EchoPlugins/DesktopPlugins/AnalyticsDesktopPlugin.framework/Objects-normal/arm64/AnalyticsView.1.preview-thunk.dylib -fprofile-instr-generate -client_name AnalyticsDesktopPlugin -bundle -framework SwiftUI == VERSION INFO: Tools: 15C65 OS: 23D60 PID: 65387 Model: MacBook Pro Arch: arm64e == ENVIRONMENT: openFiles = [ /Users/lpadron/Development/cash-ios/Code/DeveloperTools/EchoPlugins/DesktopPlugins/Sources/AnalyticsDesktopPlugin/AnalyticsView.swift ] wantsNewBuildSystem = true newBuildSystemAvailable = true activeScheme = AnalyticsDesktopPlugin activeRunDestination = My Mac variant macos arm64 workspaceArena = [x] buildArena = [x] buildableEntries = [ AnalyticsDesktopPlugin.framework ] runMode = Dynamic Replacement == SELECTED RUN DESTINATION: name = My Mac eligible = true sdk = Optional(Reproduction steps
xcodeproj
target with amacos_dynamic_framework
top level target#Preview { Text("Hi") }
Expected behavior
Previews work for
macos_dynamic_framework
rules_xcodeproj version
1.16.0
Xcode version
15.1
Bazel version
6.5.0
rules_apple version
No response
rules_swift version
No response
Additional information
No response