Skip to content

Commit

Permalink
Update to 1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yonaskolb committed Jul 3, 2018
1 parent 0b7353b commit 01815e7
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TOOL_NAME = XcodeGen
export EXECUTABLE_NAME = xcodegen
VERSION = 1.9.0
VERSION = 1.10.0

PREFIX = /usr/local
INSTALL_PATH = $(PREFIX)/bin/$(EXECUTABLE_NAME)
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ extension Target: NamedJSONDictionaryConvertible {
dependencies = try jsonDictionary.json(atKeyPath: "dependencies", invalidItemBehaviour: .fail)
}
transientlyLinkDependencies = jsonDictionary.json(atKeyPath: "transientlyLinkDependencies")

prebuildScripts = jsonDictionary.json(atKeyPath: "prebuildScripts") ?? []
postbuildScripts = jsonDictionary.json(atKeyPath: "postbuildScripts") ?? []
buildRules = jsonDictionary.json(atKeyPath: "buildRules") ?? []
Expand Down
2 changes: 1 addition & 1 deletion Sources/ProjectSpec/XCProjExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension PBXProductType {
public var isTest: Bool {
return fileExtension == "xctest"
}

public var isExecutable: Bool {
return isApp || isExtension || isTest
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGen/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ProjectSpec
import XcodeGenKit
import xcproj

let version = "1.9.0"
let version = "1.10.0"

func generate(spec: String, project: String, isQuiet: Bool, justVersion: Bool) {
if justVersion {
Expand Down
18 changes: 9 additions & 9 deletions Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public class PBXProjGenerator {
var copyResourcesReferences: [String] = []
var copyWatchReferences: [String] = []
var extensions: [String] = []

let targetDependencies = (target.transientlyLinkDependencies ?? project.options.transientlyLinkDependencies) ?
getAllDependenciesPlusTransientNeedingEmbedding(target: target) : target.dependencies

Expand Down Expand Up @@ -444,7 +444,7 @@ public class PBXProjGenerator {
)
targetFrameworkBuildFiles.append(buildFile.reference)
}

let shouldEmbed = target.type.isApp
|| (target.type.isTest && (dependencyTarget.type.isFramework || dependencyTarget.type == .bundle))
if (dependency.embed ?? shouldEmbed) && !dependencyTarget.type.isLibrary {
Expand Down Expand Up @@ -500,7 +500,7 @@ public class PBXProjGenerator {
)
copyFrameworksReferences.append(embedFile.reference)
}

case .carthage:
var platformPath = Path(getCarthageBuildPath(platform: target.platform))
var frameworkPath = platformPath + dependency.reference
Expand Down Expand Up @@ -747,7 +747,7 @@ public class PBXProjGenerator {

return frameworks
}

func getAllDependenciesPlusTransientNeedingEmbedding(target topLevelTarget: Target) -> [Dependency] {
// this is used to resolve cyclical target dependencies
var visitedTargets: Set<String> = []
Expand All @@ -758,15 +758,15 @@ public class PBXProjGenerator {
if visitedTargets.contains(target.name) {
continue
}

let isTopLevel = target == topLevelTarget

for dependency in target.dependencies {
// don't overwrite dependencies, to allow top level ones to rule
if dependencies.contains(reference: dependency.reference) {
continue
}

// don't want a dependency if it's going to be embedded or statically linked in a non-top level target
// in .target check we filter out targets that will embed all of their dependencies
switch dependency.type {
Expand All @@ -786,10 +786,10 @@ public class PBXProjGenerator {
}
}
}

visitedTargets.update(with: target.name)
}

return dependencies.sorted(by: { $0.key < $1.key }).map { $0.value }
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XcodeGenKit/ProjectGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class ProjectGenerator {
}
return XCScheme.ExecutionAction(scriptText: action.script, title: action.name, environmentBuildable: environmentBuildable)
}

let target = project.getTarget(scheme.build.targets.first!.target)
let shouldExecuteOnLaunch = target?.type.isExecutable == true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,71 +1,63 @@
//
// MessagesViewController.swift
// IMessage MessagesExtension
//
// Created by Yonas Kolb on 26/6/18.
//

import UIKit
import Messages
import UIKit

class MessagesViewController: MSMessagesAppViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

// MARK: - Conversation Handling

override func willBecomeActive(with conversation: MSConversation) {
// Called when the extension is about to move from the inactive to active state.
// This will happen when the extension is about to present UI.

// Use this method to configure the extension and restore previously stored state.
}

override func didResignActive(with conversation: MSConversation) {
// Called when the extension is about to move from the active to inactive state.
// This will happen when the user dissmises the extension, changes to a different
// conversation or quits Messages.

// Use this method to release shared resources, save user data, invalidate timers,
// and store enough state information to restore your extension to its current state
// in case it is terminated later.
}

override func didReceive(_ message: MSMessage, conversation: MSConversation) {
// Called when a message arrives that was generated by another instance of this
// extension on a remote device.

// Use this method to trigger UI updates in response to the message.
}

override func didStartSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user taps the send button.
}

override func didCancelSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user deletes the message without sending it.

// Use this to clean up state related to the deleted message.
}

override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called before the extension transitions to a new presentation style.

// Use this method to prepare for the change in presentation style.
}

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called after the extension transitions to a new presentation style.

// Use this method to finalize any behaviors associated with the change in presentation style.
}

}
37 changes: 19 additions & 18 deletions Tests/XcodeGenKitTests/ProjectGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class ProjectGeneratorTests: XCTestCase {
try expect(dependencies[0].object.target) == nativeTargets.first { $0.object.name == framework.name }!.reference
try expect(dependencies[1].object.target) == nativeTargets.first { $0.object.name == app.name }!.reference
}

$0.it("generates targets with correct transient embeds") {
// App # Embeds it's frameworks, so shouldn't embed in tests
// dependencies:
Expand Down Expand Up @@ -321,11 +321,11 @@ class ProjectGeneratorTests: XCTestCase {
// - target: iOSFrameworkB
// - carthage: CarthageD
//

var expectedResourceFiles: [String: Set<String>] = [:]
var expectedLinkedFiles: [String: Set<String>] = [:]
var expectedEmbeddedFrameworks: [String: Set<String>] = [:]

let app = Target(
name: "App",
type: .application,
Expand All @@ -344,7 +344,7 @@ class ProjectGeneratorTests: XCTestCase {
expectedEmbeddedFrameworks[app.name] = Set([
"FrameworkA.framework",
])

let staticLibrary = Target(
name: "StaticLibrary",
type: .staticLibrary,
Expand All @@ -355,7 +355,7 @@ class ProjectGeneratorTests: XCTestCase {
expectedResourceFiles[staticLibrary.name] = Set()
expectedLinkedFiles[staticLibrary.name] = Set([])
expectedEmbeddedFrameworks[staticLibrary.name] = Set()

let resourceBundle = Target(
name: "ResourceBundle",
type: .bundle,
Expand All @@ -365,7 +365,7 @@ class ProjectGeneratorTests: XCTestCase {
expectedResourceFiles[resourceBundle.name] = Set()
expectedLinkedFiles[resourceBundle.name] = Set()
expectedEmbeddedFrameworks[resourceBundle.name] = Set()

let iosFrameworkA = Target(
name: "iOSFrameworkA",
type: .framework,
Expand All @@ -387,7 +387,7 @@ class ProjectGeneratorTests: XCTestCase {
"CarthageB.framework",
])
expectedEmbeddedFrameworks[iosFrameworkA.name] = Set()

let iosFrameworkB = Target(
name: "iOSFrameworkB",
type: .framework,
Expand Down Expand Up @@ -415,7 +415,7 @@ class ProjectGeneratorTests: XCTestCase {
expectedEmbeddedFrameworks[iosFrameworkB.name] = Set([
"FrameworkE.framework",
])

let appTest = Target(
name: "AppTest",
type: .unitTestBundle,
Expand Down Expand Up @@ -443,7 +443,7 @@ class ProjectGeneratorTests: XCTestCase {
iosFrameworkB.filename,
"FrameworkD.framework",
])

var appTestWithoutTransient = appTest
appTestWithoutTransient.name = "AppTestWithoutTransient"
appTestWithoutTransient.transientlyLinkDependencies = false
Expand All @@ -455,17 +455,17 @@ class ProjectGeneratorTests: XCTestCase {
expectedEmbeddedFrameworks[appTestWithoutTransient.name] = Set([
iosFrameworkB.filename,
])

let targets = [app, staticLibrary, resourceBundle, iosFrameworkA, iosFrameworkB, appTest, appTestWithoutTransient]

let project = Project(
basePath: "",
name: "test",
targets: targets,
options: SpecOptions(transientlyLinkDependencies: true)
)
let pbxProject = try project.generatePbxProj()

for target in targets {
guard let nativeTarget = pbxProject.objects.nativeTargets.referenceValues.first(where: { $0.name == target.name }) else {
throw failure("PBXNativeTarget for \(target) not found")
Expand All @@ -474,7 +474,7 @@ class ProjectGeneratorTests: XCTestCase {
let resourcesPhases = pbxProject.objects.resourcesBuildPhases.objectReferences.filter { buildPhases.contains($0.reference) }
let frameworkPhases = pbxProject.objects.frameworksBuildPhases.objectReferences.filter { buildPhases.contains($0.reference) }
let copyFilesPhases = pbxProject.objects.copyFilesBuildPhases.objectReferences.filter { buildPhases.contains($0.reference) }

// ensure only the right resources are copies, no more, no less
let expectedResourceFiles = expectedResourceFiles[target.name]!
try expect(resourcesPhases.count) == (expectedResourceFiles.isEmpty ? 0 : 1)
Expand All @@ -483,7 +483,7 @@ class ProjectGeneratorTests: XCTestCase {
.compactMap { pbxProject.objects.buildFiles[$0]?.fileRef.flatMap { pbxProject.objects.fileReferences[$0]?.nameOrPath } }
try expect(Set(resourceFiles)) == expectedResourceFiles
}

// ensure only the right things are linked, no more, no less
let expectedLinkedFiles = expectedLinkedFiles[target.name]!
try expect(frameworkPhases.count) == (expectedLinkedFiles.isEmpty ? 0 : 1)
Expand All @@ -492,7 +492,7 @@ class ProjectGeneratorTests: XCTestCase {
.compactMap { pbxProject.objects.buildFiles[$0]?.fileRef.flatMap { pbxProject.objects.fileReferences[$0]?.nameOrPath } }
try expect(Set(linkFrameworks)) == expectedLinkedFiles
}

// ensure only the right things are embedded, no more, no less
let expectedEmbeddedFrameworks = expectedEmbeddedFrameworks[target.name]!
try expect(copyFilesPhases.count) == (expectedEmbeddedFrameworks.isEmpty ? 0 : 1)
Expand Down Expand Up @@ -557,10 +557,12 @@ class ProjectGeneratorTests: XCTestCase {
action: .script("do thing"),
name: "My Rule",
outputFiles: ["file1.swift", "file2.swift"],
outputFilesCompilerFlags: ["--zee", "--bee"]),
outputFilesCompilerFlags: ["--zee", "--bee"]
),
BuildRule(
fileType: .pattern("*.plist"),
action: .compilerSpec("com.apple.build-tasks.copy-plist-file"))
action: .compilerSpec("com.apple.build-tasks.copy-plist-file")
),
]
let pbxProject = try scriptSpec.generatePbxProj()

Expand All @@ -585,7 +587,6 @@ class ProjectGeneratorTests: XCTestCase {
try expect(second.script).beNil()
try expect(second.outputFiles) == []
try expect(second.outputFilesCompilerFlags) == []

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/XcodeGenKitTests/SpecLoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ class SpecLoadingTests: XCTestCase {
$0.it("decodes dots in dictionary keys") {
let dictionary: [String: Any] = [
"test": [
"one.two": true
]
"one.two": true,
],
]

let booleans: [String: Bool] = try dictionary.json(atKeyPath: "test")
Expand Down

0 comments on commit 01815e7

Please sign in to comment.