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

chore: Download the Cocoa SDK instead of building it #1854

Merged
merged 13 commits into from
Oct 21, 2024
Merged
18 changes: 0 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ jobs:
include:
- target: Android
host: ubuntu-latest
- target: iOS
host: macos-13
- target: Linux
# Build using older Linux version to preserve sdk compatibility with old GLIBC
# See discussion in https://github.com/getsentry/sentry-unity/issues/1730 for more details
host: ubuntu-20.04
- target: macOS
host: macos-13
- target: Windows
host: windows-latest
uses: ./.github/workflows/sdk.yml
Expand Down Expand Up @@ -109,20 +105,6 @@ jobs:
path: modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib
wait-timeout: 3600

- name: Download iOS SDK
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848
with:
name: iOS-sdk
path: package-dev/Plugins/iOS
wait-timeout: 3600

- name: Download macSO SDK
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848
with:
name: macOS-sdk
path: package-dev/Plugins/macOS
wait-timeout: 3600

- name: Download Linux SDK
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
run: |
if [[ "${{ inputs.target }}" == "Android" ]]; then
submodules="modules/sentry-java"
elif [[ "${{ inputs.target }}" == "iOS" || "${{ inputs.target }}" == "macOS" ]]; then
submodules="modules/sentry-cocoa"
else
submodules="modules/sentry-native"
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
include:
- name: Cocoa SDK
path: modules/sentry-cocoa
path: modules/sentry-cocoa.properties
- name: Java SDK
path: modules/sentry-java
- name: Native SDK
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ package-dev/**/TestSentryOptions.json
package-dev/Tests/Editor/TestFiles/
package-dev/Plugins/*/Sentry/crashpad_handler*

# Download cache for Cocoa SDK
modules/sentry-cocoa

# Adding .meta to control target platforms for all of our DLLs
!package-dev/**/Sentry*.dll.meta

# required to be marked as iOS only
!package-dev/**/*.framework.meta

# required to be excluded on all platforms because we don't want Unity to copy it during build
!package-dev/**/SentryNativeBridge.m.meta
!package-dev/**/SentryNativeBridgeNoOp.m.meta
Expand All @@ -60,7 +60,7 @@ sentry-unity/Assets/Editor/Sentry/
package-dev/alias-references.txt

# ignore integration test files
Samples/IntegrationTest
Samples/IntegrationTest*
unity.log

# Ignore package release
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "src/sentry-dotnet"]
path = src/sentry-dotnet
url = https://github.com/getsentry/sentry-dotnet.git
[submodule "modules/sentry-cocoa"]
path = modules/sentry-cocoa
url = https://github.com/getsentry/sentry-cocoa
[submodule "modules/sentry-java"]
path = modules/sentry-java
url = https://github.com/getsentry/sentry-java.git
Expand Down
89 changes: 44 additions & 45 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<UnityTestEditModeResultFilePath>../../artifacts/test/editmode/results.xml</UnityTestEditModeResultFilePath>
<SentryArtifactsDestination>$(RepoRoot)package-dev/Plugins/</SentryArtifactsDestination>
<!-- Cocoa -->
<SentryCocoaRoot>$(RepoRoot)modules/sentry-cocoa/</SentryCocoaRoot>
<SentryCocoaCache>$(RepoRoot)modules/sentry-cocoa/</SentryCocoaCache>
<SentryiOSArtifactsDestination>$(SentryArtifactsDestination)iOS/Sentry.xcframework~/</SentryiOSArtifactsDestination>
<SentrymacOSArtifactsDestination>$(SentryArtifactsDestination)macOS/Sentry/</SentrymacOSArtifactsDestination>
<!-- Android -->
Expand Down Expand Up @@ -108,9 +108,11 @@ Expected to exist:
<RemoveDir Directories="$(PlayerBuildPath)" />
</Target>

<Target Name="CleaniOSSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<RemoveDir Directories="$(SentryCocoaRoot)Carthage" ContinueOnError="true" />
<Target Name="CleanCocoaSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<RemoveDir Directories="$(SentryCocoaCache)" ContinueOnError="true" />
<RemoveDir Directories="$(SentryiOSArtifactsDestination)" ContinueOnError="true" />
<Delete Files="$(SentrymacOSArtifactsDestination)Sentry.dylib" ContinueOnError="true" />
<Delete Files="$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM" ContinueOnError="true" />
</Target>

<Target Name="CleanAndroidSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
Expand All @@ -119,12 +121,6 @@ Expected to exist:
<RemoveDir Directories="$(SentryAndroidArtifactsDestination)" ContinueOnError="true" />
</Target>

<Target Name="CleanmacOSSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<RemoveDir Directories="$(SentryCocoaRoot)Carthage/Build/Mac" ContinueOnError="true" />
<Delete Files="$(SentrymacOSArtifactsDestination)Sentry.dylib" ContinueOnError="true" />
<Delete Files="$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM" ContinueOnError="true" />
</Target>

<Target Name="CleanLinuxSDK" AfterTargets="Clean" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
<RemoveDir Directories="$(SentryNativeRoot)build/" ContinueOnError="true" />
<Delete Files="$(SentryLinuxArtifactsDestination)libsentry.so" ContinueOnError="true" />
Expand All @@ -142,43 +138,48 @@ Expected to exist:
<Exec Command="pwsh &quot;$(RepoRoot)scripts/download-sentry-cli.ps1&quot;"></Exec>
</Target>

<!-- Build the iOS SDK: dotnet msbuild /t:BuildiOSSDK src/Sentry.Unity -->
<Target Name="BuildiOSSDK" Condition="$([MSBuild]::IsOSPlatform('OSX'))
And '$(MSBuildProjectName)' == 'Sentry.Unity'
And (!Exists('$(SentryiOSArtifactsDestination)'))" BeforeTargets="BeforeBuild">
<Error Condition="!Exists('$(SentryCocoaRoot)')" Text="Couldn't find the Cocoa root at $(SentryCocoaRoot)."></Error>
<Message Importance="High" Text="Building Sentry iOS SDK."></Message>

<!-- Workaround to enable building the Cocoa SDK with Bitcode enabled -->
<Message Importance="High" Text="Creating xcconfig file to enable Bitcode." />
<WriteLinesToFile File="$(SentryCocoaRoot)unity.xcconfig" Lines="ENABLE_BITCODE = YES" Overwrite="true" />

<Exec WorkingDirectory="$(SentryCocoaRoot)" Command="carthage build --use-xcframeworks --no-skip-current --platform iOS --log-path $(SentryCocoaRoot)build.log" EnvironmentVariables="XCODE_XCCONFIG_FILE=unity.xcconfig" />

<!-- Itemgroup for the output Sentry.framework so we have access to '%(RecursiveDir)' when copying -->
<!-- Downloads and sets up the Cocoa SDK: dotnet msbuild /t:SetupCocoaSDK src/Sentry.Unity -->
<Target Name="SetupCocoaSDK"
Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'
And (!Exists('$(SentryiOSArtifactsDestination)') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib'))"
BeforeTargets="BeforeBuild">

<PropertyGroup>
<PropertiesContent>$([System.IO.File]::ReadAllText("$(RepoRoot)modules/sentry-cocoa.properties"))</PropertiesContent>
<CocoaVersion>$([System.Text.RegularExpressions.Regex]::Match($(PropertiesContent), 'version\s*=\s*(\d+\.\d+\.\d+)').Groups[1].Value)</CocoaVersion>
</PropertyGroup>

<Message Importance="High" Text="Setting up the Cocoa SDK version '$(CocoaVersion)'." />

<!-- Clean cache if version does not exist to get rid of old versions -->
<RemoveDir
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')"
Directories="$(SentryCocoaCache)" />

<!-- Create cache directory -->
<MakeDir Condition="!Exists('$(SentryCocoaCache)')" Directories="$(SentryCocoaCache)" />

<!-- Download the Cocoa SDK as pre-built .xcframework -->
<Exec
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip')"
Command="curl -L https://github.com/getsentry/sentry-cocoa/releases/download/$(CocoaVersion)/Sentry-Dynamic.xcframework.zip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip" />

<Exec
Condition="!Exists('$(SentryCocoaCache)Sentry-Dynamic.xcframework')"
Command="unzip -o $(SentryCocoaCache)Sentry-Dynamic-$(CocoaVersion).xcframework.zip -d $(SentryCocoaCache)" />

<!-- Set up the iOS support -->
<ItemGroup>
<iOSDeviceBuildPath Include="$(SentryCocoaRoot)Carthage/Build/Sentry.xcframework/**/*" />
<!-- Itemgroup for the output Sentry.framework so we have access to '%(RecursiveDir)' when copying -->
<xcframeworkdPath Include="$(SentryCocoaCache)/Sentry-Dynamic.xcframework/**/*" />
</ItemGroup>
<Copy SourceFiles="@(iOSDeviceBuildPath)" DestinationFiles="@(iOSDeviceBuildPath->'$(SentryiOSArtifactsDestination)%(RecursiveDir)%(Filename)%(Extension)')">
</Copy>

<Message Importance="High" Text="Deleting xcconfig file." />
<Delete Files="$(SentryCocoaRoot)unity.xcconfig" />

<Error Condition="(!Exists('$(SentryiOSArtifactsDestination)'))" Text="Failed to build the iOS SDK." />
</Target>

<!-- Build the macOS SDK: dotnet msbuild /t:BuildmacOSSDK src/Sentry.Unity -->
<Target Name="BuildmacOSSDK" BeforeTargets="BeforeBuild" Condition="$([MSBuild]::IsOSPlatform('OSX'))
And '$(MSBuildProjectName)' == 'Sentry.Unity'
And (!Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM'))">
<Error Condition="!Exists('$(SentryCocoaRoot)')" Text="Couldn't find the Cocoa root at $(SentryCocoaRoot)."></Error>
<Message Importance="High" Text="Building Sentry macOS SDK."></Message>

<Exec WorkingDirectory="$(SentryCocoaRoot)" Command="carthage build --no-skip-current --platform macOS --log-path $(SentryCocoaRoot)build.log" />
<Copy SourceFiles="@(xcframeworkdPath)" DestinationFiles="@(xcframeworkdPath->'$(SentryiOSArtifactsDestination)%(RecursiveDir)%(Filename)%(Extension)')" />
<Error Condition="(!Exists('$(SentryiOSArtifactsDestination)'))" Text="Failed to set up the iOS SDK." />

<Copy SourceFiles="$(SentryCocoaRoot)Carthage/Build/Mac/Sentry.framework/Sentry" DestinationFiles="$(SentrymacOSArtifactsDestination)Sentry.dylib" />
<Copy SourceFiles="$(SentryCocoaRoot)Carthage/Build/Mac/Sentry.framework.dSYM/Contents/Resources/DWARF/Sentry" DestinationFiles="$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM" />
<!-- Set up the macOS support -->
<Copy SourceFiles="$(SentryCocoaCache)Sentry-Dynamic.xcframework/macos-arm64_x86_64/Sentry.framework/Sentry" DestinationFiles="$(SentrymacOSArtifactsDestination)Sentry.dylib" />
<Copy SourceFiles="$(SentryCocoaCache)Sentry-Dynamic.xcframework/macos-arm64_x86_64/dSYMs/Sentry.framework.dSYM/Contents/Resources/DWARF/Sentry" DestinationFiles="$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM" />
<Error Condition="(!Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib') Or !Exists('$(SentrymacOSArtifactsDestination)Sentry.dylib.dSYM'))" Text="Failed to set up the macOS SDK." />
</Target>

<!-- Build the Android SDK: dotnet msbuild /t:BuildAndroidSDK src/Sentry.Unity -->
Expand Down Expand Up @@ -512,8 +513,6 @@ void PrintFailedTests(XElement element)

<ItemGroup>
<SDK Include="Windows"/>
<SDK Include="iOS"/>
<SDK Include="macOS"/>
<SDK Include="Android"/>
<SDK Include="Linux"/>
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion modules/sentry-cocoa
Submodule sentry-cocoa deleted from 5575af
2 changes: 2 additions & 0 deletions modules/sentry-cocoa.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = 8.37.0
repo = https://github.com/getsentry/sentry-cocoa
Loading
Loading