From 7efe9c17f66fec6dcbe3a6d3d7abff91e12968c8 Mon Sep 17 00:00:00 2001 From: Yonas Kolb Date: Sun, 28 Jan 2018 19:31:47 +1030 Subject: [PATCH] update to xcproj 4.0 --- Sources/ProjectSpec/ProjectSpec.swift | 12 ++++++------ Sources/XcodeGenKit/PBXProjGenerator.swift | 16 ++++++---------- .../Project.xcodeproj/project.pbxproj | 15 ++++++++++----- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Sources/ProjectSpec/ProjectSpec.swift b/Sources/ProjectSpec/ProjectSpec.swift index f6d5f72a..02d1c00c 100644 --- a/Sources/ProjectSpec/ProjectSpec.swift +++ b/Sources/ProjectSpec/ProjectSpec.swift @@ -27,8 +27,8 @@ public struct ProjectSpec { public var disabledValidations: [ValidationType] public var developmentLanguage: String? public var usesTabs: Bool? - public var tabWidth: Int? - public var indentWidth: Int? + public var tabWidth: UInt? + public var indentWidth: UInt? public var xcodeVersion: String? public var deploymentTarget: DeploymentTarget @@ -59,8 +59,8 @@ public struct ProjectSpec { bundleIdPrefix: String? = nil, settingPresets: SettingPresets = .all, developmentLanguage: String? = nil, - indentWidth: Int? = nil, - tabWidth: Int? = nil, + indentWidth: UInt? = nil, + tabWidth: UInt? = nil, usesTabs: Bool? = nil, xcodeVersion: String? = nil, deploymentTarget: DeploymentTarget = .init(), @@ -208,8 +208,8 @@ extension ProjectSpec.Options: JSONObjectConvertible { createIntermediateGroups = jsonDictionary.json(atKeyPath: "createIntermediateGroups") ?? false developmentLanguage = jsonDictionary.json(atKeyPath: "developmentLanguage") usesTabs = jsonDictionary.json(atKeyPath: "usesTabs") - indentWidth = jsonDictionary.json(atKeyPath: "indentWidth") - tabWidth = jsonDictionary.json(atKeyPath: "tabWidth") + indentWidth = (jsonDictionary.json(atKeyPath: "indentWidth") as Int?).flatMap(UInt.init) + tabWidth = (jsonDictionary.json(atKeyPath: "tabWidth") as Int?).flatMap(UInt.init) deploymentTarget = jsonDictionary.json(atKeyPath: "deploymentTarget") ?? DeploymentTarget() disabledValidations = jsonDictionary.json(atKeyPath: "disabledValidations") ?? [] } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index f3962529..09b33315 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -27,7 +27,7 @@ public class PBXProjGenerator { public init(spec: ProjectSpec) { self.spec = spec - proj = PBXProj(objectVersion: 46, rootObject: "") + proj = PBXProj(rootObject: "", objectVersion: 46) sourceGenerator = SourceGenerator(spec: spec) { [unowned self] id, object in self.addObject(id: id, object) } @@ -74,8 +74,7 @@ public class PBXProjGenerator { id: spec.name, XCConfigurationList( buildConfigurations: buildConfigs.map { $0.reference }, - defaultConfigurationName: buildConfigs.first?.object.name ?? "", - defaultConfigurationIsVisible: 0 + defaultConfigurationName: buildConfigs.first?.object.name ?? "" ) ) @@ -84,7 +83,7 @@ public class PBXProjGenerator { PBXGroup( children: [], sourceTree: .group, - usesTabs: spec.options.usesTabs.map { $0 ? 1 : 0 }, + usesTabs: spec.options.usesTabs, indentWidth: spec.options.indentWidth, tabWidth: spec.options.tabWidth ) @@ -136,7 +135,7 @@ public class PBXProjGenerator { explicitFileType: explicitFileType, lastKnownFileType: lastKnownFileType, path: target.filename, - includeInIndex: 0 + includeInIndex: false ) ) @@ -515,7 +514,7 @@ public class PBXProjGenerator { shellPath: buildScript.shell ?? "/bin/sh", shellScript: shellScript ) - shellScriptPhase.runOnlyForDeploymentPostprocessing = buildScript.runOnlyWhenInstalling ? 1 : 0 + shellScriptPhase.runOnlyForDeploymentPostprocessing = buildScript.runOnlyWhenInstalling let shellScriptPhaseReference = createObject(id: String(describing: buildScript.name) + shellScript + target.name, shellScriptPhase) buildPhases.append(shellScriptPhaseReference.reference) } @@ -544,10 +543,7 @@ public class PBXProjGenerator { let frameworkBuildPhase = createObject( id: target.name, - PBXFrameworksBuildPhase( - files: targetFrameworkBuildFiles, - runOnlyForDeploymentPostprocessing: 0 - ) + PBXFrameworksBuildPhase(files: targetFrameworkBuildFiles) ) buildPhases.append(frameworkBuildPhase.reference) } diff --git a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj index e7ae944a..84e425c6 100644 --- a/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj +++ b/Tests/Fixtures/TestProject/Project.xcodeproj/project.pbxproj @@ -114,7 +114,7 @@ FR_481575785861 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; FR_500792082643 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LocalizedStoryboard.strings; sourceTree = ""; }; FR_525119120469 /* Framework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Framework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - FR_602633703434 /* en */ = {isa = PBXFileReference; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; + FR_602633703434 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; FR_609193904586 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; FR_635802719871 /* base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = base.xcconfig; sourceTree = ""; }; FR_643034527839 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -124,7 +124,7 @@ FR_675266829517 /* Standalone.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Standalone.swift; sourceTree = ""; }; FR_722239415598 /* TestProjectTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestProjectTests.swift; sourceTree = ""; }; FR_725187762757 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - FR_746876637628 /* Base */ = {isa = PBXFileReference; name = Base; path = Base.lproj/Localizable.stringsdict; sourceTree = ""; }; + FR_746876637628 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.stringsdict; sourceTree = ""; }; FR_752394658615 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Alamofire.framework; sourceTree = ""; }; FR_771029596306 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; FR_783122899910 /* App_iOS_Tests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = App_iOS_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -395,8 +395,6 @@ buildConfigurationList = CL_479264660374 /* Build configuration list for PBXLegacyTarget "Legacy" */; buildPhases = ( ); - buildRules = ( - ); buildToolPath = /usr/bin/true; dependencies = ( ); @@ -606,6 +604,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "echo \"You ran a script\"\n"; + showEnvVarsInLog = 0; }; SSBP_3886691194 /* MyScript */ = { isa = PBXShellScriptBuildPhase; @@ -620,6 +619,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "echo \"You ran a script\"\n"; + showEnvVarsInLog = 0; }; SSBP_5106020372 /* Strip Unused Architectures from Frameworks */ = { isa = PBXShellScriptBuildPhase; @@ -634,6 +634,7 @@ runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; shellScript = "################################################################################\n#\n# Copyright 2015 Realm Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n################################################################################\n\n# This script strips all non-valid architectures from dynamic libraries in\n# the application's `Frameworks` directory.\n#\n# The following environment variables are required:\n#\n# BUILT_PRODUCTS_DIR\n# FRAMEWORKS_FOLDER_PATH\n# VALID_ARCHS\n# EXPANDED_CODE_SIGN_IDENTITY\n\n\n# Signs a framework with the provided identity\ncode_sign() {\n # Use the current code_sign_identitiy\n echo \"Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}\"\n echo \"/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements $1\"\n /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"\n}\n\n# Set working directory to product’s embedded frameworks\ncd \"${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}\"\n\nif [ \"$ACTION\" = \"install\" ]; then\n echo \"Copy .bcsymbolmap files to .xcarchive\"\n find . -name '*.bcsymbolmap' -type f -exec mv {} \"${CONFIGURATION_BUILD_DIR}\" \\;\nelse\n # Delete *.bcsymbolmap files from framework bundle unless archiving\n find . -name '*.bcsymbolmap' -type f -exec rm -rf \"{}\" +\\;\nfi\n\necho \"Stripping frameworks\"\n\nfor file in $(find . -type f -perm +111); do\n # Skip non-dynamic libraries\n if ! [[ \"$(file \"$file\")\" == *\"dynamically linked shared library\"* ]]; then\n continue\n fi\n # Get architectures for current file\n archs=\"$(lipo -info \"${file}\" | rev | cut -d ':' -f1 | rev)\"\n stripped=\"\"\n for arch in $archs; do\n if ! [[ \"${VALID_ARCHS}\" == *\"$arch\"* ]]; then\n # Strip non-valid architectures in-place\n lipo -remove \"$arch\" -output \"$file\" \"$file\" || exit 1\n stripped=\"$stripped $arch\"\n fi\n done\n if [[ \"$stripped\" != \"\" ]]; then\n echo \"Stripped $file of architectures:$stripped\"\n if [ \"${CODE_SIGNING_REQUIRED}\" == \"YES\" ]; then\n code_sign \"${file}\"\n fi\n fi\ndone\n"; + showEnvVarsInLog = 0; }; SSBP_6331376344 /* MyScript */ = { isa = PBXShellScriptBuildPhase; @@ -648,6 +649,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "echo \"You ran a script\"\n"; + showEnvVarsInLog = 0; }; SSBP_8106229290 /* Carthage */ = { isa = PBXShellScriptBuildPhase; @@ -664,6 +666,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "/usr/local/bin/carthage copy-frameworks\n"; + showEnvVarsInLog = 0; }; SSBP_8255377629 /* MyScript */ = { isa = PBXShellScriptBuildPhase; @@ -678,6 +681,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "echo \"You ran a script\"\n"; + showEnvVarsInLog = 0; }; SSBP_8706434794 /* MyScript */ = { isa = PBXShellScriptBuildPhase; @@ -692,6 +696,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "echo \"You ran a script!\"\n"; + showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -2188,7 +2193,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = ""; }; - CL_479264660374 = { + CL_479264660374 /* Build configuration list for PBXLegacyTarget "Legacy" */ = { isa = XCConfigurationList; buildConfigurations = ( BC_805283956103 /* Production Debug */,