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

Simplify linking with libraries that contain Swift code #18848

Closed
rolfbjarne opened this issue Aug 28, 2023 · 0 comments · Fixed by #20463
Closed

Simplify linking with libraries that contain Swift code #18848

rolfbjarne opened this issue Aug 28, 2023 · 0 comments · Fixed by #20463
Labels
enhancement The issue or pull request is an enhancement
Milestone

Comments

@rolfbjarne
Copy link
Member

Currently developers need to add custom linker flags if any of their third-party libraries need to link with swift.

Example code:

<Target Name="LinkWithSwift" DependsOnTargets="_ParseBundlerArguments;_DetectSdkLocations" BeforeTargets="_LinkNativeExecutable">
	<PropertyGroup>
		<_SwiftPlatform Condition="$(RuntimeIdentifier.StartsWith('iossimulator-'))">iphonesimulator</_SwiftPlatform>
		<_SwiftPlatform Condition="$(RuntimeIdentifier.StartsWith('ios-'))">iphoneos</_SwiftPlatform>
	</PropertyGroup>
	<ItemGroup>
		<_CustomLinkFlags Include="-L" />
		<_CustomLinkFlags Include="/usr/lib/swift" />
		<_CustomLinkFlags Include="-L" />
		<_CustomLinkFlags Include="$(_SdkDevPath)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(_SwiftPlatform)" />
		<_CustomLinkFlags Include="-Wl,-rpath" />
		<_CustomLinkFlags Include="-Wl,/usr/lib/swift" />
	</ItemGroup>
</Target>

Ref: #18774 (comment)

We should consider adding something like this into our product, to make it easier for everyone referencing libraries that use swift.

@rolfbjarne rolfbjarne added the enhancement The issue or pull request is an enhancement label Aug 28, 2023
@rolfbjarne rolfbjarne added this to the .NET 9 milestone Aug 28, 2023
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Apr 17, 2024
…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.
rolfbjarne added a commit that referenced this issue Apr 18, 2024
…18848. (#20463)

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 #18848.
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Apr 22, 2024
…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.
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Apr 24, 2024
…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.
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Apr 26, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue or pull request is an enhancement
Projects
None yet
1 participant