Skip to content

Commit

Permalink
[dotnet] Add support for linking with Swift system libraries. Fixes x…
Browse files Browse the repository at this point in the history
…amarin#18848.

By adding the 'LinkWithSwiftSystemLibraries=true' property in a project file, we'll
now add the location of Swift's system libraries to the linker arguments.

Fixes xamarin#18848.
  • Loading branch information
rolfbjarne committed Apr 24, 2024
1 parent 5fee497 commit e8c9251
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1469,9 +1469,25 @@
_CompileNativeExecutable;
_ReidentifyDynamicLibraries;
_ComputeLinkNativeExecutableInputs;
_AddSwiftLinkerFlags;
</_LinkNativeExecutableDependsOn>
</PropertyGroup>

<Target Name="_AddSwiftLinkerFlags" Condition="'$(LinkWithSwiftSystemLibraries)' == 'true'">
<PropertyGroup>
<_SwiftTargetPlatform Condition="'$(_PlatformName)' == 'iOS' And '$(_SdkIsSimulator)' == 'true'">iphonesimulator</_SwiftTargetPlatform>
<_SwiftTargetPlatform Condition="'$(_PlatformName)' == 'iOS' And '$(_SdkIsSimulator)' != 'true'">iphoneos</_SwiftTargetPlatform>
<_SwiftTargetPlatform Condition="'$(_PlatformName)' == 'tvOS' And '$(_SdkIsSimulator)' == 'true'">appletvsimulator</_SwiftTargetPlatform>
<_SwiftTargetPlatform Condition="'$(_PlatformName)' == 'tvOS' And '$(_SdkIsSimulator)' != 'true'">appletvos</_SwiftTargetPlatform>
<_SwiftTargetPlatform Condition="'$(_PlatformName)' == 'MacCatalyst'">macosx</_SwiftTargetPlatform> <!-- yes, 'macosx' and not 'maccatalyst': even though the resulting maccatalyst directory exists, it doesn't have anything useful in it -->
<_SwiftTargetPlatform Condition="'$(_PlatformName)' == 'macOS'">macosx</_SwiftTargetPlatform>
</PropertyGroup>
<ItemGroup>
<_MainLinkerFlags Include="-L$(_SdkDevPath)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(_SwiftTargetPlatform)/" />
<_MainLinkerFlags Include="-L$(_SdkRoot)/usr/lib/swift/" />
</ItemGroup>
</Target>

<Target Name="_ComputeLinkNativeExecutableInputs" Condition="'$(IsMacEnabled)' == 'true'">
<PropertyGroup>
<_ExportedSymbolsFile Condition="'$(_ExportedSymbolsFile)' == '' and '$(_MtouchSymbolsList)' == ''">/dev/null</_ExportedSymbolsFile> <!-- nothing to export -->
Expand Down

0 comments on commit e8c9251

Please sign in to comment.