Skip to content

Commit 51a500b

Browse files
committed
Fixed dynamic target for Carthage
* Removed VALID_ARCHS for all targets in Xcode. Only ARCHS should be set. * Removed all overrides per target. Going forward only set ARCHS on the root "OneSignal" project. * build_fat_framework.sh - Added VALID_ARCHS=x86_64h as a special case for build Catalyst - Added `file` output so we can verify the fat framework contains everything.
1 parent cb0e6ba commit 51a500b

File tree

3 files changed

+86
-27
lines changed

3 files changed

+86
-27
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@
11941194
);
11951195
runOnlyForDeploymentPostprocessing = 0;
11961196
shellPath = /bin/sh;
1197-
shellScript = "/bin/sh ${SRCROOT}/build_fat_framework.sh\n";
1197+
shellScript = "/bin/sh ${SRCROOT}/build_dynamic_framework.sh\n";
11981198
};
11991199
/* End PBXShellScriptBuildPhase section */
12001200

@@ -1452,6 +1452,7 @@
14521452
"$(ARCHS_STANDARD)",
14531453
armv7s,
14541454
x86_64h,
1455+
x86_64,
14551456
);
14561457
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
14571458
CLANG_CXX_LIBRARY = "libc++";
@@ -1488,17 +1489,12 @@
14881489
);
14891490
SDKROOT = iphoneos;
14901491
VALIDATE_PRODUCT = YES;
1491-
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64h";
14921492
};
14931493
name = Release;
14941494
};
14951495
CA2951B72167F4120064227A /* Release */ = {
14961496
isa = XCBuildConfiguration;
14971497
buildSettings = {
1498-
ARCHS = (
1499-
"$(ARCHS_STANDARD)",
1500-
x86_64h,
1501-
);
15021498
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
15031499
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
15041500
CLANG_ENABLE_CODE_COVERAGE = NO;
@@ -1512,17 +1508,12 @@
15121508
OTHER_LDFLAGS = "";
15131509
PRODUCT_NAME = OneSignal;
15141510
SKIP_INSTALL = NO;
1515-
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64h";
15161511
};
15171512
name = Release;
15181513
};
15191514
CA2951B82167F4120064227A /* Release */ = {
15201515
isa = XCBuildConfiguration;
15211516
buildSettings = {
1522-
ARCHS = (
1523-
"$(ARCHS_STANDARD)",
1524-
x86_64h,
1525-
);
15261517
CLANG_ANALYZER_NONNULL = YES;
15271518
CLANG_ENABLE_CODE_COVERAGE = NO;
15281519
CLANG_ENABLE_MODULES = YES;
@@ -1581,7 +1572,6 @@
15811572
CA2951BA2167F4120064227A /* Release */ = {
15821573
isa = XCBuildConfiguration;
15831574
buildSettings = {
1584-
ARCHS = "$(ARCHS_STANDARD)";
15851575
CODE_SIGN_STYLE = Automatic;
15861576
DEVELOPMENT_TEAM = 4ZR3G6ZK9T;
15871577
ONESIGNAL_DESTINATION_PATH = "${SRCROOT}/Framework/Dynamic";
@@ -1595,7 +1585,6 @@
15951585
CA2951C12167F9860064227A /* Release */ = {
15961586
isa = XCBuildConfiguration;
15971587
buildSettings = {
1598-
ARCHS = "$(ARCHS_STANDARD)";
15991588
CODE_SIGN_STYLE = Automatic;
16001589
DEVELOPMENT_TEAM = 4ZR3G6ZK9T;
16011590
ONESIGNAL_DESTINATION_PATH = "${SRCROOT}/Framework";
@@ -1614,6 +1603,7 @@
16141603
"$(ARCHS_STANDARD)",
16151604
armv7s,
16161605
x86_64h,
1606+
x86_64,
16171607
);
16181608
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
16191609
CLANG_CXX_LIBRARY = "libc++";
@@ -1650,17 +1640,12 @@
16501640
);
16511641
SDKROOT = iphoneos;
16521642
VALIDATE_PRODUCT = YES;
1653-
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64h";
16541643
};
16551644
name = Debug;
16561645
};
16571646
CA2951C32167FB950064227A /* Debug */ = {
16581647
isa = XCBuildConfiguration;
16591648
buildSettings = {
1660-
ARCHS = (
1661-
"$(ARCHS_STANDARD)",
1662-
x86_64h,
1663-
);
16641649
CLANG_ANALYZER_GCD_PERFORMANCE = YES;
16651650
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
16661651
CLANG_ENABLE_CODE_COVERAGE = NO;
@@ -1674,17 +1659,12 @@
16741659
OTHER_LDFLAGS = "";
16751660
PRODUCT_NAME = OneSignal;
16761661
SKIP_INSTALL = NO;
1677-
VALID_ARCHS = "arm64 arm64e armv7 armv7s x86_64h";
16781662
};
16791663
name = Debug;
16801664
};
16811665
CA2951C42167FB950064227A /* Debug */ = {
16821666
isa = XCBuildConfiguration;
16831667
buildSettings = {
1684-
ARCHS = (
1685-
"$(ARCHS_STANDARD)",
1686-
x86_64h,
1687-
);
16881668
CLANG_ANALYZER_NONNULL = YES;
16891669
CLANG_ENABLE_CODE_COVERAGE = NO;
16901670
CLANG_ENABLE_MODULES = YES;
@@ -1743,7 +1723,6 @@
17431723
CA2951C62167FB950064227A /* Debug */ = {
17441724
isa = XCBuildConfiguration;
17451725
buildSettings = {
1746-
ARCHS = "$(ARCHS_STANDARD)";
17471726
CODE_SIGN_STYLE = Automatic;
17481727
DEVELOPMENT_TEAM = 4ZR3G6ZK9T;
17491728
ONESIGNAL_DESTINATION_PATH = "${SRCROOT}/Framework/Dynamic";
@@ -1757,7 +1736,6 @@
17571736
CA2951C72167FB950064227A /* Debug */ = {
17581737
isa = XCBuildConfiguration;
17591738
buildSettings = {
1760-
ARCHS = "$(ARCHS_STANDARD)";
17611739
CODE_SIGN_STYLE = Automatic;
17621740
DEVELOPMENT_TEAM = 4ZR3G6ZK9T;
17631741
ONESIGNAL_DESTINATION_PATH = "${SRCROOT}/Framework";
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Generates a universal/fat framework that can be used in multiple architectures (x86_64 and arm64) to support both simulator and actual devices.
2+
# Note: When complete, this build script takes the fat framework and moves it to the {project root}/iOS_SDK/OneSignalSDK/Framework folder
3+
#
4+
# INPUT ENVIRONMENTAL VARIABLES (set in Xcode project settings for our Aggregate targets)
5+
# $ONESIGNAL_DESTINATION_PATH: The path where the final fat framework should be copied to
6+
# eg: ${SRCROOT}/Framework
7+
#
8+
# $ONESIGNAL_OUTPUT_NAME: The name of the framework produced (ie. {OneSignal}.framework)
9+
#
10+
# $ONESIGNAL_TARGET_NAME: The name of the actual Xcode target that produces the framework
11+
#
12+
# #ONESIGNAL_MACH_O_TYPE: Determines if the project is build as a static or dynamic library
13+
14+
set -e
15+
set -o pipefail
16+
17+
# Build x86 based framework to support iOS simulator
18+
xcodebuild -configuration "${CONFIGURATION}" -project "${PROJECT_NAME}.xcodeproj" -target ${ONESIGNAL_TARGET_NAME} -sdk "iphonesimulator${SDK_VERSION}" "${ACTION}" ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode RUN_CLANG_STATIC_ANALYZER=NO CLANG_ENABLE_MODULE_DEBUGGING=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" SYMROOT="${SYMROOT}" MACH_O_TYPE=${ONESIGNAL_MACH_O_TYPE} -UseModernBuildSystem=NO
19+
20+
# Build arm based framework to support actual iOS devices
21+
xcodebuild -configuration "${CONFIGURATION}" -project "${PROJECT_NAME}.xcodeproj" -target ${ONESIGNAL_TARGET_NAME} -sdk "iphoneos${SDK_VERSION}" "${ACTION}" ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode RUN_CLANG_STATIC_ANALYZER=NO CLANG_ENABLE_MODULE_DEBUGGING=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" SYMROOT="${SYMROOT}" MACH_O_TYPE=${ONESIGNAL_MACH_O_TYPE} -UseModernBuildSystem=NO
22+
23+
CURRENTCONFIG_DEVICE_DIR=${SYMROOT}/${CONFIGURATION}-iphoneos/${ONESIGNAL_OUTPUT_NAME}.framework
24+
CURRENTCONFIG_SIMULATOR_DIR=${SYMROOT}/${CONFIGURATION}-iphonesimulator/${ONESIGNAL_OUTPUT_NAME}.framework
25+
CREATING_UNIVERSAL_DIR=${SYMROOT}/${CONFIGURATION}-universal
26+
FINAL_FRAMEWORK_LOCATION=${CREATING_UNIVERSAL_DIR}/${ONESIGNAL_OUTPUT_NAME}.framework
27+
EXECUTABLE_DESTINATION=${FINAL_FRAMEWORK_LOCATION}/${ONESIGNAL_OUTPUT_NAME}
28+
29+
rm -rf "${CREATING_UNIVERSAL_DIR}"
30+
mkdir "${CREATING_UNIVERSAL_DIR}"
31+
32+
# copy the device framework to the location
33+
# when we use lipo to merge device/sim frameworks, it only
34+
# merges the actual binary. Thus, we need to copy all of the
35+
# Framework files (such as headers and modulemap)
36+
cp -a "${CURRENTCONFIG_DEVICE_DIR}" "${FINAL_FRAMEWORK_LOCATION}"
37+
38+
# This file gets replaced by lipo when building the fat/universal binary
39+
rm "${FINAL_FRAMEWORK_LOCATION}/${ONESIGNAL_OUTPUT_NAME}"
40+
41+
# Combine results
42+
# use lipo to combine device & simulator binaries into one
43+
lipo -create -output "${EXECUTABLE_DESTINATION}" "${CURRENTCONFIG_DEVICE_DIR}/${ONESIGNAL_OUTPUT_NAME}" "${CURRENTCONFIG_SIMULATOR_DIR}/${ONESIGNAL_OUTPUT_NAME}"
44+
45+
# Move framework files to the location Versions/A/* and create
46+
# symlinks at the root of the framework, and Versions/Current
47+
cd $FINAL_FRAMEWORK_LOCATION
48+
49+
declare -a files=("Headers" "Modules" "${ONESIGNAL_OUTPUT_NAME}")
50+
51+
# Create the Versions folders
52+
mkdir Versions
53+
mkdir Versions/A
54+
mkdir Versions/A/Resources
55+
56+
# Move the framework files/folders
57+
for name in "${files[@]}"; do
58+
mv ${name} Versions/A/${name}
59+
done
60+
61+
# Create symlinks at the root of the framework
62+
for name in "${files[@]}"; do
63+
ln -s Versions/A/${name} ${name}
64+
done
65+
66+
# move info.plist into Resources and create appropriate symlinks
67+
mv Info.plist Versions/A/Resources/Info.plist
68+
ln -s Versions/A/Resources Resources
69+
70+
# Create a symlink directory for 'Versions/A' called 'Current'
71+
cd Versions
72+
ln -s A Current
73+
74+
# Copy the built product to the final destination in {repo}/iOS_SDK/OneSignalSDK/Framework
75+
rm -rf "${ONESIGNAL_DESTINATION_PATH}/${ONESIGNAL_OUTPUT_NAME}.framework"
76+
cp -a "${FINAL_FRAMEWORK_LOCATION}" "${ONESIGNAL_DESTINATION_PATH}/${ONESIGNAL_OUTPUT_NAME}.framework"

iOS_SDK/OneSignalSDK/build_fat_framework.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ XCODEBUILD_11_0=/Applications/Xcode11.0.app/Contents/Developer/usr/bin/xcodebuil
1616
# However variant=Mac Catalyst needs to be be Xcode 11.0
1717
$XCODEBUILD_OLDEST_SUPPORTED -configuration ${BUILD_CONFIG} MACH_O_TYPE=${BUILD_TYPE} -sdk "iphonesimulator" ARCHS="x86_64" -project ${BUILD_PROJECT} -scheme ${BUILD_SCHEME} SYMROOT="${DERIVED_DATA_RELATIVE_DIR}/"
1818
$XCODEBUILD_OLDEST_SUPPORTED -configuration ${BUILD_CONFIG} MACH_O_TYPE=${BUILD_TYPE} -sdk "iphoneos" ARCHS="armv7 armv7s arm64 arm64e i386" -project ${BUILD_PROJECT} -scheme ${BUILD_SCHEME} SYMROOT="${DERIVED_DATA_RELATIVE_DIR}/"
19-
$XCODEBUILD_11_0 -configuration ${BUILD_CONFIG} ARCHS="x86_64h" -destination 'platform=macOS,variant=Mac Catalyst' MACH_O_TYPE=${BUILD_TYPE} -project ${BUILD_PROJECT} -scheme ${BUILD_SCHEME} SYMROOT="${DERIVED_DATA_RELATIVE_DIR}/"
19+
$XCODEBUILD_11_0 -configuration ${BUILD_CONFIG} ARCHS="x86_64h" VALID_ARCHS="x86_64h" -destination 'platform=macOS,variant=Mac Catalyst' MACH_O_TYPE=${BUILD_TYPE} -project ${BUILD_PROJECT} -scheme ${BUILD_SCHEME} SYMROOT="${DERIVED_DATA_RELATIVE_DIR}/"
2020

2121
USER=$(id -un)
2222
DERIVED_DATA_ONESIGNAL_DIR="${WORKING_DIR}/${DERIVED_DATA_RELATIVE_DIR}"
@@ -73,11 +73,16 @@ ln -s Versions/A/Resources Resources
7373
cd Versions
7474
ln -s A Current
7575

76+
RELEASE_OUTPUT_FRAMEWORK_DIR="${WORKING_DIR}/Framework/OneSignal.framework"
77+
7678
# Copy the built product to the final destination in {repo}/iOS_SDK/OneSignalSDK/Framework
7779
rm -rf "${WORKING_DIR}/Framework/OneSignal.framework"
7880
cp -a "${FINAL_FRAMEWORK}" "${WORKING_DIR}/Framework/OneSignal.framework"
7981

82+
echo "Listing frameworks of final framework"
83+
file "${RELEASE_OUTPUT_FRAMEWORK_DIR}/Versions/A/OneSignal"
84+
8085
echo "Opening final release framework in Finder:${WORKING_DIR}/Framework/OneSignal.framework"
81-
open ${WORKING_DIR}/Framework
86+
open "${WORKING_DIR}/Framework"
8287

8388
echo "Done"

0 commit comments

Comments
 (0)