Skip to content

Commit

Permalink
Add mergeable libraries support to dynamic libraries (#4381)
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase authored Oct 2, 2024
1 parent e88fe9a commit fd458ae
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- Sentry.xcodeproj/**
- Gemfile.lock
- 'Package.swift'
- 'scripts/build-xcframework'
- 'scripts/build-xcframework.sh'

# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Added breadcrumb.origin private field (#4358)
- Custom redact modifier for SwiftUI (#4362)
- Add mergeable libraries support to dynamic libraries (#4381)

### Improvements

Expand Down
46 changes: 43 additions & 3 deletions scripts/build-xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ generate_xcframework() {

local resolved_configuration="Release$configuration_suffix"
local resolved_product_name="$scheme$configuration_suffix"

local OTHER_LDFLAGS=""

if [ "$MACH_O_TYPE" = "staticlib" ]; then
#For static framework we disabled symbols because they are not distributed in the framework causing warnings.
GCC_GENERATE_DEBUGGING_SYMBOLS="NO"
Expand All @@ -30,7 +31,27 @@ generate_xcframework() {
for sdk in "${sdks[@]}"; do
if grep -q "${sdk}" <<< "$ALL_SDKS"; then

xcodebuild archive -project Sentry.xcodeproj/ -scheme "$scheme" -configuration "$resolved_configuration" -sdk "$sdk" -archivePath "./Carthage/archive/${scheme}${suffix}/${sdk}.xcarchive" CODE_SIGNING_REQUIRED=NO SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CARTHAGE=YES MACH_O_TYPE="$MACH_O_TYPE" ENABLE_CODE_COVERAGE=NO GCC_GENERATE_DEBUGGING_SYMBOLS="$GCC_GENERATE_DEBUGGING_SYMBOLS"
## watchos, watchsimulator dont support make_mergeable: ld: unknown option: -make_mergeable
if [[ "$sdk" == "watchos" || "$sdk" == "watchsimulator" ]]; then
OTHER_LDFLAGS=""
elif [ "$MACH_O_TYPE" != "staticlib" ]; then
OTHER_LDFLAGS="-Wl,-make_mergeable"
fi

xcodebuild archive \
-project Sentry.xcodeproj/ \
-scheme "$scheme" \
-configuration "$resolved_configuration" \
-sdk "$sdk" \
-archivePath "./Carthage/archive/${scheme}${suffix}/${sdk}.xcarchive" \
CODE_SIGNING_REQUIRED=NO \
SKIP_INSTALL=NO \
CODE_SIGN_IDENTITY= \
CARTHAGE=YES \
MACH_O_TYPE="$MACH_O_TYPE" \
ENABLE_CODE_COVERAGE=NO \
GCC_GENERATE_DEBUGGING_SYMBOLS="$GCC_GENERATE_DEBUGGING_SYMBOLS" \
OTHER_LDFLAGS="$OTHER_LDFLAGS"

createxcframework+="-framework Carthage/archive/${scheme}${suffix}/${sdk}.xcarchive/Products/Library/Frameworks/${resolved_product_name}.framework "

Expand All @@ -55,8 +76,27 @@ generate_xcframework() {
fi
done

# for the case that watch* sdks are last in list
if [ "$MACH_O_TYPE" != "staticlib" ]; then
OTHER_LDFLAGS="-Wl,-make_mergeable"
fi

#Create framework for mac catalyst
xcodebuild -project Sentry.xcodeproj/ -scheme "$scheme" -configuration "$resolved_configuration" -sdk iphoneos -destination 'platform=macOS,variant=Mac Catalyst' -derivedDataPath ./Carthage/DerivedData CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES MACH_O_TYPE="$MACH_O_TYPE" SUPPORTS_MACCATALYST=YES ENABLE_CODE_COVERAGE=NO GCC_GENERATE_DEBUGGING_SYMBOLS="$GCC_GENERATE_DEBUGGING_SYMBOLS"
xcodebuild \
-project Sentry.xcodeproj/ \
-scheme "$scheme" \
-configuration "$resolved_configuration" \
-sdk iphoneos \
-destination 'platform=macOS,variant=Mac Catalyst' \
-derivedDataPath ./Carthage/DerivedData \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY= \
CARTHAGE=YES \
MACH_O_TYPE="$MACH_O_TYPE" \
SUPPORTS_MACCATALYST=YES \
ENABLE_CODE_COVERAGE=NO \
GCC_GENERATE_DEBUGGING_SYMBOLS="$GCC_GENERATE_DEBUGGING_SYMBOLS" \
OTHER_LDFLAGS="$OTHER_LDFLAGS"

if [ "$MACH_O_TYPE" = "staticlib" ]; then
local infoPlist="Carthage/DerivedData/Build/Products/$resolved_configuration-maccatalyst/${scheme}.framework/Resources/Info.plist"
Expand Down

0 comments on commit fd458ae

Please sign in to comment.