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

dotnet build doesn't relink iOS native frameworks when packages are added/removed #21223

Open
bnickel opened this issue Sep 11, 2024 · 1 comment
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@bnickel
Copy link

bnickel commented Sep 11, 2024

Apple platform

iOS

Framework version

net8.0-*

Affected platform version

.Net 8.0.401, Maui 8.0.82/8.0.100

Description

I have a NuGet package that includes XCFrameworks and observed a NullReferenceException when I first tried to integrate it into an app. I identified the issue as the frameworks not being linked in the native binary (i.e., they don't appear when calling otool -L AppName.app/AppName). Cleaning and rebuilding fixes the issue, but it's a kind of change I'd expect to be automatically picked up.

Steps to Reproduce

mkdir MyApp
cd MyApp
dotnet new maui
dotnet build -p:TargetFramework=net8.0-ios
otool -L ./bin/Debug/net8.0-ios/iossimulator-arm64/MyApp.app/MyApp | grep rpath
# ✅ zero lines, as expected

dotnet add MyApp.csproj package HeapInc.Maui
dotnet build -p:TargetFramework=net8.0-ios
otool -L ./bin/Debug/net8.0-ios/iossimulator-arm64/MyApp.app/MyApp | grep rpath
# ❌ zero lines, unexpected

dotnet clean
dotnet build -p:TargetFramework=net8.0-ios
otool -L ./bin/Debug/net8.0-ios/iossimulator-arm64/MyApp.app/MyApp | grep rpath
#	@rpath/HeapSwiftCore-Dynamic.framework/HeapSwiftCore-Dynamic (compatibility version 0.0.0, current version 0.0.0)
#	@rpath/HeapSwiftCoreInterfaces.framework/HeapSwiftCoreInterfaces (compatibility version 1.0.0, current version 1.0.0)
# ✅ Frameworks from HeapInc.Maui

dotnet remove MyApp.csproj package HeapInc.Maui

dotnet build -p:TargetFramework=net8.0-ios
otool -L ./bin/Debug/net8.0-ios/iossimulator-arm64/MyApp.app/MyApp | grep rpath
#	@rpath/HeapSwiftCore-Dynamic.framework/HeapSwiftCore-Dynamic (compatibility version 0.0.0, current version 0.0.0)
#	@rpath/HeapSwiftCoreInterfaces.framework/HeapSwiftCoreInterfaces (compatibility version 1.0.0, current version 1.0.0)
# ❌ Frameworks should have been removed

dotnet clean
dotnet build -p:TargetFramework=net8.0-ios
otool -L ./bin/Debug/net8.0-ios/iossimulator-arm64/MyApp.app/MyApp | grep rpath
# ✅ zero lines, as expected

Did you find any workaround?

Running dotnet clean after dotnet add and dotnet remove.

Relevant logs

No response

@rolfbjarne
Copy link
Member

I can reproduce this.

Here's a build log showing the problem:
msbuild.binlog.zip

Skipping target "_LinkNativeExecutable" because all output files are up-to-date with respect to the input files.

@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Sep 12, 2024
@rolfbjarne rolfbjarne added this to the .NET 10 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
None yet
Development

No branches or pull requests

2 participants