winddpan / ObservationBP

Proof of concept for back-porting Observation framework to earlier iOS versions
18 stars 5 forks source link

Add tvOS support #4

Open rafcabezas opened 10 months ago

rafcabezas commented 10 months ago

Adds tvOS support to the Swift Package (tested in my project)

The main change is in the ObservationBPLock project so that the AggregatedFramework target generates a framework with tvOS support, as noted in the issue here.

SCHEME_NAME="ObservationBPLock"
FRAMEWORK_NAME="ObservationBPLock"
OUTPUT_DIC=".././ObservationBPLock/"
ARCHIVE_PATH="${BUILD_DIR}/${CONFIGURATION}"

xcodebuild archive \
    -scheme ${SCHEME_NAME} \
    -destination "generic/platform=iOS" \
    -archivePath "${ARCHIVE_PATH}/${FRAMEWORK_NAME}-iOS.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
    -scheme ${SCHEME_NAME} \
    -destination "generic/platform=iOS Simulator" \
    -archivePath "${ARCHIVE_PATH}/${FRAMEWORK_NAME}-iOS_Simulator.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
    -scheme ${SCHEME_NAME} \
    -destination "generic/platform=tvOS" \
    -archivePath "${ARCHIVE_PATH}/${FRAMEWORK_NAME}-tvOS.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
    -scheme ${SCHEME_NAME} \
    -destination "generic/platform=tvOS Simulator" \
    -archivePath "${ARCHIVE_PATH}/${FRAMEWORK_NAME}-tvOS_Simulator.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
    -scheme ${SCHEME_NAME} \
    -destination "generic/platform=macOS" \
    -archivePath "${ARCHIVE_PATH}/${FRAMEWORK_NAME}-macOS.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive \
    -scheme ${SCHEME_NAME} \
    -destination "generic/platform=macOS,variant=Mac Catalyst" \
    -archivePath "${ARCHIVE_PATH}/${FRAMEWORK_NAME}-Mac_Catalyst.xcarchive" \
    SKIP_INSTALL=NO \
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES

rm -rf "${OUTPUT_DIC}"

xcodebuild -create-xcframework \
    -framework ${ARCHIVE_PATH}/${FRAMEWORK_NAME}-iOS.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
    -framework ${ARCHIVE_PATH}/${FRAMEWORK_NAME}-iOS_Simulator.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
    -framework ${ARCHIVE_PATH}/${FRAMEWORK_NAME}-tvOS.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
    -framework ${ARCHIVE_PATH}/${FRAMEWORK_NAME}-tvOS_Simulator.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
    -framework ${ARCHIVE_PATH}/${FRAMEWORK_NAME}-macOS.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
    -framework ${ARCHIVE_PATH}/${FRAMEWORK_NAME}-Mac_Catalyst.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
    -output ${OUTPUT_DIC}/${FRAMEWORK_NAME}.xcframework