Skip to content

Commit

Permalink
Merge pull request #1914 from DataDog/ganeshnj/chore/fix-spm-build
Browse files Browse the repository at this point in the history
chore: fix SPM build and add scripts to check locally
  • Loading branch information
ganeshnj authored Jun 20, 2024
2 parents cd37cb5 + e1db922 commit 85f4abe
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
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

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

0 comments on commit 85f4abe

Please sign in to comment.