Skip to content

Commit

Permalink
Merge pull request #2 from DataDog/ncreated/RUMM-101-create-sdk-project
Browse files Browse the repository at this point in the history
RUMM-101 Create SDK project
  • Loading branch information
ncreated authored Dec 11, 2019
2 parents 9cef8be + 1b22a51 commit b23c25b
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Contributing

## Installation

### `kickoff` tool

The easiest way to start is to use `kickoff` tool. It will prepare your machine for contributions. Simply run the tool from repository root folder:
```bash
./tools/kickoff.sh
```

### What does `kickoff` do?

This project uses [Swift Package Manager](https://swift.org/package-manager/). `kickoff` will **generate `Datadog.xcodeproj`** for you.

As part of our coding convention, we use **custom Xcode file templates** for creating `.swift` and unit test files. Templates will be automatically installed and available from Xcode's "New File..." menu (search for "Datadog" section).

## Contributing to `Datadog` SDK

_TBD_

## Contributing to Project Tools

Tools are located in `tools` directory. They are set of scripts dedicated to project setup and development automation.

Be aware of these conventions when contributing to tools:
* each tool is located under separate directory in `tools/`, `kebab-case` convention is used for naming;
* each script must work as it is executed from repository root folder (so they can be eventually used by `./tools/kickoff.sh`).
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Datadog",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Datadog",
targets: ["Datadog"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Datadog",
dependencies: []),
.testTarget(
name: "DatadogTests",
dependencies: ["Datadog"]),
]
)
5 changes: 5 additions & 0 deletions Sources/Datadog/Datadog.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

public struct Datadog {
public init() {}
}
8 changes: 8 additions & 0 deletions Tests/DatadogTests/DatadogTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import XCTest

class DatadogTests: XCTestCase {

func testItDoesSomething() {
// 🐶
}
}
15 changes: 15 additions & 0 deletions tools/kickoff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

CURRENT_DIR=${PWD##*/}

if [ "$CURRENT_DIR" != "dd-sdk-ios" ]; then
echo "\`kickoff.sh\` must be run in repository root folder: \`./tools/kickoff.sh\`"; exit 1
fi

# Generate `Datadog.xcodeproj`
swift package generate-xcodeproj

# Install Datadog Xcode templates
./tools/xcode-templates/install-xcode-templates.sh

echo "💪 All good"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>An empty Swift file.</string>
<key>Summary</key>
<string>An empty Swift file</string>
<key>SortOrder</key>
<string>30</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>File</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Foundation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>An empty Swift file.</string>
<key>Summary</key>
<string>An empty Swift file</string>
<key>SortOrder</key>
<string>30</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>DefaultCompletionName</key>
<string>File</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import XCTest

class ___FILEBASENAMEASIDENTIFIER___: XCTestCase {

func testItDoesSomething() {
// 🐶
}
}
14 changes: 14 additions & 0 deletions tools/xcode-templates/install-xcode-templates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

XCODE_LOCATION=$(xcode-select -p)
XCODE_TEMPLATES_LOCATION="$XCODE_LOCATION/Library/Xcode/Templates/File Templates/"

if [ -z "$XCODE_LOCATION" ]; then
echo "🔥 Failed to install Xcode templates - cannot determine Xcode installation with \`xcode-select -p\`."
exit 1
fi

rm -r "$XCODE_TEMPLATES_LOCATION/Datadog" 2> /dev/null
cp -R "./tools/xcode-templates/Datadog" "$XCODE_TEMPLATES_LOCATION"

echo "✅ Installed Xcode templates"

0 comments on commit b23c25b

Please sign in to comment.