Skip to content

Commit 5606e3b

Browse files
authored
XCFramework Changes (#220)
* XCFramework fixes; Build process updates. * Package dep update
1 parent d941847 commit 5606e3b

File tree

6 files changed

+123
-33
lines changed

6 files changed

+123
-33
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ Package.resolved
9696
# XCFramework
9797
Segment-Package_XCFramework
9898
*.zip
99+
Segment.xcframework.zip
100+
Segment.xcframework
101+
XCFrameworkOutput
102+

Package.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/segmentio/Sovran-Swift.git",
77
"state": {
88
"branch": null,
9-
"revision": "944c17d7c46bd95fc37f09136cabd172be5b413b",
10-
"version": "1.0.3"
9+
"revision": "64f3b5150c282a34af4578188dce2fd597e600e3",
10+
"version": "1.1.0"
1111
}
1212
}
1313
]

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
.package(
2424
name: "Sovran",
2525
url: "https://github.com/segmentio/Sovran-Swift.git",
26-
from: "1.0.3"
26+
from: "1.1.0"
2727
)
2828
],
2929
targets: [

Segment.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,12 @@
665665
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
666666
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
667667
SKIP_INSTALL = YES;
668+
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
669+
SUPPORTS_MACCATALYST = YES;
670+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
668671
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
669672
SWIFT_VERSION = 5.0;
673+
TARGETED_DEVICE_FAMILY = "1,2,3,4";
670674
TARGET_NAME = Segment;
671675
};
672676
name = Debug;
@@ -696,8 +700,12 @@
696700
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
697701
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
698702
SKIP_INSTALL = YES;
703+
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
704+
SUPPORTS_MACCATALYST = YES;
705+
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
699706
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
700707
SWIFT_VERSION = 5.0;
708+
TARGETED_DEVICE_FAMILY = "1,2,3,4";
701709
TARGET_NAME = Segment;
702710
};
703711
name = Release;

build.sh

Lines changed: 99 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,115 @@
11
#!/bin/zsh
22

33
# Set Project name
4-
PROJECT_NAME="Segment-Package"
4+
# These are the only variables that need to be set per-project, the rest
5+
# is very generic and should work for most things.
6+
PROJECT_NAME="Segment"
7+
SCHEME_NAME="Segment-Package"
58

6-
# set framework folder name
7-
FRAMEWORK_FOLDER_NAME="${PROJECT_NAME}_XCFramework"
9+
# Your PROJECT_NAME.xcodeproj should include schemes for
10+
# iOS
11+
# tvOS
12+
# watchOS
13+
# macOS
14+
# Mac Catalyst
815

9-
# set framework name or read it from project by this variable
10-
FRAMEWORK_NAME="Segment"
16+
XCFRAMEWORK_OUTPUT_PATH="./XCFrameworkOutput"
1117

12-
#xcframework path
13-
FRAMEWORK_PATH="${FRAMEWORK_FOLDER_NAME}/${FRAMEWORK_NAME}.xcframework"
18+
# clean up old releases
19+
echo "Removing previous ${PROJECT_NAME}.xcframework.zip"
20+
rm -rf ${PROJECT_NAME}.xcframework.zip
21+
rm -rf ${PROJECT_NAME}.xcframework
22+
rm -rf ${XCFRAMEWORK_OUTPUT_PATH}
1423

15-
# set path for iOS simulator archive
16-
SIMULATOR_ARCHIVE_PATH="${FRAMEWORK_FOLDER_NAME}/simulator.xcarchive"
24+
mkdir "${XCFRAMEWORK_OUTPUT_PATH}"
25+
echo "Created ${XCFRAMEWORK_OUTPUT_PATH}"
1726

18-
# set path for iOS device archive
19-
IOS_DEVICE_ARCHIVE_PATH="${FRAMEWORK_FOLDER_NAME}/iOS.xcarchive"
27+
# iOS Related Slices
28+
echo "Building iOS Slices ..."
29+
xcodebuild archive \
30+
-scheme "${SCHEME_NAME}" \
31+
-destination "generic/platform=iOS" \
32+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/iOS" \
33+
SKIP_INSTALL=NO \
34+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
2035

21-
# clean up old releases
22-
rm -rf Segment.xcframework.zip
23-
echo "Deleted the xcframework"
36+
xcodebuild archive \
37+
ONLY_ACTIVE_ARCH=NO \
38+
-scheme "${SCHEME_NAME}" \
39+
-destination "generic/platform=iOS Simulator" \
40+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/iOSSimulator" \
41+
SKIP_INSTALL=NO \
42+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
43+
44+
# tvOS Related Slices
45+
echo "Building tvOS Slices ..."
46+
xcodebuild archive \
47+
-scheme "${SCHEME_NAME}" \
48+
-destination "generic/platform=tvOS" \
49+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/tvOS" \
50+
SKIP_INSTALL=NO \
51+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
52+
53+
xcodebuild archive \
54+
ONLY_ACTIVE_ARCH=NO \
55+
-scheme "${SCHEME_NAME}" \
56+
-destination "generic/platform=tvOS Simulator" \
57+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/tvOSSimulator" \
58+
SKIP_INSTALL=NO \
59+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
60+
61+
# watchOS Related Slices
62+
echo "Building watchOS Slices ..."
63+
xcodebuild archive \
64+
-scheme "${SCHEME_NAME}" \
65+
-destination "generic/platform=watchOS" \
66+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/watchOS" \
67+
SKIP_INSTALL=NO \
68+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
69+
70+
xcodebuild archive \
71+
ONLY_ACTIVE_ARCH=NO \
72+
-scheme "${SCHEME_NAME}" \
73+
-destination "generic/platform=watchOS Simulator" \
74+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/watchOSSimulator" \
75+
SKIP_INSTALL=NO \
76+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
2477

25-
rm -rf "${FRAMEWORK_FOLDER_NAME}"
26-
echo "Deleted ${FRAMEWORK_FOLDER_NAME}"
78+
# macOS Related Slices
79+
echo "Building macOS Slices ..."
2780

28-
mkdir "${FRAMEWORK_FOLDER_NAME}"
29-
echo "Created ${FRAMEWORK_FOLDER_NAME}"
81+
xcodebuild archive \
82+
ONLY_ACTIVE_ARCH=NO \
83+
-scheme "${SCHEME_NAME}" \
84+
-destination "generic/platform=macOS" \
85+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/macOS" \
86+
SKIP_INSTALL=NO \
87+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
3088

31-
echo "Archiving ${FRAMEWORK_NAME}"
89+
xcodebuild archive \
90+
ONLY_ACTIVE_ARCH=NO \
91+
-scheme "${SCHEME_NAME}" \
92+
-destination "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac" \
93+
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/macOSCatalyst" \
94+
SKIP_INSTALL=NO \
95+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
3296

33-
xcodebuild archive -scheme ${PROJECT_NAME} -destination="iOS Simulator" -archivePath "${SIMULATOR_ARCHIVE_PATH}" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
97+
# Combine all the slices into XCFramework
98+
echo "Combining Slices into XCFramework ..."
99+
xcodebuild -create-xcframework \
100+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/iOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
101+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/iOSSimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
102+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/tvOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
103+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/tvOSSimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
104+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/watchOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
105+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/watchOSSimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
106+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/macOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
107+
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/macOSCatalyst.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
108+
-output "./${XCFRAMEWORK_OUTPUT_PATH}/${PROJECT_NAME}.xcframework"
34109

35-
xcodebuild archive -scheme ${PROJECT_NAME} -destination="iOS" -archivePath "${IOS_DEVICE_ARCHIVE_PATH}" -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
110+
# Zip it up!
36111

37-
#Creating XCFramework
38-
xcodebuild -create-xcframework -framework ${SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework -framework ${IOS_DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework -output "${FRAMEWORK_PATH}"
39-
rm -rf "${SIMULATOR_ARCHIVE_PATH}"
40-
rm -rf "${IOS_DEVICE_ARCHIVE_PATH}"
112+
echo "Zipping up ${PROJECT_NAME}.xcframework ..."
113+
zip -r ${PROJECT_NAME}.xcframework.zip "./${XCFRAMEWORK_OUTPUT_PATH}/${PROJECT_NAME}.xcframework"
41114

42-
zip -r Segment.xcframework.zip "${FRAMEWORK_FOLDER_NAME}/Segment.xcframework"
115+
echo "Done."

release.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
PROJECT_NAME="Analytics-Swift"
4+
PRODUCT_NAME="Segment"
5+
6+
LOWER_PRODUCT_NAME="$(echo ${PRODUCT_NAME} | tr '[:upper:]' '[:lower:]')"
7+
38
vercomp () {
49
if [[ $1 == $2 ]]
510
then
@@ -56,7 +61,7 @@ then
5661
exit 1
5762
fi
5863

59-
versionFile="./sources/Segment/Version.swift"
64+
versionFile="./sources/${PRODUCT_NAME}/Version.swift"
6065

6166
# get last line in version.swift
6267
versionLine=$(tail -n 1 $versionFile)
@@ -65,7 +70,7 @@ version=$(cut -d "=" -f2- <<< "$versionLine")
6570
# remove quotes and spaces
6671
version=$(sed "s/[' \"]//g" <<< "$version")
6772

68-
echo "Analytics-Swift current version: $version"
73+
echo "${PROJECT_NAME} current version: $version"
6974

7075
# no args, so give usage.
7176
if [ $# -eq 0 ]
@@ -113,7 +118,7 @@ echo -e "$changelog" >> $tempFile
113118
# - remove last line...
114119
sed -i '' -e '$ d' $versionFile
115120
# - add new line w/ new version
116-
echo "internal let __segment_version = \"$newVersion\"" >> $versionFile
121+
echo "internal let __${LOWER_PRODUCT_NAME}_version = \"$newVersion\"" >> $versionFile
117122

118123
# commit the version change.
119124
git commit -am "Version $newVersion" && git push
@@ -127,4 +132,4 @@ rm $tempFile
127132
./build.sh
128133

129134
# upload the release
130-
gh release upload $newVersion Segment.xcframework.zip
135+
gh release upload $newVersion ${PRODUCT_NAME}.xcframework.zip

0 commit comments

Comments
 (0)