-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// swift-tools-version:999.0 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "appPkg", | ||
This comment has been minimized.
Sorry, something went wrong. |
||
platforms: [ | ||
.macOS(.v10_12), | ||
.iOS(.v10), | ||
.tvOS(.v11), | ||
.watchOS(.v5) | ||
], | ||
dependencies: [ | ||
.package(url: "../gamePkg", from: "1.0.0"), | ||
This comment has been minimized.
Sorry, something went wrong.
tomerd
Contributor
|
||
], | ||
targets: [ | ||
.executableTarget( | ||
name: "App", | ||
dependencies: [ | ||
"Utils", | ||
.product(name: "Utils", | ||
package: "gamePkg", | ||
moduleAliases: ["Utils": "GameUtils"]) | ||
], | ||
path: "./Sources/App"), | ||
.target( | ||
name: "Utils", | ||
dependencies: [], | ||
path: "./Sources/Utils" | ||
) | ||
] | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Utils | ||
import GameUtils | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
Utils.echoModule() | ||
|
||
let level = LevelDetector.detect(for: "TestUser") | ||
print(level) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
public func echoModule() { | ||
print("Utils") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// swift-tools-version:4.2 | ||
This comment has been minimized.
Sorry, something went wrong. |
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "gamePkg", | ||
This comment has been minimized.
Sorry, something went wrong. |
||
products: [ | ||
.library(name: "Game", targets: ["Game"]), | ||
.library(name: "Utils", targets: ["Utils"]), | ||
], | ||
targets: [ | ||
.target(name: "Game", dependencies: ["Utils"]), | ||
.target(name: "Utils", dependencies: []), | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Utils | ||
|
||
public struct Game: Equatable { | ||
public var levels: [LevelDetector] | ||
|
||
public static func startGame(for user: String) -> Int { | ||
if user.isEmpty { | ||
return -1 | ||
} | ||
return LevelDetector.detect(for: user) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
public struct LevelDetector: Equatable { | ||
public static func detect(for user: String) -> Int { | ||
return user.count | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See http://swift.org/LICENSE.txt for license information | ||
See http://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
*/ | ||
|
||
import Commands | ||
import PackageModel | ||
import SourceControl | ||
import SPMTestSupport | ||
import TSCBasic | ||
import Workspace | ||
import XCTest | ||
|
||
class ModuleAliasingTests: XCTestCase { | ||
|
||
func testExternalSimple() { | ||
fixture(name: "Miscellaneous/ModuleAliasing/Simple") { prefix in | ||
let app = prefix.appending(components: "appPkg") | ||
XCTAssertBuilds(app) | ||
XCTAssertFileExists(prefix.appending(components: "appPkg", ".build", UserToolchain.default.triple.platformBuildPathComponent(), "debug", "App")) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
XCTAssertFileExists(prefix.appending(components: "appPkg", ".build", UserToolchain.default.triple.platformBuildPathComponent(), "debug", "GameUtils.swiftmodule")) | ||
XCTAssertFileExists(prefix.appending(components: "appPkg", ".build", UserToolchain.default.triple.platformBuildPathComponent(), "debug", "Utils.swiftmodule")) | ||
let result = try SwiftPMProduct.SwiftBuild.executeProcess([], packagePath: app) | ||
XCTAssertEqual(result.exitStatus, .terminated(code: 0)) | ||
} | ||
} | ||
} |
1 comment
on commit 954bb2b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, some nits around naming.
nit: we dont normally use camel case. so this would more naturally be
AppPkg