Skip to content

Commit f480812

Browse files
committed
Merge branch 'deploy/0.6.3' into productive
2 parents b9bb621 + d258f7f commit f480812

22 files changed

+614
-78
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
1717
### Security
1818
- None.
1919

20+
## [0.6.3] - 2019-07-12
21+
### Added
22+
- None.
23+
### Changed
24+
- None.
25+
### Deprecated
26+
- None.
27+
### Removed
28+
- None.
29+
### Fixed
30+
- Fix mixed caching of frameworks with different Swift versions.
31+
Issue: [#61](https://github.com/JamitLabs/Accio/issues/61) | PR: [#62](https://github.com/JamitLabs/Accio/pull/62) | Author: [Frederick Pietschmann](https://github.com/fredpi)
32+
- Fix missing CFBundleVersion in Info.plist of build Frameworks by adding it implicity with the default value "1"
33+
Issue: [#69](https://github.com/JamitLabs/Accio/issues/69) | PR: [#70](https://github.com/JamitLabs/Accio/pull/70) | Author: [Murat Yilmaz](https://github.com/mrylmz)
34+
### Security
35+
- None.
36+
2037
## [0.6.2] - 2019-06-20
2138
### Added
2239
- None.

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cli.goAndExit()
5757
from the file at path `Sources/Accio/main.swift` with something like:
5858

5959
```swift
60-
cli.debugGo(with: "accio update -d /Users/You/path/to/Accio/Demo -v")
60+
cli.go(with: ["install", "-d", "/Users/You/path/to/Accio/Demo", "-v"])
6161
```
6262

6363
Note that the `-d` option specifies the path from within to run Accio and `-v` makes sure the logging level is set to `verbose`.

Formula/accio.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Accio < Formula
22
desc "Dependency manager driven by SwiftPM for iOS/macOS/tvOS/watchOS"
33
homepage "https://github.com/JamitLabs/Accio"
4-
url "https://github.com/JamitLabs/Accio.git", :tag => "0.6.1", :revision => "6b01bd6458c71eb946402144d6c21e3a855aadac"
4+
url "https://github.com/JamitLabs/Accio.git", :tag => "0.6.2", :revision => "b9bb6215778fccc6c4428101786b582f9217cd75"
55
head "https://github.com/JamitLabs/Accio.git"
66

77
depends_on :xcode => ["10.2", :build]

Package.resolved

+12-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
"version": "4.4.0"
1111
}
1212
},
13+
{
14+
"package": "CryptoSwift",
15+
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
16+
"state": {
17+
"branch": null,
18+
"revision": "3a2acbb32ab68215ee1596ee6004da8e90c3721b",
19+
"version": "1.0.0"
20+
}
21+
},
1322
{
1423
"package": "HandySwift",
1524
"repositoryURL": "https://github.com/Flinesoft/HandySwift.git",
@@ -60,8 +69,8 @@
6069
"repositoryURL": "https://github.com/jakeheis/SwiftCLI.git",
6170
"state": {
6271
"branch": null,
63-
"revision": "5318c37d3cacc8780f50b87a8840a6774320ebdf",
64-
"version": "5.2.2"
72+
"revision": "ba2268e67c07b9f9cfbc0801385e6238b36255eb",
73+
"version": "5.3.2"
6574
}
6675
},
6776
{
@@ -78,7 +87,7 @@
7887
"repositoryURL": "https://github.com/tuist/xcodeproj.git",
7988
"state": {
8089
"branch": "master",
81-
"revision": "50cd5c1a6c52f85d040b0ab3d3714233568ee09f",
90+
"revision": "fca5c6b5cf6a28bae466d0a23080e94f5d8814e6",
8291
"version": null
8392
}
8493
}

