From 3ab707170303ac53a952fe78e19d6fdb7de30d81 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 16 Oct 2017 20:39:33 -0700 Subject: [PATCH 1/4] Exclude more file types from resources Entitlements files, gpx files, and explicit lproj directories should never be included in a target's copy resources phase. Ideally this would also include files with the plist extension, but there are some outliers such as AppIntentVocabulary.plist. --- Sources/XcodeGenKit/PBXProjGenerator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index c42defbb..d8e59144 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -450,7 +450,7 @@ public class PBXProjGenerator { switch fileExtension { case "swift", "m", "cpp": return .sources case "h", "hh", "hpp", "ipp", "tpp", "hxx", "def": return .headers - case "xcconfig": return nil + case "xcconfig", "entitlements", "gpx", "lproj", "apns": return nil default: return .resources } } From d24df8677ce51040cae76a7967c2f905503bb0c9 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 16 Oct 2017 20:59:44 -0700 Subject: [PATCH 2/4] Allow copying of resource files from targets Previously we were assuming that all targets that were not app extensions should be added to the copy frameworks build phase, even though we didn't have any guarantee they were actually frameworks. This updates that to ensure that things copied in the copy frameworks phase are actually frameworks, and then falls back to the resources phase instead. This fixes the ability to embed bundle targets, and copy them as resources. --- Sources/ProjectSpec/ProjectExtensions.swift | 4 ++++ Sources/XcodeGenKit/PBXProjGenerator.swift | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Sources/ProjectSpec/ProjectExtensions.swift b/Sources/ProjectSpec/ProjectExtensions.swift index eedb2c79..ef05cac1 100644 --- a/Sources/ProjectSpec/ProjectExtensions.swift +++ b/Sources/ProjectSpec/ProjectExtensions.swift @@ -46,6 +46,10 @@ extension PBXProductType { } } + public var isFramework: Bool { + return fileExtension == "framework" + } + public var isExtension: Bool { return fileExtension == "appex" } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index fa8764f1..e33a96d1 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -229,7 +229,8 @@ public class PBXProjGenerator { var dependencies: [String] = [] var targetFrameworkBuildFiles: [String] = [] - var copyFiles: [String] = [] + var copyFrameworksReferences: [String] = [] + var copyResourcesReferences: [String] = [] var copyWatchReferences: [String] = [] var extensions: [String] = [] @@ -261,10 +262,12 @@ public class PBXProjGenerator { if dependencyTarget.type.isExtension { // embed app extension extensions.append(embedFile.reference) + } else if dependencyTarget.type.isFramework { + copyFrameworksReferences.append(embedFile.reference) } else if dependencyTarget.type.isApp && dependencyTarget.platform == .watchOS { copyWatchReferences.append(embedFile.reference) } else { - copyFiles.append(embedFile.reference) + copyResourcesReferences.append(embedFile.reference) } } @@ -283,7 +286,7 @@ public class PBXProjGenerator { if embed { let embedFile = PBXBuildFile(reference: generateUUID(PBXBuildFile.self, fileReference + target.name), fileRef: fileReference, settings: dependency.buildSettings) addObject(embedFile) - copyFiles.append(embedFile.reference) + copyFrameworksReferences.append(embedFile.reference) } case .carthage: if carthageFrameworksByPlatform[target.platform.carthageDirectoryName] == nil { @@ -304,7 +307,7 @@ public class PBXProjGenerator { if target.platform == .macOS && target.type.isApp { let embedFile = PBXBuildFile(reference: generateUUID(PBXBuildFile.self, fileReference + target.name), fileRef: fileReference, settings: dependency.buildSettings) addObject(embedFile) - copyFiles.append(embedFile.reference) + copyFrameworksReferences.append(embedFile.reference) } } } @@ -348,7 +351,7 @@ public class PBXProjGenerator { addObject(sourcesBuildPhase) buildPhases.append(sourcesBuildPhase.reference) - let resourcesBuildPhase = PBXResourcesBuildPhase(reference: generateUUID(PBXResourcesBuildPhase.self, target.name), files: getBuildFilesForPhase(.resources)) + let resourcesBuildPhase = PBXResourcesBuildPhase(reference: generateUUID(PBXResourcesBuildPhase.self, target.name), files: getBuildFilesForPhase(.resources) + copyResourcesReferences) addObject(resourcesBuildPhase) buildPhases.append(resourcesBuildPhase.reference) @@ -379,13 +382,13 @@ public class PBXProjGenerator { buildPhases.append(copyFilesPhase.reference) } - if !copyFiles.isEmpty { + if !copyFrameworksReferences.isEmpty { let copyFilesPhase = PBXCopyFilesBuildPhase( reference: generateUUID(PBXCopyFilesBuildPhase.self, "embed frameworks" + target.name), dstPath: "", dstSubfolderSpec: .frameworks, - files: copyFiles) + files: copyFrameworksReferences) addObject(copyFilesPhase) buildPhases.append(copyFilesPhase.reference) From 98f89ee758e4d8586d702d515a704917db4de66d Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 18 Oct 2017 08:58:28 -0700 Subject: [PATCH 3/4] Make build a PHONY task This solves the issue where if someone is generating a xcodeproj to work on XcodeGen, and their build directories are local, this command would assume that it should only run if something in that directory is changed, which isn't the case, we want it to run all the time and for swiftpm to decide if something has changed. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 1aab87e7..3fc7958a 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ install: build mkdir -p $(SHARE_PATH) cp -R $(CURRENT_PATH)/SettingPresets $(SHARE_PATH)/SettingPresets +.PHONY: build build: swift build --disable-sandbox -c release -Xswiftc -static-stdlib From 84437181eef1b9e99899772f6a6d1324ff780802 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 18 Oct 2017 10:40:53 -0700 Subject: [PATCH 4/4] Correct README --help argument This needs dashes, if you run it without it XcodeGen does print some help but only because the command failed. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ac6b6dc..9e043f90 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ $ xcodegen This will look for a project spec in the current directory called `project.yml` -Use `xcodegen help` to see the list of options: +Use `xcodegen --help` to see the list of options: - **--spec**: An optional path to a `.yml` or `.json` project spec - **--project**: An optional path to a directory where the project will be generated. By default this is the current directory