Skip to content

Commit

Permalink
Merge pull request #1446 from OneSignal/fix/live_activities_mac_catalyst
Browse files Browse the repository at this point in the history
OneSignalLiveActivities framework included for mac catalyst
  • Loading branch information
nan-li committed Jun 10, 2024
2 parents 25f0657 + b105eba commit 37ede25
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
6 changes: 3 additions & 3 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5413,7 +5413,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MACCATALYST = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -5486,7 +5486,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MACCATALYST = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -5554,7 +5554,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MACCATALYST = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
THE SOFTWARE.
*/

// Effectively blanks out this file for Mac Catalyst
#if targetEnvironment(macCatalyst)
#else

/**
A default struct conforming to OneSignalLiveActivityAttributes which is registered with OneSignal as a Live Activity
through `OneSignal.LiveActivities.setupDefault`. The only action required by the customer app is
Expand Down Expand Up @@ -74,3 +78,4 @@ public struct DefaultLiveActivityAttributes: OneSignalLiveActivityAttributes {
public var data: [String: AnyCodable]
public var onesignal: OneSignalLiveActivityAttributeData
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
THE SOFTWARE.
*/

// Effectively blanks out this file for Mac Catalyst
#if targetEnvironment(macCatalyst)
#else
import OneSignalOSCore
import ActivityKit

Expand Down Expand Up @@ -116,3 +119,4 @@ public class LiveActivitySetupOptions: NSObject {
self.enablePushToUpdate = enablePushToUpdate
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
THE SOFTWARE.
*/

// Effectively blanks out this file for Mac Catalyst
#if targetEnvironment(macCatalyst)
#else
import OneSignalCore
import OneSignalOSCore
import ActivityKit
Expand Down Expand Up @@ -238,3 +241,4 @@ public class OneSignalLiveActivitiesManagerImpl: NSObject, OSLiveActivities {
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
THE SOFTWARE.
*/

// Effectively blanks out this file for Mac Catalyst
#if targetEnvironment(macCatalyst)
#else
import ActivityKit

/**
Expand Down Expand Up @@ -83,3 +86,4 @@ public protocol OneSignalLiveActivityContentState: Decodable, Encodable, Hashabl
public struct OneSignalLiveActivityContentStateData: Decodable, Encodable, Hashable {
public var notificationId: String
}
#endif
34 changes: 1 addition & 33 deletions iOS_SDK/OneSignalSDK/build_all_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,6 @@ create_xcframework() {
rm -rf "${CATALYST_ARCHIVE_PATH}"
}

create_xcframework_no_catalyst() {
FRAMEWORK_FOLDER_NAME=$1

FRAMEWORK_NAME=$2

FRAMEWORK_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/${FRAMEWORK_NAME}.xcframework"

BUILD_SCHEME=$3

SIMULATOR_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/simulator.xcarchive"

IOS_DEVICE_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/iOS.xcarchive"

rm -rf "${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}"
echo "Deleted ${FRAMEWORK_FOLDER_NAME}"
mkdir "${FRAMEWORK_FOLDER_NAME}"
echo "Created ${FRAMEWORK_FOLDER_NAME}"
echo "Archiving ${FRAMEWORK_NAME}"

xcodebuild -list

xcodebuild archive ONLY_ACTIVE_ARCH=NO -scheme ${BUILD_SCHEME} -destination="generic/platform=iOS Simulator" -archivePath "${SIMULATOR_ARCHIVE_PATH}" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

xcodebuild archive -scheme ${BUILD_SCHEME} -destination="generic/platform=iOS" -archivePath "${IOS_DEVICE_ARCHIVE_PATH}" -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

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}"
rm -rf "${CATALYST_ARCHIVE_PATH}"
}

# BUILD ONESIGNAL CORE ##
create_xcframework "OneSignal_Core" "OneSignalCore" "OneSignalCore"

Expand All @@ -90,7 +58,7 @@ create_xcframework "OneSignal_Notifications" "OneSignalNotifications" "OneSignal
create_xcframework "OneSignal_User" "OneSignalUser" "OneSignalUser"

## BUILD ONESIGNAL LIVE ACTIVITIES ##
create_xcframework_no_catalyst "OneSignal_LiveActivities" "OneSignalLiveActivities" "OneSignalLiveActivities"
create_xcframework "OneSignal_LiveActivities" "OneSignalLiveActivities" "OneSignalLiveActivities"

## BUILD ONESIGNAL USER ##
create_xcframework "OneSignal_Location" "OneSignalLocation" "OneSignalLocation"
Expand Down

0 comments on commit 37ede25

Please sign in to comment.