Skip to content

Commit c838e74

Browse files
authored
Adding sample swift package importing swift wrappers package (#1183)
* renaming folder to have different names for xcode and package sample * adding sample package files * adding dependencies for the onedswrapper * removing tests file * adding example for calling swift wrapper classes * correcting readme file * correcting readme file
1 parent 15e1855 commit c838e74

File tree

10 files changed

+82
-1
lines changed

10 files changed

+82
-1
lines changed

examples/swift/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SwiftWrapperApp
1+
# SampleXcodeApp
22

33
Contains a simple Xcode project to import and showcase swift wrappers package.
44

@@ -18,3 +18,15 @@ Details:
1818
- libmat.a
1919
- libz.tbd
2020
- libsqlite3.a
21+
22+
23+
# SamplePackage
24+
25+
Contains a simple swift package importing swift wrappers package and calling 1DS API via swift wrappers.
26+
27+
Details:
28+
- Package Dependencies:
29+
- OneDSSwift: Package containing swift wrappers
30+
31+
- Modules Included:
32+
- ObjCModule: Module exposing ObjC headers via module.modulemap file.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/config/registries.json
8+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
9+
.netrc
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// swift-tools-version: 5.8
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SamplePackage",
8+
products: [
9+
// Products define the executables and libraries a package produces, making them visible to other packages.
10+
.library(
11+
name: "SamplePackage",
12+
targets: ["SamplePackage"]),
13+
],
14+
dependencies: [
15+
.package(path: "../../../wrappers/swift"),
16+
],
17+
targets: [
18+
// Targets are the basic building blocks of a package, defining a module or a test suite.
19+
// Targets can depend on other targets in this package and products from dependencies.
20+
.target(
21+
name: "SamplePackage",
22+
dependencies: [
23+
.product(name: "OneDSSwift", package: "swift"),
24+
],
25+
swiftSettings: [
26+
.unsafeFlags(["-Xcc", "-I../../../wrappers/swift/Modules/"])
27+
]),
28+
]
29+
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
6+
import OneDSSwift
7+
8+
private var logger:Logger?
9+
private var token:String = ""
10+
11+
/// Method accessing Swift Wrapper package OneDSSwift telemetry classes
12+
13+
func initTelemetry() {
14+
token = "7c8b1796cbc44bd5a03803c01c2b9d61-b6e370dd-28d9-4a52-9556-762543cf7aa7-6991"
15+
logger = LogManager.loggerWithTenant(tenantToken: token, withSource: "example_proj_source")
16+
}
17+
18+
func sendTelemetry(_ text:String) {
19+
let event:EventProperties = EventProperties(name: "SetProps_Swift_Wrapper_Example_Proj")
20+
event.setProperty("enteredtext", withValue: text)
21+
event.setProperty("from", withValue: "Swift_Wrappers_Package_Example_Project")
22+
23+
if (logger != nil) {
24+
logger!.logEvent(properties: event)
25+
}
26+
LogManager.uploadNow()
27+
}
28+
29+
func closeTelemetrySession() {
30+
_ = LogManager.flushAndTeardown()
31+
}

0 commit comments

Comments
 (0)