Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
Condition="Exists('$(SentryCocoaFramework).zip') and !Exists('$(SentryCocoaFramework)')"
Command="unzip -o $(SentryCocoaFramework).zip -d $(SentryCocoaCache) && mv $(SentryCocoaCache)Sentry-Dynamic.xcframework $(SentryCocoaFramework)" />

<!-- Invalidate any stale sanitization stamp left over from a previous extraction.
Without this, if the xcframework directory is deleted while the zip survives, the stamp
would prevent SanitizeSentryCocoaFramework from running on the freshly extracted framework. -->
<Delete Files="$(SentryCocoaFramework).sanitized.stamp" />

<!-- Make a copy of the header files before we butcher these to suite objective sharpie -->
<MakeDir Directories="$(SentryCocoaFrameworkHeaders)" />
<ItemGroup>
Expand All @@ -103,17 +108,21 @@
DependsOnTargets="_DownloadCocoaSDK;_BuildCocoaSDK;_GenerateSentryCocoaBindings;SanitizeSentryCocoaFramework"
Condition="$([MSBuild]::IsOSPlatform('OSX'))" />

<!-- Setup exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once -->
<!-- Outer build (multi-TFM): runs _SetupCocoaSDK once before MSBuild fans out to inner per-TFM builds. -->
<Target Name="SetupCocoaSDKBeforeOuterBuild" DependsOnTargets="_SetupCocoaSDK"
Condition="$([MSBuild]::IsOSPlatform('OSX'))"
BeforeTargets="DispatchToInnerBuilds" />

<!--
Inner build (single-TFM) or direct single-TFM invocation (-f flag): runs _SetupCocoaSDK as a
direct dependency, without a recursive MSBuild call. The recursive call pattern caused a circular
dependency (SetupCocoaSDK → BeforeBuild → SetupCocoaSDK) that newer MSBuild versions detect as an error.
All subtargets are idempotent, so if the outer build already ran them this is a no-op.
-->
<Target Name="SetupCocoaSDK"
DependsOnTargets="_SetupCocoaSDK"
BeforeTargets="BeforeBuild"
Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<!-- Setup exactly once: https://learn.microsoft.com/visualstudio/msbuild/run-target-exactly-once -->
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_SetupCocoaSDK" RemoveProperties="TargetFramework" />
</Target>
Condition="$([MSBuild]::IsOSPlatform('OSX'))" />

<Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" />
Expand All @@ -133,10 +142,12 @@
</Target>

<!-- Sanitize the xcframework before NativeReference resolution and packing -->
<!-- Stamp file ensures this only runs once even when invoked from multiple inner TFM builds -->
<Target Name="SanitizeSentryCocoaFramework"
Condition="$([MSBuild]::IsOSPlatform('OSX')) and Exists('$(SentryCocoaFramework)')">
Condition="$([MSBuild]::IsOSPlatform('OSX')) and Exists('$(SentryCocoaFramework)') and !Exists('$(SentryCocoaFramework).sanitized.stamp')">
<Message Importance="High" Text="Sanitizing $(SentryCocoaFramework): removing dSYMs, Headers, Modules, PrivateHeaders (including symlinks)." />
<Exec Command="find &quot;$(SentryCocoaFramework)&quot; -depth \( -name dSYMs -o -name Headers -o -name Modules -o -name PrivateHeaders \) -exec echo Removing {} \; -exec rm -rf {} + 2&gt;/dev/null || true" />
<Touch Files="$(SentryCocoaFramework).sanitized.stamp" AlwaysCreate="true" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: just to be sure ... this file doesn't get packed or published when an app is built, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the framework directory/file is specified here:

<SentryCocoaFramework>$(SentryCocoaCache)Sentry-$(SentryCocoaVersion).xcframework</SentryCocoaFramework>

By appending .sanitized.stamp we effectively end up with a stamp file beside that directory/file.

</Target>

<!-- Workaround for https://github.com/xamarin/xamarin-macios/issues/15299 -->
Expand Down
Loading