Reorganize files in repo, pull out build settings from pbxproj (#1140)

This is somewhat in prep of being able to make the project file generated, but also just organizes things into more concrete directory structures.

This pulls out _all_ of the build settings from the root level, and most from the target level, into xcconfigs.

The new directory structure looks like:

- Sources
  - App
    - (everything from HomeAssistant/)
  - WatchApp
  - Shared
  - MacBridge
  - Extensions
    - Intents
    - NotificationContent
    - NotificationService
    - Share
    - Today
    - Watch
    - Widgets
- Tests
  - App
  - UI
  - Shared

Somewhat intentionally, the file structure under these is not yet standardized/organized.

The project targets are now:

- App
- WatchApp
- Shared-iOS
- Shared-watchOS
- MacBridge
- Tests-App
- Tests-UI
- Tests-Shared
- Extension-Intents
- Extension-NotificationContent
- Extension-NotificationService
- Extension-Share
- Extension-Today
- Extension-Widget
- WatchExtension-Watch

This does not yet clean up resources vs. sources, nor does it handle some of the "it's in Sources/App but it's part of Shared" crossover directory issues.
This commit is contained in:
Zac West
2020-10-03 00:15:04 -07:00
committed by GitHub
parent 9dc83910d5
commit 4d9a530637
806 changed files with 490 additions and 1061 deletions

View File

@@ -0,0 +1,97 @@
//
// WebSocketMessage.swift
// HomeAssistant
//
// Created by Robert Trencheny on 4/9/19.
// Copyright © 2019 Robbie Trencheny. All rights reserved.
//
import Foundation
public class WebSocketMessage: Codable {
public let MessageType: String
public var ID: Int?
public var Success: Bool?
public var Payload: [String: Any]?
public var Result: [String: Any]?
public var Message: String?
public var HAVersion: String?
private enum CodingKeys: String, CodingKey {
case MessageType = "type"
case ID = "id"
case Success = "success"
case Payload = "payload"
case Result = "result"
case Message = "message"
case HAVersion = "ha_version"
}
required public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
MessageType = try values.decode(String.self, forKey: .MessageType)
ID = try? values.decode(Int.self, forKey: .ID)
Success = try? values.decode(Bool.self, forKey: .Success)
Payload = try? values.decode([String: Any].self, forKey: .Payload)
Result = try? values.decode([String: Any].self, forKey: .Result)
Message = try? values.decode(String.self, forKey: .Message)
HAVersion = try? values.decode(String.self, forKey: .HAVersion)
}
public init?(_ dictionary: [String: Any]) {
guard let mType = dictionary["type"] as? String else {
return nil
}
self.MessageType = mType
self.ID = dictionary["id"] as? Int
self.Payload = dictionary["payload"] as? [String: Any]
self.Result = dictionary["result"] as? [String: Any]
self.Success = dictionary["success"] as? Bool
}
public init(_ incomingMessage: WebSocketMessage, _ result: [String: Any]) {
self.ID = incomingMessage.ID
self.MessageType = "result"
self.Result = result
self.Success = true
}
public init(id: Int, type: String, result: [String: Any], success: Bool = true) {
self.ID = id
self.MessageType = type
self.Result = result
self.Success = success
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(MessageType, forKey: .MessageType)
if let ID = ID {
try container.encode(ID, forKey: .ID)
}
if let Success = Success {
try container.encode(Success, forKey: .Success)
}
if let Message = Message {
try container.encode(Message, forKey: .Message)
}
if let Result = Result {
try container.encode(Result, forKey: .Result)
}
}
init(_ messageType: String) {
self.MessageType = messageType
}
}
extension WebSocketMessage: CustomStringConvertible, CustomDebugStringConvertible {
public var description: String {
// swiftlint:disable:next line_length
return "WebSocketMessage(type: \(self.MessageType), id: \(String(describing: self.ID)), payload: \(String(describing: self.Payload)), result: \(String(describing: self.Result)), success: \(String(describing: self.Success)))"
}
public var debugDescription: String {
return self.description
}
}