winddpan / ObservationBP

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

tvOS support? #3

Open rafcabezas opened 8 months ago

rafcabezas commented 8 months ago

I tried using the SPM in a tvOS project, but I get an error that no library for the platform is found in the ObservationBPLock.xcframework. I tried to modify the project sources by adding a tvOS target to the demo app, and I get the same error:

.../ObservationBP/Sources/ObservationBPLock/ObservationBPLock.xcframework:1:1 While building for tvOS Simulator, no library for this platform was found in '.../ObservationBP/Sources/ObservationBPLock/ObservationBPLock.xcframework'.

Would you be able to add support for tvOS?

rafcabezas commented 8 months ago

Looks like the build phase for the ObservationBPLock project is not building the tvOS variants, I can provide a PR, but basically the script could be modified like this:

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
rafcabezas commented 8 months ago

PR that resolves this: https://github.com/winddpan/ObservationBP/pull/4