Package.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let package = Package(
1010
.library(name: "AccioKit", type: .dynamic, targets: ["AccioKit"])
1111
],
1212
dependencies: [
13+
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMajor(from: "1.0.0")),
1314
.package(url: "https://github.com/Flinesoft/HandySwift.git", .upToNextMajor(from: "3.0.0")),
1415
.package(url: "https://github.com/onevcat/Rainbow.git", .upToNextMajor(from: "3.1.4")),
1516
.package(url: "https://github.com/jakeheis/SwiftCLI.git", .upToNextMajor(from: "5.2.2")),
@@ -24,6 +25,7 @@ let package = Package(
2425
.target(
2526
name: "AccioKit",
2627
dependencies: [
28+
"CryptoSwift",
2729
"HandySwift",
2830
"Rainbow",
2931
"SwiftCLI",
@@ -33,7 +35,7 @@ let package = Package(
3335
),
3436
.testTarget(
3537
name: "AccioKitTests",
36-
dependencies: ["AccioKit", "HandySwift", "XcodeProj"]
38+
dependencies: ["CryptoSwift", "AccioKit", "HandySwift", "XcodeProj"]
3739
)
3840
]
3941
)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
alt="Codebeat Badge">
1414
</a>
1515
<a href="https://github.com/JamitLabs/Accio/releases">
16-
<img src="https://img.shields.io/badge/Version-0.6.2-blue.svg"
17-
alt="Version: 0.6.2">
16+
<img src="https://img.shields.io/badge/Version-0.6.3-blue.svg"
17+
alt="Version: 0.6.3">
1818
</a>
1919
<img src="https://img.shields.io/badge/Swift-5.0-FFAC45.svg"
2020
alt="Swift: 5.0">

Sources/Accio/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Foundation
33
import SwiftCLI
44

55
// MARK: - CLI
6-
let cli = CLI(name: "accio", version: "0.6.2", description: "A dependency manager driven by SwiftPM that works for iOS/tvOS/watchOS/macOS projects.")
6+
let cli = CLI(name: "accio", version: "0.6.3", description: "A dependency manager driven by SwiftPM that works for iOS/tvOS/watchOS/macOS projects.")
77

88
cli.commands = [InitCommand(), InstallCommand(), UpdateCommand(), CleanCommand(), ClearCacheCommand(), SetSharedCacheCommand()]
99
cli.globalOptions.append(contentsOf: GlobalOptions.all)

Sources/AccioKit/Commands/InstallCommand.swift

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public class InstallCommand: Command {
1414
// MARK: - Instance Methods
1515
public func execute() throws {
1616
let config = try Config.load()
17+
18+
if try loadRequiredFrameworksFromCache(sharedCachePath: sharedCachePath.value ?? config.defaultSharedCachePath) {
19+
print("No changes found & successfully copied dependencies from cache.", level: .info)
20+
return
21+
}
22+
1723
try revertCheckoutChanges()
1824
try DependencyResolverService.shared.resolveDependencies()
1925

Sources/AccioKit/Commands/Protocols/DependencyInstaller.swift

+78-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ enum DependencyInstallerError: Error {
88
protocol DependencyInstaller {
99
func loadManifest() throws -> Manifest
1010
func revertCheckoutChanges(workingDirectory: String) throws
11-
func buildFrameworksAndIntegrateWithXcode(manifest: Manifest, dependencyGraph: DependencyGraph, sharedCachePath: String?) throws
11+
func buildFrameworksAndIntegrateWithXcode(workingDirectory: String, manifest: Manifest, dependencyGraph: DependencyGraph, sharedCachePath: String?) throws
12+
func loadRequiredFrameworksFromCache(workingDirectory: String, sharedCachePath: String?) throws -> Bool
1213
}
1314

1415
extension DependencyInstaller {
@@ -47,7 +48,12 @@ extension DependencyInstaller {
4748
}
4849
}
4950

50-
func buildFrameworksAndIntegrateWithXcode(manifest: Manifest, dependencyGraph: DependencyGraph, sharedCachePath: String?) throws {
51+
func buildFrameworksAndIntegrateWithXcode(
52+
workingDirectory: String = GlobalOptions.workingDirectory.value ?? FileManager.default.currentDirectoryPath,
53+
manifest: Manifest,
54+
dependencyGraph: DependencyGraph,
55+
sharedCachePath: String?
56+
) throws {
5157
if FileManager.default.fileExists(atPath: Constants.temporaryFrameworksUrl.path) {
5258
try bash("rm -rf '\(Constants.temporaryFrameworksUrl.path)'")
5359
}
@@ -59,6 +65,8 @@ extension DependencyInstaller {
5965
try bash("mkdir -p '\(Constants.temporaryFrameworksUrl.path)'")
6066
try bash("mkdir -p '\(Constants.temporaryUncachingUrl.path)'")
6167

68+
let swiftVersion = try SwiftVersionDetectorService.shared.getCurrentSwiftVersion()
69+
6270
typealias ParsingResult = (target: AppTarget, platform: Platform, frameworkProducts: [FrameworkProduct])
6371

6472
let appTargets: [AppTarget] = try manifest.appTargets()
@@ -71,7 +79,13 @@ extension DependencyInstaller {
7179
let platform = try PlatformDetectorService.shared.detectPlatform(of: appTarget)
7280
print("Resolving dependencies for target '\(appTarget.targetName)' on platform '\(platform.rawValue)' ...", level: .info)
7381

74-
let frameworkProducts = try CachedBuilderService(sharedCachePath: sharedCachePath).frameworkProducts(manifest: manifest, appTarget: appTarget, dependencyGraph: dependencyGraph, platform: platform)
82+
let frameworkProducts = try CachedBuilderService(sharedCachePath: sharedCachePath).frameworkProducts(
83+
manifest: manifest,
84+
appTarget: appTarget,
85+
dependencyGraph: dependencyGraph,
86+
platform: platform,
87+
swiftVersion: swiftVersion
88+
)
7589
return ParsingResult(target: appTarget, platform: platform, frameworkProducts: frameworkProducts)
7690
}
7791

@@ -83,5 +97,66 @@ extension DependencyInstaller {
8397

8498
try XcodeProjectIntegrationService.shared.handleRemovedTargets(keepingTargets: appTargets)
8599
try bash("rm -rf '\(Constants.temporaryFrameworksUrl.path)'")
100+
101+
try ResolvedManifestCachingService(sharedCachePath: sharedCachePath).cacheResolvedManifest(
102+
at: URL(fileURLWithPath: workingDirectory).appendingPathComponent("Package.resolved"),
103+
with: parsingResults.flatMap {
104+
$0.frameworkProducts.map {
105+
CachedFrameworkProduct(
106+
libraryName: $0.libraryName,
107+
commitHash: $0.commitHash,
108+
platform: $0.platformName
109+
)
110+
}
111+
}
112+
)
113+
}
114+
115+
func loadRequiredFrameworksFromCache(
116+
workingDirectory: String = GlobalOptions.workingDirectory.value ?? FileManager.default.currentDirectoryPath,
117+
sharedCachePath: String?
118+
) throws -> Bool {
119+
let cachingService = ResolvedManifestCachingService(sharedCachePath: sharedCachePath)
120+
121+
guard let cachedFrameworkProducts = try cachingService.cachedFrameworkProducts(
122+
forResolvedManifestAt: URL(fileURLWithPath: workingDirectory).appendingPathComponent("Package.resolved")
123+
) else {
124+
return false
125+
}
126+
127+
let cachedFrameworkProductUrls: [URL] = cachedFrameworkProducts.compactMap { cachedFrameworkProduct in
128+
guard let cacheFileSubPath = try? cachedFrameworkProduct.getCacheFileSubPath() else { return nil }
129+
130+
let localCacheFileUrl = URL(fileURLWithPath: Constants.localCachePath).appendingPathComponent(cacheFileSubPath)
131+
if FileManager.default.fileExists(atPath: localCacheFileUrl.path) {
132+
return localCacheFileUrl
133+
}
134+
135+
if let sharedCachePath = sharedCachePath {
136+
let sharedCacheFileUrl = URL(fileURLWithPath: sharedCachePath).appendingPathComponent(cacheFileSubPath)
137+
138+
if FileManager.default.fileExists(atPath: sharedCacheFileUrl.path) {
139+
return sharedCacheFileUrl
140+
}
141+
}
142+
143+
return nil
144+
}
145+
146+
guard cachedFrameworkProductUrls.count == cachedFrameworkProducts.count else {
147+
print("Not all required build products specified in resolved manifest are cached – unable to skip checkout / integration process ...", level: .info)
148+
return false
149+
}
150+
151+
print("Found all required build products specified in resolved manifest in cache – skipping checkout & integration process ...", level: .info)
152+
153+
let frameworkProducts: [FrameworkProduct] = try cachedFrameworkProductUrls.map {
154+
return try FrameworkCachingService(sharedCachePath: sharedCachePath).frameworkProduct(forCachedFileAt: $0)
155+
}
156+
157+
try XcodeProjectIntegrationService.shared.clearDependenciesFolder()
158+
try XcodeProjectIntegrationService.shared.copy(cachedFrameworkProducts: frameworkProducts)
159+
160+
return true
86161
}
87162
}

Sources/AccioKit/Globals/Constants.swift

-14
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,4 @@ enum Constants {
1919

2020
return FileManager.userCacheDirUrl.appendingPathComponent("Accio/Cache").path
2121
}
22-
23-
static var swiftVersion: String {
24-
#if swift(>=6.0)
25-
return "Swift-6.0"
26-
#elseif swift(>=5.2)
27-
return "Swift-5.2"
28-
#elseif swift(>=5.1)
29-
return "Swift-5.1"
30-
#elseif swift(>=5.0)
31-
return "Swift-5.0"
32-
#else
33-
return "Swift-4.2"
34-
#endif
35-
}
3622
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
3+
struct CachedFrameworkProduct: Codable {
4+
let libraryName: String
5+
let commitHash: String
6+
let platform: String
7+
8+
func getCacheFileSubPath() throws -> String {
9+
let swiftVersion = try SwiftVersionDetectorService.shared.getCurrentSwiftVersion()
10+
return "\(swiftVersion)/\(libraryName)/\(commitHash)/\(platform).zip"
11+
}
12+
}

Sources/AccioKit/Models/FrameworkProduct.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import Foundation
33
struct FrameworkProduct {
44
let frameworkDirPath: String
55
let symbolsFilePath: String
6+
let commitHash: String
67

7-
init(frameworkDirPath: String, symbolsFilePath: String) {
8+
init(frameworkDirPath: String, symbolsFilePath: String, commitHash: String) {
89
self.frameworkDirPath = frameworkDirPath
910
self.symbolsFilePath = symbolsFilePath
11+
self.commitHash = commitHash
1012
}
1113

12-
init(libraryName: String, platformName: String) {
14+
init(libraryName: String, platformName: String, commitHash: String) {
1315
self.frameworkDirPath = Constants.temporaryFrameworksUrl.appendingPathComponent("\(platformName)/\(libraryName).framework").path
1416
self.symbolsFilePath = Constants.temporaryFrameworksUrl.appendingPathComponent("\(platformName)/\(libraryName).framework.dSYM").path
17+
self.commitHash = commitHash
1518
}
1619

1720
var frameworkDirUrl: URL {
@@ -26,6 +29,10 @@ struct FrameworkProduct {
2629
return frameworkDirUrl.lastPathComponent.replacingOccurrences(of: ".framework", with: "")
2730
}
2831

32+
var platformName: String {
33+
return frameworkDirUrl.pathComponents.suffix(2).first!
34+
}
35+
2936
// This is a workaround for issues with frameworks that symlink to themselves (first found in RxSwift)
3037
func cleanupRecursiveFrameworkIfNeeded() throws {
3138
let recursiveFrameworkPath: String = frameworkDirUrl.appendingPathComponent(frameworkDirUrl.lastPathComponent).path

0 commit comments

Comments
 (0)