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

Add support for targets with mixed language sources #5919

Open
wants to merge 193 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
93a6090
[Initial] Approach 2
ncooke3 Oct 18, 2022
bda2a8a
Leaf mixed packages build
ncooke3 Nov 7, 2022
e8deac0
Various fixes
ncooke3 Nov 9, 2022
455f4bc
Resolve issues post rebase
ncooke3 Nov 9, 2022
6e961d1
Generate unextended-module-overlay.yaml
ncooke3 Nov 10, 2022
57f3c52
Generate unextended-module.modulemap and all-product-headers.yaml
ncooke3 Nov 10, 2022
67a05da
Fix build when Objc target depends on mixed target
ncooke3 Nov 10, 2022
680cf52
Add unit test to test mixed sources
ncooke3 Nov 12, 2022
ccaf69f
Remove newline
ncooke3 Nov 12, 2022
2c73c23
Consolidate 'finding module map type' logic
ncooke3 Nov 12, 2022
bcceb79
Consolidate 'finding module map type' logic
ncooke3 Nov 12, 2022
19bae8a
Refactor unextended module map generation
ncooke3 Nov 12, 2022
37bf34a
Add doc note wrt unextended module map
ncooke3 Nov 12, 2022
8bee64a
Remove unnecessary path string formatting
ncooke3 Nov 12, 2022
ce69990
Add doc comment wrt -I usage
ncooke3 Nov 14, 2022
54a71bd
Refactor approach
ncooke3 Nov 15, 2022
5929d46
Remove unneeded param
ncooke3 Nov 15, 2022
de336ed
Consolidate build argument additions
ncooke3 Nov 15, 2022
81b3537
Move more mixed target specific logic to MixedTargetBuildDescription
ncooke3 Nov 15, 2022
89ea761
Work around unsupported flags
ncooke3 Nov 15, 2022
e4b14e8
Various improvements
ncooke3 Nov 15, 2022
106d34c
Improve source filtering logic
ncooke3 Nov 15, 2022
42d5277
Broaden API surface of MixedTargetBuildDescription
ncooke3 Nov 15, 2022
761e112
Add errors for improper module map config
ncooke3 Nov 16, 2022
64fe280
Throw error for non-library and non-test targets
ncooke3 Nov 16, 2022
70729df
Throw error when using Mixed target on non-Apple platforms
ncooke3 Nov 16, 2022
fe7b530
Remove extra new line
ncooke3 Nov 16, 2022
b068fe3
Add ModuleMapGenerator test
ncooke3 Nov 16, 2022
3bf0392
Remove unneeded error case
ncooke3 Nov 16, 2022
b0cda54
Make error message more precise
ncooke3 Nov 16, 2022
295e385
Make error message more precise
ncooke3 Nov 16, 2022
64e5dcb
Move module map error earlier and add unit test
ncooke3 Nov 16, 2022
38e1ba5
Remove temporary development logic
ncooke3 Nov 16, 2022
4b826e1
Add BuildPlan unit test
ncooke3 Nov 17, 2022
9a2a7f2
Revert change to var's access level
ncooke3 Nov 17, 2022
35662f5
Add API for appending clang flags to SwiftTargetBuildDescription
ncooke3 Nov 18, 2022
accdcd8
Use .append() for single flag
ncooke3 Nov 18, 2022
2fdf1c3
Generate resource bundle accessors for Clang sources
ncooke3 Nov 19, 2022
0bac60b
Fix mixed target builds when public headers path includes directories
ncooke3 Nov 30, 2022
2e5ac6f
Add support for custom module maps
ncooke3 Dec 12, 2022
4d54084
Resolve warning and update tests
ncooke3 Dec 13, 2022
59e015e
Throw error for mixed targets when tool version is insufficient
ncooke3 Dec 13, 2022
1b78a25
Expose internal headers to Swift-half of target
ncooke3 Dec 15, 2022
713d618
Add initial batch of Fixture tests
ncooke3 Dec 19, 2022
ff61080
Build overlay using root of the target's sources, resolving a TODO
ncooke3 Dec 20, 2022
f01700f
Refactor overlay approach
ncooke3 Dec 21, 2022
06dc053
Add newlines to test files
ncooke3 Dec 21, 2022
c9cd563
Remove unneeded newline
ncooke3 Dec 21, 2022
a8a51a0
Add more newlines to test files
ncooke3 Dec 21, 2022
3944276
Resolve PR comment, align module map logic
ncooke3 Dec 21, 2022
b0166ea
Consolidate module map logic
ncooke3 Dec 21, 2022
3989c84
Add support for mixed targets with no public headers
ncooke3 Dec 21, 2022
6b735e1
Fix older tests, add new test, refactor impl
ncooke3 Dec 21, 2022
c6aae7d
Fix comment now that issue is understood
ncooke3 Dec 22, 2022
15eb0d1
Add linking tests (unit and integration)
ncooke3 Dec 22, 2022
cd4ead5
Add CXX integration test and document use case
ncooke3 Dec 23, 2022
84b0dde
s/half/part
ncooke3 Dec 23, 2022
1f5c447
s/half/part (pt. 2)
ncooke3 Dec 23, 2022
da01fd7
Refactor approach and add more tests
ncooke3 Dec 24, 2022
773bd47
Remove outdated comment
ncooke3 Dec 24, 2022
61d2e55
Cleanup constants
ncooke3 Dec 24, 2022
adcc335
Migrate private properties to local constants
ncooke3 Dec 24, 2022
c63c9b0
Consolidate local constants
ncooke3 Dec 25, 2022
4a5feff
Add unit test for custom moudle map case
ncooke3 Dec 25, 2022
be66b09
Add unit test to test invalid module map
ncooke3 Dec 25, 2022
ecc9291
Remove newline
ncooke3 Dec 26, 2022
8028c08
Fix tests
ncooke3 Dec 27, 2022
321c467
Rename testing copts
ncooke3 Dec 28, 2022
5a00f6a
Tweak error message
ncooke3 Dec 28, 2022
6c3a780
Use if rather than switch
ncooke3 Dec 28, 2022
31b4835
Update comment
ncooke3 Dec 28, 2022
8fe94a9
Resolve outdated TODOs
ncooke3 Dec 28, 2022
0d73056
Remove unneeded README
ncooke3 Dec 28, 2022
bcb5868
Remove unneeded README (2)
ncooke3 Dec 28, 2022
6224a95
Make comments more precise
ncooke3 Dec 28, 2022
0cd0d06
Simplify property's computation
ncooke3 Dec 28, 2022
3e1bc93
Fix grammar in comment
ncooke3 Dec 28, 2022
31de8c5
Fix test
ncooke3 Dec 28, 2022
075206f
Explicitly expose public headers to clients via -I (pt. 1)
ncooke3 Jan 3, 2023
072b2b0
Rename test files to avoid collisions in test bundle
ncooke3 Jan 3, 2023
feb7e18
Explicitly expose public headers to clients via -I (pt. 2)
ncooke3 Jan 3, 2023
971233f
Add unit test for issue fixed in previous 3 commits
ncooke3 Jan 3, 2023
b12688b
Resolve TODO
ncooke3 Jan 3, 2023
891a05b
Add unit tests to highlight current failures
ncooke3 Jan 6, 2023
5049814
Address current failures (approach #1)
ncooke3 Jan 6, 2023
3179871
Improve comments
ncooke3 Jan 6, 2023
8838f58
Resolve TODO and rename test resource
ncooke3 Jan 9, 2023
0eb90cb
Resolve TODO after investigation
ncooke3 Jan 9, 2023
0ddd937
Add extra imports to test
ncooke3 Jan 9, 2023
de78c7a
Add newlines where needed
ncooke3 Jan 9, 2023
6cb8601
Resolve TODO about VFSOverlay API
ncooke3 Jan 9, 2023
b06aee5
Add TODO to discuss during review
ncooke3 Jan 9, 2023
eb17874
Resolve TODO after experimenting
ncooke3 Jan 9, 2023
15f35fb
Convert variable to constant
ncooke3 Jan 10, 2023
f09eb58
Add additional CXX tests
ncooke3 Jan 10, 2023
b7a66de
Fix bug, add test resources, add TODOs
ncooke3 Jan 13, 2023
95b2450
Fix warning bug from previous commit description
ncooke3 Jan 14, 2023
268f1a9
Discovered workaround to previous commit's issue
ncooke3 Jan 14, 2023
358bffc
Remove VFSOverlayBuilder type as it is no longer needed
ncooke3 Jan 14, 2023
8ed1652
post rebase fixes
ncooke3 Jan 14, 2023
fe1f1f7
Corresponding test fix for f9ed8d5a99cee7a62ea0840250a6669dc418ad5f
ncooke3 Jan 17, 2023
db5f4d0
Revert "[Will erase] Make test build"
ncooke3 Jan 17, 2023
04e1bf0
Fix BuildPlanTests.swift build failures on Linux
ncooke3 Jan 17, 2023
8f71933
Add new 'MixedTargetBuildDescription.swift' to 'Build/CMakeLists.txt'
ncooke3 Jan 17, 2023
f12d8bd
Fix bug where non-public headers could not import public headers
ncooke3 Feb 3, 2023
5af3449
Fix tests to accomodate previous commit's changes
ncooke3 Feb 10, 2023
6b82912
Fix typo in name of test
ncooke3 Feb 10, 2023
cb7d874
Resolve comment TODOs
ncooke3 Feb 10, 2023
599fb6b
Add test coverage to ensure dependency headers can be imported in mix…
ncooke3 Feb 10, 2023
9896c47
Resolve rebase on 'main'
ncooke3 May 24, 2023
5c15bdb
Resolve incorrect code from rebase
ncooke3 Jul 17, 2023
a9b0ba2
Get tests rebased passing
ncooke3 Jul 17, 2023
7796abe
Rename fixture
ncooke3 Jul 22, 2023
3e6ea0e
Rename fixture (leftover from previous commit)
ncooke3 Jul 22, 2023
7923b02
Rename some test fixtures
ncooke3 Jul 23, 2023
7f7aee9
C++ interop support (1)
ncooke3 Jul 23, 2023
fa6a0e2
Adding build settings assertions to test
ncooke3 Jul 23, 2023
f2af5c0
C++ interop support (2)
ncooke3 Jul 24, 2023
b753b51
C++ interop support (3)
ncooke3 Jul 24, 2023
0dd4540
Resolve deprecation
ncooke3 Jul 24, 2023
735d37b
Guard tests and targets that require Swift 5.9
ncooke3 Jul 25, 2023
ecb3747
Remove unneeded build artifacts
ncooke3 Jul 25, 2023
4a524e1
Remove 'requires objc'
ncooke3 Jul 25, 2023
b01c677
Update test target Swift code to not reference non-public types
ncooke3 Jul 30, 2023
5f0054b
Post FR Re-work (1)
ncooke3 Jul 30, 2023
990908a
Post FR Re-work (2)
ncooke3 Aug 12, 2023
7b0f582
Post FR Re-work (3)
ncooke3 Aug 13, 2023
1da62e7
Post FR Re-work (4)
ncooke3 Aug 13, 2023
f00a883
Post FR Re-work (5): Plugin Support
ncooke3 Aug 15, 2023
6090b91
Add newlines where needed
ncooke3 Aug 15, 2023
eb19c0f
Cleanup unneeed module map generator code
ncooke3 Aug 16, 2023
33360bf
Post FR Re-work (6): Remove 'objc' from module map
ncooke3 Aug 16, 2023
044712c
Post FR Re-work (7): Use relative path for modularized Swift header
ncooke3 Aug 16, 2023
978c5f7
Add TODO question wrt C++ public hdrs dir
ncooke3 Aug 16, 2023
9c42e99
Consolidate module map logic
ncooke3 Aug 16, 2023
8575dbf
Replace unneeded property
ncooke3 Aug 16, 2023
219b92e
Consolidate module map logic (2)
ncooke3 Aug 16, 2023
008f294
Consolidate module map logic (3): Remove dated docs
ncooke3 Aug 16, 2023
159840e
Add TODO to investigate
ncooke3 Aug 16, 2023
6f9a0c5
Simplify some manifest builder logic
ncooke3 Aug 17, 2023
1dd2578
Post FR Re-work (8): Fix up Build Plan unit tests
ncooke3 Aug 17, 2023
3202a82
Post FR Re-work (9): Enable Windows support
ncooke3 Aug 17, 2023
67f7484
Post rebase fixes
ncooke3 Aug 17, 2023
9c6c97e
Resolve TODO in LLBuildManifestBuilder.swift
ncooke3 Aug 17, 2023
f877143
Feedback w.r.t. Plugin API
ncooke3 Aug 18, 2023
652fb7e
Revert "Post FR Re-work (9): Enable Windows support"
ncooke3 Aug 18, 2023
5cb110f
Refactor test suite for easier multiplatform support
ncooke3 Aug 21, 2023
778e65f
Add multiplatform build test
ncooke3 Aug 21, 2023
56ed7fb
Fix some of the Linux CI failures
ncooke3 Aug 22, 2023
cffc22a
Fix mixed target related build tests
ncooke3 Aug 22, 2023
1649cdd
Fix tests following 652fb7ea07c4480a0b116e2ddc485b4f4b0f4f66 (see more)
ncooke3 Aug 22, 2023
163b78e
Revert "Fix some of the Linux CI failures"
ncooke3 Aug 23, 2023
9b7413b
Temp. disable test on non-macOS. Added TODO
ncooke3 Aug 23, 2023
4e540d3
Resolve TODO; re-enable test on non-macOS
ncooke3 Aug 23, 2023
aca8f27
Fix remaining other BuildPlanTests on Linux
ncooke3 Aug 23, 2023
f415d89
Fix CI failures
ncooke3 Aug 23, 2023
a57bd03
Remove no longer need property
ncooke3 Aug 23, 2023
151e5bd
Fix macOS BuildPlan test
ncooke3 Aug 24, 2023
1c5d502
Fix linux test failure
ncooke3 Aug 24, 2023
b96629d
Fix Linux failure
ncooke3 Aug 25, 2023
e58fab9
Review – Add ending newlines where needed
ncooke3 Aug 25, 2023
2fb3e7a
Fix Linux failure (2)
ncooke3 Aug 29, 2023
4ddb0ae
Remove out-of-scope test
ncooke3 Aug 29, 2023
373c8ee
Resolve outstanding plugin TODO
ncooke3 Aug 29, 2023
8e74b5c
Resolve infeasible TODO
ncooke3 Aug 29, 2023
adc348d
Anticipate #6972's file deletions
ncooke3 Dec 2, 2023
4e967ab
Anticipate #6972's file deletions (2)
ncooke3 Dec 2, 2023
ccec9e7
Merge branch 'main' into nc/support-mixed-targets
ncooke3 Dec 6, 2023
fccc12d
Merge branch 'main' into nc/support-mixed-targets
ncooke3 Dec 6, 2023
ba37f14
Fix issues remaining after merges
ncooke3 Dec 6, 2023
3c70119
Merge branch 'main' into nc/support-mixed-targets
ncooke3 Jan 21, 2024
bc32197
Building post-merge. Tests failing.
ncooke3 Jan 22, 2024
43605b2
Use printf over NSLog
ncooke3 Aug 6, 2024
642c901
Fix tests that were failing post-merge
ncooke3 Aug 6, 2024
5543ae0
Fix mixed target related tests
ncooke3 Aug 6, 2024
3503c94
Fix regression caused by early case loop exit
ncooke3 Aug 8, 2024
2035f2a
Merge branch 'main-merge-feb' into nc/support-mixed-targets
ncooke3 Aug 9, 2024
7f72500
Post feb merge mixed target initializer fix
ncooke3 Aug 9, 2024
9cfc298
Merge branch 'main-merge-march' into nc/support-mixed-targets
ncooke3 Aug 14, 2024
387da75
Post march merge buildplantests fix
ncooke3 Aug 14, 2024
8e46768
Merge branch 'main-merge-april' into nc/support-mixed-targets
ncooke3 Nov 2, 2024
c444e19
Merge branch 'merge-main-may-07' into nc/support-mixed-targets
ncooke3 Nov 2, 2024
351f1c2
Merge branch 'main-merge-may-10' into nc/support-mixed-targets
ncooke3 Nov 2, 2024
86fced9
Merge branch 'main-merge-may-14' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
6134665
Merge branch 'merge-main-may-21' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
0ab7e0a
Merge branch 'main-merge-may-28' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
b81ae8b
Merge branch 'main-merge-may-29' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
fd2ba1a
Merge branch 'main-merge-may-30' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
7028c3b
Merge branch 'main-merge-may-31' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
059661d
Merge branch 'main-merge-june-15' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
97f6db6
main-merge-june-15 follow-up
ncooke3 Nov 5, 2024
3031e92
Merge branch 'main-merge-june-18' into nc/support-mixed-targets
ncooke3 Nov 5, 2024
e5f3579
Move platform conditional for easier testing
ncooke3 Nov 5, 2024
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
51 changes: 51 additions & 0 deletions Fixtures/MixedTargets/DummyTargets/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// swift-tools-version: 999.0
// FIXME(ncooke3): Update above version with the next version of SwiftPM.

import PackageDescription

// This package vends targets to aid in testing the MixedTargetsWithObjC package.
let package = Package(
name: "DummyTargets",
dependencies: [
.package(path: "../MixedTargetsWithObjC")
],
targets: [
.executableTarget(
name: "ClangExecutableDependsOnDynamicallyLinkedMixedTarget",
dependencies: [
.product(
name: "DynamicallyLinkedBasicMixedTarget",
package: "MixedTargetsWithObjC"
)
]
),
.executableTarget(
name: "ClangExecutableDependsOnStaticallyLinkedMixedTarget",
dependencies: [
.product(
name: "StaticallyLinkedBasicMixedTarget",
package: "MixedTargetsWithObjC"
)
]
),
.executableTarget(
name: "SwiftExecutableDependsOnDynamicallyLinkedMixedTarget",
dependencies: [
.product(
name: "DynamicallyLinkedBasicMixedTarget",
package: "MixedTargetsWithObjC"
)
]
),
.executableTarget(
name: "SwiftExecutableDependsOnStaticallyLinkedMixedTarget",
dependencies: [
.product(
name: "StaticallyLinkedBasicMixedTarget",
package: "MixedTargetsWithObjC"
)
]
)

]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>

@import BasicMixedTarget;

int main(int argc, const char *argv[]) {
@autoreleasepool {
// Ensure that the module is actually loaded.
Engine *engine = [[Engine alloc] init];
OldCar *oldCar = [[OldCar alloc] init];

printf("Hello, world!\n");
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>

@import BasicMixedTarget;

int main(int argc, const char * argv[]) {
@autoreleasepool {
// Ensure that the module is actually loaded.
Engine *engine = [[Engine alloc] init];
OldCar *oldCar = [[OldCar alloc] init];

printf("Hello, world!\n");
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import BasicMixedTarget

// Ensure that the module is actually loaded.
let _ = NewCar()
let _ = OldCar()

print("Hello, world!")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import BasicMixedTarget

// Ensure that the module is actually loaded.
let _ = NewCar()
let _ = OldCar()

print("Hello, world!")
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version: 999.0
// FIXME(ncooke3): Update above version with the next version of SwiftPM.

// NOTE: This is package is intended to build on all platforms (macOS, Linux, and Windows).

import PackageDescription

let package = Package(
name: "MixedTargetsWithCXX_InteropDisabled",
products: [
.library(
name: "MixedTarget",
targets: ["MixedTarget"]
),
.library(
name: "StaticallyLinkedMixedTarget",
type: .static,
targets: ["MixedTarget"]
),
.library(
name: "DynamicallyLinkedMixedTarget",
type: .dynamic,
targets: ["MixedTarget"]
)
],
dependencies: [],
targets: [
.target(
name: "MixedTarget"
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "CxxCountdown.hpp"

#include <iostream>

#include "MixedTarget-Swift.h"
#include <MixedTarget-Swift.h>

CxxCountdown::CxxCountdown(bool printCount) : printCount(printCount) {}

void CxxCountdown::countdown(int x )const {
if (x < 0)
std::cout << "[c++] Cannot count down from a negative number.\n";
return;

if (printCount)
std::cout << "[c++] T-minus " << x << "... \n";

if (x == 0)
std::cout << "[c++] We have liftoff!";
return;

CxxCountdown::countdown(x - 1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation

public struct SwiftCountdown {
private let printCount: Bool

public init(printCount: Bool) {
self.printCount = printCount
}

public func countdown(x: Int) {
if x < 0 {
print("[swift] Cannot count down from a negative number.")
return
}

if printCount {
print("[swift] T-minus \(x)...")
}

if x == 0 {
print("[swift] We have liftoff!")
return
}

countdown(x: x - 1)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifdef __cplusplus
class CxxCountdown
{
public:
CxxCountdown(bool printCount);
void countdown(int x) const;
private:
bool printCount;
};
#endif // __cplusplus
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version: 999.0
// FIXME(ncooke3): Update above version with the next version of SwiftPM.

// NOTE: This is package is intended to build on all platforms (macOS, Linux, and Windows).

import PackageDescription

let package = Package(
name: "MixedTargetsWithCXX_InteropEnabled",
products: [
.library(
name: "MixedTarget",
targets: ["MixedTarget"]
),
.library(
name: "StaticallyLinkedMixedTarget",
type: .static,
targets: ["MixedTarget"]
),
.library(
name: "DynamicallyLinkedMixedTarget",
type: .dynamic,
targets: ["MixedTarget"]
)
],
dependencies: [],
targets: [
.target(
name: "MixedTarget",
swiftSettings: [.interoperabilityMode(.Cxx)]
)
],
// TODO(ncooke3): Is the below note behavior that we want to be intended?
// This is needed for targets with that have
// `swiftSettings: [.interoperabilityMode(.Cxx)]` set.
cxxLanguageStandard: .cxx11
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "CxxCountdown.hpp"

#include <iostream>

#include "MixedTarget-Swift.h"
#include <MixedTarget-Swift.h>

CxxCountdown::CxxCountdown(bool printCount) : printCount(printCount) {}

void CxxCountdown::countdown(int x )const {
if (x < 0)
std::cout << "[c++] Cannot count down from a negative number.\n";
return;

if (printCount)
std::cout << "[c++] T-minus " << x << "... \n";

if (x == 0)
std::cout << "[c++] We have liftoff!";
return;

auto swiftCountdown = MixedTarget::SwiftCountdown::init(printCount);
swiftCountdown.countdown(x - 1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation

public struct SwiftCountdown {
private let printCount: Bool

public init(printCount: Bool) {
self.printCount = printCount
}

public func countdown(x: Int) {
if x < 0 {
print("[swift] Cannot count down from a negative number.")
return
}

if printCount {
print("[swift] T-minus \(x)...")
}

if x == 0 {
print("[swift] We have liftoff!")
return
}

let cxxCountdown = CxxCountdown(printCount)
cxxCountdown.countdown(Int32(x) - 1)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CxxCountdown
{
public:
CxxCountdown(bool printCount);
void countdown(int x) const;
private:
bool printCount;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <Foundation/Foundation.h>

// All three import statements should be supported.
#import "Driver.h"
#import "Public/Driver.h"
#import "MixedTargetWithCustomPaths/Sources/Public/Driver.h"

@implementation Driver
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Foundation

// This type is Objective-C compatible and used in `OldCar`.
@objc public class Engine: NSObject {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation

public class NewCar {
// `Engine` is defined in Swift.
var engine: Engine? = nil
// The following types are defined in Objective-C.
var driver: Driver? = nil

public init() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import <Foundation/Foundation.h>

// The below import statements should be supported.
#import "MixedTargetWithCustomPaths/Sources/Public/OldCar.h"
#import "OldCar.h"
#import "Public/OldCar.h"
#import <OldCar.h>
#import <Public/OldCar.h>

// Import the Swift part of the module.
#import "MixedTargetWithCustomPaths-Swift.h"

// Both import statements should be supported.
#import "MixedTargetWithCustomPaths/Sources/Transmission.h"
#import "Transmission.h"

@interface OldCar ()
@property(nonatomic) Transmission *transmission;
@end

@implementation OldCar
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import <Foundation/Foundation.h>

// This type is Swift compatible and used in `NewCar`.
@interface Driver : NSObject
@property(nonnull) NSString* name;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>

#import "Driver.h"

// The `Engine` type is declared in the Swift part of the module. Such types
// must be forward declared in headers.
@class Engine;

@interface OldCar : NSObject
// `Engine` is defined in Swift.
@property(nullable) Engine *engine;
// `Driver` is defined in Objective-C.
@property(nullable) Driver *driver;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, TransmissionKind) {
TransmissionKindManual,
TransmissionKindAutomatic
};

@interface Transmission : NSObject
@property (nonatomic, readonly, assign) TransmissionKind transmissionKind;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>

// Both import statements should be supported.
#import "Transmission.h"
#import "MixedTargetWithCustomPaths/Sources/Transmission.h"

@implementation Transmission
@end
Loading