diff --git a/.gitignore b/.gitignore index 7c800627..468bb4af 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,7 @@ Package.resolved # XCFramework Segment-Package_XCFramework *.zip +Segment.xcframework.zip +Segment.xcframework +XCFrameworkOutput + diff --git a/Package.resolved b/Package.resolved index be8d60d4..148e0e79 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/segmentio/Sovran-Swift.git", "state": { "branch": null, - "revision": "944c17d7c46bd95fc37f09136cabd172be5b413b", - "version": "1.0.3" + "revision": "64f3b5150c282a34af4578188dce2fd597e600e3", + "version": "1.1.0" } } ] diff --git a/Package.swift b/Package.swift index c5460e1c..c280e640 100644 --- a/Package.swift +++ b/Package.swift @@ -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: [ diff --git a/Segment.xcodeproj/project.pbxproj b/Segment.xcodeproj/project.pbxproj index 0041ea27..d37a1049 100644 --- a/Segment.xcodeproj/project.pbxproj +++ b/Segment.xcodeproj/project.pbxproj @@ -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; @@ -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; diff --git a/build.sh b/build.sh index a8c6f69c..21f4b154 100755 --- a/build.sh +++ b/build.sh @@ -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." diff --git a/release.sh b/release.sh index 5641e7e0..1b44863d 100755 --- a/release.sh +++ b/release.sh @@ -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 @@ -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) @@ -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 ] @@ -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 @@ -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