Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ Package.resolved
# XCFramework
Segment-Package_XCFramework
*.zip
Segment.xcframework.zip
Segment.xcframework
XCFrameworkOutput

4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let package = Package(
.package(
name: "Sovran",
url: "https://github.com/segmentio/Sovran-Swift.git",
from: "1.0.3"
from: "1.1.0"
)
],
targets: [
Expand Down
8 changes: 8 additions & 0 deletions Segment.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,12 @@
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TARGET_NAME = Segment;
};
name = Debug;
Expand Down Expand Up @@ -668,8 +672,12 @@
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TARGET_NAME = Segment;
};
name = Release;
Expand Down
125 changes: 99 additions & 26 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,115 @@
#!/bin/zsh

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

# set framework folder name
FRAMEWORK_FOLDER_NAME="${PROJECT_NAME}_XCFramework"
# Your PROJECT_NAME.xcodeproj should include schemes for
# iOS
# tvOS
# watchOS
# macOS
# Mac Catalyst

# set framework name or read it from project by this variable
FRAMEWORK_NAME="Segment"
XCFRAMEWORK_OUTPUT_PATH="./XCFrameworkOutput"

#xcframework path
FRAMEWORK_PATH="${FRAMEWORK_FOLDER_NAME}/${FRAMEWORK_NAME}.xcframework"
# clean up old releases
echo "Removing previous ${PROJECT_NAME}.xcframework.zip"
rm -rf ${PROJECT_NAME}.xcframework.zip
rm -rf ${PROJECT_NAME}.xcframework
rm -rf ${XCFRAMEWORK_OUTPUT_PATH}

# set path for iOS simulator archive
SIMULATOR_ARCHIVE_PATH="${FRAMEWORK_FOLDER_NAME}/simulator.xcarchive"
mkdir "${XCFRAMEWORK_OUTPUT_PATH}"
echo "Created ${XCFRAMEWORK_OUTPUT_PATH}"

# set path for iOS device archive
IOS_DEVICE_ARCHIVE_PATH="${FRAMEWORK_FOLDER_NAME}/iOS.xcarchive"
# iOS Related Slices
echo "Building iOS Slices ..."
xcodebuild archive \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=iOS" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/iOS" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# clean up old releases
rm -rf Segment.xcframework.zip
echo "Deleted the xcframework"
xcodebuild archive \
ONLY_ACTIVE_ARCH=NO \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=iOS Simulator" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/iOSSimulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# tvOS Related Slices
echo "Building tvOS Slices ..."
xcodebuild archive \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=tvOS" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/tvOS" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
ONLY_ACTIVE_ARCH=NO \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=tvOS Simulator" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/tvOSSimulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# watchOS Related Slices
echo "Building watchOS Slices ..."
xcodebuild archive \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=watchOS" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/watchOS" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
ONLY_ACTIVE_ARCH=NO \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=watchOS Simulator" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/watchOSSimulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

rm -rf "${FRAMEWORK_FOLDER_NAME}"
echo "Deleted ${FRAMEWORK_FOLDER_NAME}"
# macOS Related Slices
echo "Building macOS Slices ..."

mkdir "${FRAMEWORK_FOLDER_NAME}"
echo "Created ${FRAMEWORK_FOLDER_NAME}"
xcodebuild archive \
ONLY_ACTIVE_ARCH=NO \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=macOS" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/macOS" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

echo "Archiving ${FRAMEWORK_NAME}"
xcodebuild archive \
ONLY_ACTIVE_ARCH=NO \
-scheme "${SCHEME_NAME}" \
-destination "generic/platform=macOS,variant=Mac Catalyst,name=Any Mac" \
-archivePath "${XCFRAMEWORK_OUTPUT_PATH}/macOSCatalyst" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive -scheme ${PROJECT_NAME} -destination="iOS Simulator" -archivePath "${SIMULATOR_ARCHIVE_PATH}" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
# Combine all the slices into XCFramework
echo "Combining Slices into XCFramework ..."
xcodebuild -create-xcframework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/iOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/iOSSimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/tvOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/tvOSSimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/watchOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/watchOSSimulator.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/macOS.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-framework ./${XCFRAMEWORK_OUTPUT_PATH}/macOSCatalyst.xcarchive/Products/Library/Frameworks/${PROJECT_NAME}.framework \
-output "./${XCFRAMEWORK_OUTPUT_PATH}/${PROJECT_NAME}.xcframework"

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

#Creating XCFramework
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}"
rm -rf "${SIMULATOR_ARCHIVE_PATH}"
rm -rf "${IOS_DEVICE_ARCHIVE_PATH}"
echo "Zipping up ${PROJECT_NAME}.xcframework ..."
zip -r ${PROJECT_NAME}.xcframework.zip "./${XCFRAMEWORK_OUTPUT_PATH}/${PROJECT_NAME}.xcframework"

zip -r Segment.xcframework.zip "${FRAMEWORK_FOLDER_NAME}/Segment.xcframework"
echo "Done."
13 changes: 9 additions & 4 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

PROJECT_NAME="Analytics-Swift"
PRODUCT_NAME="Segment"

LOWER_PRODUCT_NAME="$(echo ${PRODUCT_NAME} | tr '[:upper:]' '[:lower:]')"

vercomp () {
if [[ $1 == $2 ]]
then
Expand Down Expand Up @@ -56,7 +61,7 @@ then
exit 1
fi

versionFile="./sources/Segment/Version.swift"
versionFile="./sources/${PRODUCT_NAME}/Version.swift"

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

echo "Analytics-Swift current version: $version"
echo "${PROJECT_NAME} current version: $version"

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

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

# upload the release
gh release upload $newVersion Segment.xcframework.zip
gh release upload $newVersion ${PRODUCT_NAME}.xcframework.zip