Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix SPM build and add scripts to check locally #1914

Merged
merged 2 commits into from
Jun 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ internal struct UITabBarWireframesBuilder: NodeWireframesBuilder {
]
}
}
#endif

fileprivate extension UIImage {
/// Returns a unique description of the image.
Expand All @@ -142,3 +141,4 @@ fileprivate extension UIImage {
return "\(cgImage.width)x\(cgImage.height)-\(cgImage.bitsPerComponent)x\(cgImage.bitsPerPixel)-\(cgImage.bytesPerRow)-\(cgImage.bitmapInfo)"
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import DatadogInternal
#warning("Datadog WebView Tracking does not support tvOS")
#else
import WebKit
#endif

@objc(DDWebViewTracking)
@_spi(objc)
Expand Down Expand Up @@ -55,3 +54,4 @@ public final class objc_WebViewTracking: NSObject {
WebViewTracking.disable(webView: webView)
}
}
#endif
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ DEFAULT_TVOS_OS := latest
DEFAULT_TVOS_PLATFORM := tvOS Simulator
DEFAULT_TVOS_DEVICE := Apple TV

build-spm:
@$(call require_param,PLATFORM)
@:$(eval PLATFORM ?= iOS)
./tools/spm.sh --platform $(PLATFORM)

build-spm-all:
./tools/spm.sh --platform iOS
./tools/spm.sh --platform tvOS
./tools/spm.sh --platform visionOS

# Run unit tests for specified SCHEME
test:
@$(call require_param,SCHEME)
Expand Down
47 changes: 47 additions & 0 deletions tools/spm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/zsh

# Usage:
# $ ./tools/spm.sh -h
# Builds the SDK only using Package.swift.

set -eo pipefail
source ./tools/utils/echo_color.sh
source ./tools/utils/argparse.sh

define_arg "platform" "" "Defines the type of simulator platform for the tests, e.g. 'iOS', 'tvOS, 'visionOS'" "string" "true"

check_for_help "$@"
parse_args "$@"

WORKSPACE="Datadog.xcworkspace"
WORKSPACE_RENAMED="Datadog.xcworkspace.old"
SCHEME="Datadog-Package"

set -x

rename_workspace() {
if [ ! -d "$WORKSPACE" ]; then
echo_warn "Workspace $WORKSPACE does not exist"
return 0
fi

echo_warn "Renaming workspace to $WORKSPACE_RENAMED"
mv "$WORKSPACE" "$WORKSPACE_RENAMED"
}

restore_workspace() {
if [ ! -d "$WORKSPACE_RENAMED" ]; then
echo_warn "Workspace $WORKSPACE_RENAMED does not exist"
return 0
fi

echo_warn "Restoring workspace to $WORKSPACE"
mv "$WORKSPACE_RENAMED" "$WORKSPACE"
}

rename_workspace
# try to restore the files even if the script fails
trap restore_workspace EXIT INT
ganeshnj marked this conversation as resolved.
Show resolved Hide resolved

echo "Building SDK for platform $platform"
xcodebuild build -scheme $SCHEME -destination generic/platform="$platform" | xcbeautify