KEMBAR78
`dotnet build` doesn't relink iOS native frameworks when packages are added/removed · Issue #21223 · dotnet/macios · GitHub
Skip to content

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

@bnickel

Description

@bnickel

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

Metadata

Metadata

Assignees

Labels

bugIf an issue is a bug or a pull request a bug fix

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions