Skip to content

Commit ae3d8d9

Browse files
committed
fix cocoa build action
1 parent 2699ca2 commit ae3d8d9

File tree

3 files changed

+57
-75
lines changed

3 files changed

+57
-75
lines changed

.github/actions/buildcocoasdk/action.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@ runs:
44
using: composite
55

66
steps:
7-
8-
- name: Fetch version tags for Sentry Cocoa SDK
9-
shell: bash
10-
run: git fetch --tags --quiet
11-
working-directory: modules/sentry-cocoa
12-
13-
- name: Get Sentry Cocoa SHA
7+
8+
- name: Get submodule status
149
shell: bash
15-
run: echo "SENTRY_COCOA_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
16-
working-directory: modules/sentry-cocoa
10+
run: cat .git/modules/modules/sentry-cocoa/HEAD
1711

1812
- name: Cache Sentry Cocoa SDK
1913
id: cache-sentry-cocoa
2014
uses: actions/cache@v3
2115
with:
2216
path: modules/sentry-cocoa/Carthage
23-
key: sentry-cocoa-${{ env.SENTRY_COCOA_SHA }}
17+
key: sentry-cocoa-${{ hashFiles('scripts/build-sentry-cocoa.sh', '.git/modules/modules/sentry-cocoa/HEAD') }}
2418

2519
- name: Build Sentry Cocoa SDK
2620
if: ${{ steps.cache-sentry-cocoa.outputs.cache-hit != 'true' }}

scripts/build-sentry-cocoa.sh

Lines changed: 50 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,77 +4,64 @@ set -euo pipefail
44
pushd "$(dirname "$0")" >/dev/null
55
cd ../modules/sentry-cocoa
66

7-
SHA=$(git rev-parse HEAD)
8-
SHAFILE=./Carthage/.built-from-sha
9-
if [[ -f $SHAFILE ]]; then
10-
SHAFROMFILE=$(<$SHAFILE)
11-
else
12-
SHAFROMFILE=""
13-
fi
14-
VERSION="$(git describe --tags) ($(git rev-parse --short HEAD))"
7+
rm -rf Carthage
158

16-
if [ "$SHA" == "$SHAFROMFILE" ]; then
17-
echo "Sentry Cocoa SDK $VERSION was already built"
18-
else
19-
echo "Building Sentry Cocoa SDK $VERSION"
20-
rm -rf Carthage
9+
# Grabbing the first SDK versions
10+
sdks=$(xcodebuild -showsdks)
11+
ios_sdk=$(echo "$sdks" | awk '/iOS SDKs/{getline; print $NF}')
12+
ios_simulator_sdk=$(echo "$sdks" | awk '/iOS Simulator SDKs/{getline; print $NF}')
13+
macos_sdk=$(echo "$sdks" | awk '/macOS SDKs/{getline; print $NF}')
2114

22-
# Grabbing the first SDK versions
23-
sdks=$(xcodebuild -showsdks)
24-
ios_sdk=$(echo "$sdks" | awk '/iOS SDKs/{getline; print $NF}')
25-
ios_simulator_sdk=$(echo "$sdks" | awk '/iOS Simulator SDKs/{getline; print $NF}')
26-
macos_sdk=$(echo "$sdks" | awk '/macOS SDKs/{getline; print $NF}')
15+
# Note - We keep the build output in separate directories so that .NET
16+
# bundles iOS with net6.0-ios and Mac Catalyst with net6.0-maccatalyst.
17+
# The lack of symlinks in the ios builds, means we should also be able
18+
# to use the package on Windows with "Pair to Mac".
2719

28-
# Note - We keep the build output in separate directories so that .NET
29-
# bundles iOS with net6.0-ios and Mac Catalyst with net6.0-maccatalyst.
30-
# The lack of symlinks in the ios builds, means we should also be able
31-
# to use the package on Windows with "Pair to Mac".
20+
# Build for iOS and iOS simulator.
21+
xcodebuild -project Sentry.xcodeproj \
22+
-scheme Sentry \
23+
-configuration Release \
24+
-sdk "$ios_sdk" \
25+
-derivedDataPath ./Carthage/output-ios
26+
xcodebuild -project Sentry.xcodeproj \
27+
-scheme Sentry \
28+
-configuration Release \
29+
-sdk "$ios_simulator_sdk" \
30+
-derivedDataPath ./Carthage/output-ios
31+
xcodebuild -create-xcframework \
32+
-framework ./Carthage/output-ios/Build/Products/Release-iphoneos/Sentry.framework \
33+
-framework ./Carthage/output-ios/Build/Products/Release-iphonesimulator/Sentry.framework \
34+
-output ./Carthage/Build-ios/Sentry.xcframework
3235

