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

Support external target dependencies via subprojects #701

Merged
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Next Version

#### Added
- Support External Target References via subprojects. [#701](https://github.com/yonaskolb/XcodeGen/pull/701) @evandcoleman

#### Fixed
- Fixed compilation as library by locking down XcodeProj version [#767](https://github.com/yonaskolb/XcodeGen/pull/767) @yonaskolb

Expand Down
6 changes: 5 additions & 1 deletion Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ targets:

A dependency can be one of a 6 types:

- `target: name` - links to another target
- `target: name` - links to another target. If you are using project references you can specify a target within another project by using `ProjectName/TargetName` for the name
- `framework: path` - links to a framework
- `carthage: name` - helper for linking to a Carthage framework
- `sdk: name` - links to a dependency with the SDK. This can either be a relative path within the sdk root or a single filename that references a framework (.framework) or lib (.tbd)
Expand Down Expand Up @@ -423,10 +423,14 @@ Carthage officially supports static frameworks. In this case, frameworks are exp
You can specify `linkType` to `static` to integrate static ones.

```yaml
projectReferences:
FooLib:
path: path/to/FooLib.xcodeproj
targets:
MyTarget:
dependencies:
- target: MyFramework
- target: FooLib/FooTarget
- framework: path/to/framework.framework
- carthage: Result
findFrameworks: false
Expand Down
5 changes: 3 additions & 2 deletions Sources/ProjectSpec/Linkage.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Foundation
import XcodeProj

public enum Linkage {
case dynamic
case `static`
case none
}

extension Target {
extension PBXProductType {

public var defaultLinkage: Linkage {
switch type {
switch self {
case .none,
.appExtension,
.application,
Expand Down
13 changes: 11 additions & 2 deletions Sources/ProjectSpec/SpecValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,17 @@ extension Project {
for dependency in target.dependencies {
switch dependency.type {
case .target:
if getProjectTarget(dependency.reference) == nil {
errors.append(.invalidTargetDependency(target: target.name, dependency: dependency.reference))
let dependencyTargetReference = try TargetReference(dependency.reference)

switch dependencyTargetReference.location {
case .local:
if getProjectTarget(dependency.reference) == nil {
errors.append(.invalidTargetDependency(target: target.name, dependency: dependency.reference))
}
case .project(let dependencyProjectName):
if getProjectReference(dependencyProjectName) == nil {
errors.append(.invalidTargetDependency(target: target.name, dependency: dependency.reference))
}
}
case .sdk:
let path = Path(dependency.reference)
Expand Down
270 changes: 213 additions & 57 deletions Sources/XcodeGenKit/PBXProjGenerator.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXFileReference section */
6023D61BF2C57E6AE09CE7A3 /* BundleX.bundle */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.plug-in"; path = BundleX.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
60D6679FB526839EAFEA2EEE /* config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = config.xcconfig; sourceTree = "<group>"; };
D6340FC7DEBC81E0127BAFD6 /* ExternalTarget.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ExternalTarget.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXGroup section */
Expand All @@ -33,6 +34,7 @@
isa = PBXGroup;
children = (
6023D61BF2C57E6AE09CE7A3 /* BundleX.bundle */,
D6340FC7DEBC81E0127BAFD6 /* ExternalTarget.framework */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -55,6 +57,21 @@
productReference = 6023D61BF2C57E6AE09CE7A3 /* BundleX.bundle */;
productType = "com.apple.product-type.bundle";
};
E76A5F5E363E470416D3B487 /* ExternalTarget */ = {
isa = PBXNativeTarget;
buildConfigurationList = B5049D72EC10A5C87F29B6B1 /* Build configuration list for PBXNativeTarget "ExternalTarget" */;
buildPhases = (
F08051CAC5E72EEEB8FB447B /* Sources */,
);
buildRules = (
);
dependencies = (
);
name = ExternalTarget;
productName = ExternalTarget;
productReference = D6340FC7DEBC81E0127BAFD6 /* ExternalTarget.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -78,6 +95,7 @@
projectRoot = "";
targets = (
63A2D4898D974A06E85B07F8 /* BundleX */,
E76A5F5E363E470416D3B487 /* ExternalTarget */,
);
};
/* End PBXProject section */
Expand All @@ -90,6 +108,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F08051CAC5E72EEEB8FB447B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -248,6 +273,27 @@
};
name = "Staging Release";
};
1B1B4A623B8E9937627EF22C /* Test Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = "Test Debug";
};
270E1D32776D2D196D435FDA /* Staging Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -308,6 +354,69 @@
};
name = "Staging Debug";
};
30E2E954A636A240B1CE5C15 /* Staging Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = "Staging Release";
};
3B4B85DEBC49A5BEF2196886 /* Staging Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = "Staging Debug";
};
42D8986753AED7AA1F3DB83D /* Production Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = "Production Debug";
};
49FA7F235A6CA1F941192151 /* Staging Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -415,6 +524,48 @@
};
name = "Test Debug";
};
6081D1A42688EBF6CF4B2579 /* Production Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = "Production Release";
};
7919FDD28F9A535EA26FB151 /* Test Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = "Test Release";
};
9BD6CAD5463121A1C3FED138 /* Production Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -529,6 +680,19 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = "Production Debug";
};
B5049D72EC10A5C87F29B6B1 /* Build configuration list for PBXNativeTarget "ExternalTarget" */ = {
isa = XCConfigurationList;
buildConfigurations = (
42D8986753AED7AA1F3DB83D /* Production Debug */,
6081D1A42688EBF6CF4B2579 /* Production Release */,
3B4B85DEBC49A5BEF2196886 /* Staging Debug */,
30E2E954A636A240B1CE5C15 /* Staging Release */,
1B1B4A623B8E9937627EF22C /* Test Debug */,
7919FDD28F9A535EA26FB151 /* Test Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = "";
};
/* End XCConfigurationList section */
};
rootObject = 1B166EB49192B73A9DD8E108 /* Project object */;
Expand Down
3 changes: 3 additions & 0 deletions Tests/Fixtures/TestProject/AnotherProject/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ targets:
BundleX:
type: bundle
platform: iOS
ExternalTarget:
type: framework
platform: iOS
Loading