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

Add mergeable libraries support to dynamic libraries #4381

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
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