33-
# Build for iOS and iOS simulator.
34-
xcodebuild -project Sentry.xcodeproj \
35-
-scheme Sentry \
36-
-configuration Release \
37-
-sdk "$ios_sdk" \
38-
-derivedDataPath ./Carthage/output-ios
39-
xcodebuild -project Sentry.xcodeproj \
40-
-scheme Sentry \
41-
-configuration Release \
42-
-sdk "$ios_simulator_sdk" \
43-
-derivedDataPath ./Carthage/output-ios
44-
xcodebuild -create-xcframework \
45-
-framework ./Carthage/output-ios/Build/Products/Release-iphoneos/Sentry.framework \
46-
-framework ./Carthage/output-ios/Build/Products/Release-iphonesimulator/Sentry.framework \
47-
-output ./Carthage/Build-ios/Sentry.xcframework
36+
# Build for macOS.
37+
xcodebuild -project Sentry.xcodeproj \
38+
-scheme Sentry \
39+
-configuration Release \
40+
-sdk "$macos_sdk" \
41+
-derivedDataPath ./Carthage/output-macos
42+
xcodebuild -create-xcframework \
43+
-framework ./Carthage/output-macos/Build/Products/Release/Sentry.framework \
44+
-output ./Carthage/Build-macos/Sentry.xcframework
4845

49-
# Build for macOS.
50-
xcodebuild -project Sentry.xcodeproj \
51-
-scheme Sentry \
52-
-configuration Release \
53-
-sdk "$macos_sdk" \
54-
-derivedDataPath ./Carthage/output-macos
55-
xcodebuild -create-xcframework \
56-
-framework ./Carthage/output-macos/Build/Products/Release/Sentry.framework \
57-
-output ./Carthage/Build-macos/Sentry.xcframework
46+
# Separately, build for Mac Catalyst
47+
xcodebuild -project Sentry.xcodeproj \
48+
-scheme Sentry \
49+
-configuration Release \
50+
-destination 'platform=macOS,variant=Mac Catalyst' \
51+
-derivedDataPath ./Carthage/output-maccatalyst
52+
xcodebuild -create-xcframework \
53+
-framework ./Carthage/output-maccatalyst/Build/Products/Release-maccatalyst/Sentry.framework \
54+
-output ./Carthage/Build-maccatalyst/Sentry.xcframework
5855

59-
# Separately, build for Mac Catalyst
60-
xcodebuild -project Sentry.xcodeproj \
61-
-scheme Sentry \
62-
-configuration Release \
63-
-destination 'platform=macOS,variant=Mac Catalyst' \
64-
-derivedDataPath ./Carthage/output-maccatalyst
65-
xcodebuild -create-xcframework \
66-
-framework ./Carthage/output-maccatalyst/Build/Products/Release-maccatalyst/Sentry.framework \
67-
-output ./Carthage/Build-maccatalyst/Sentry.xcframework
68-
69-
# Copy headers - used for generating bindings
70-
mkdir Carthage/Headers
71-
find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Carthage/Headers \;
72-
73-
echo "$SHA" >"$SHAFILE"
74-
echo ""
75-
fi
56+
# Copy headers - used for generating bindings
57+
mkdir Carthage/Headers
58+
find Carthage/Build-ios/Sentry.xcframework/ios-arm64 -name '*.h' -exec cp {} Carthage/Headers \;
7659

7760
# Remove anything we don't want to bundle in the nuget package.
7861
find Carthage/Build* \( -name Headers -o -name PrivateHeaders -o -name Modules \) -exec rm -rf {} +
62+
rm -rf Carthage/output-*
63+
64+
cp ../../.git/modules/modules/sentry-cocoa/HEAD Carthage/.built-from-sha
65+
echo ""
7966

8067
popd >/dev/null

src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@
4646

4747
<!-- Build the Sentry Cocoa SDK -->
4848
<Target Name="_BuildSentryCocoaSDK" BeforeTargets="DispatchToInnerBuilds;BeforeBuild" Condition="$([MSBuild]::IsOSPlatform('OSX'))"
49-
Inputs="..\..\.git\modules\modules\sentry-cocoa\HEAD" Outputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha">
49+
Inputs="../../.git/modules/modules/sentry-cocoa/HEAD" Outputs="../../modules/sentry-cocoa/Carthage/.built-from-sha">
5050
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerBuildSentryCocoaSDK" Properties="TargetFramework=once" />
5151
</Target>
5252
<Target Name="_InnerBuildSentryCocoaSDK">
5353
<Exec Command="../../scripts/build-sentry-cocoa.sh" />
54+
<Copy SourceFiles="../../.git/modules/modules/sentry-cocoa/HEAD" DestinationFolder="../../modules/sentry-cocoa/Carthage/.built-from-sha"/>
5455
</Target>
5556

5657
<!-- Generate bindings -->
5758
<Target Name="_GenerateSentryCocoaBindings" AfterTargets="_BuildSentryCocoaSDK" Condition="$([MSBuild]::IsOSPlatform('OSX'))"
58-
Inputs="..\..\modules\sentry-cocoa\Carthage\.built-from-sha" Outputs="ApiDefinitions.cs;StructsAndEnums.cs">
59+
Inputs="../../modules/sentry-cocoa/Carthage/.built-from-sha" Outputs="ApiDefinitions.cs;StructsAndEnums.cs">
5960
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerGenerateSentryCocoaBindings" Properties="TargetFramework=once" />
6061
</Target>
6162
<Target Name="_InnerGenerateSentryCocoaBindings">

0 commit comments

Comments
 (0)