Skip to content

Commit

Permalink
Merge pull request #448 from equalitie/darwin
Browse files Browse the repository at this point in the history
Build for iOS using static linking
  • Loading branch information
madadam authored Dec 11, 2024
2 parents 46d4cce + 8174696 commit 616251a
Show file tree
Hide file tree
Showing 92 changed files with 1,594 additions and 1,656 deletions.
25 changes: 20 additions & 5 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668"
channel: "stable"

project_type: app
Expand All @@ -13,11 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: android
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: ios
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: linux
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: macos
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: web
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
- platform: windows
create_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668
base_revision: dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668

# User provided section

Expand Down
8 changes: 8 additions & 0 deletions darwin/OuisyncBackend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
33 changes: 33 additions & 0 deletions darwin/OuisyncBackend/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version: 5.9
import PackageDescription


/* This package hosts functionality that is shared by the ios and macos versions of the file
provider extension. It is currently used for:
* mapping rust data models to those expected by the platform
* white-label implementation of the file provider(s): because code in extension targets is not
currently importable by tests, our extensions import and rename the class(es) defined here

Before committing code to this package, consider the following questions:
1. is the code only useful to our extensions? otherwise it might belong to `OuisyncCommon` (at the
very least as an IPC protocol that calls into the extension that then links with this package)
2. is the code only useful to our app? otherwise it might belong to the `OuisyncLib` swift
bindings or even into the rust core library */
let package = Package(
name: "OuisyncBackend",
platforms: [.iOS(.v16), .macOS(.v13)],
products: [
.library(name: "OuisyncBackend",
targets: ["OuisyncBackend"]),
],
dependencies: [
.package(path: "../OuisyncCommon"),
.package(path: "../../ouisync/bindings/swift/OuisyncLib")
],
targets: [
.target(name: "OuisyncBackend",
dependencies: [.product(name: "OuisyncCommon", package: "OuisyncCommon"),
.product(name: "OuisyncLib", package: "OuisyncLib")],
path: "Sources"),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// Created by Peter Jankuliak on 24/05/2024.
//

import Foundation
import FileProvider
import Foundation


extension NSFileProviderSyncAnchor: CustomDebugStringConvertible {
public var debugDescription: String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// Created by Peter Jankuliak on 04/06/2024.
//

import Foundation
import FileProvider
import Foundation


extension NSFileProviderItemFields: CustomDebugStringConvertible {
static public var debugDescriptions: [(Self, String)] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
//
// Created by Peter Jankuliak on 15/03/2024.
//

import FileProvider
import OuisyncCommon
import OuisyncLib


class Enumerator: NSObject, NSFileProviderEnumerator {
private let session: OuisyncSession
private let itemId: ItemIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//
// Created by Peter Jankuliak on 25/03/2024.
//

import Common
import FileProvider
import OuisyncCommon
import OuisyncLib


class ExtError {
static var noSuchItem: NSError {
NSError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
//
// Created by Peter Jankuliak on 25/03/2024.
//

import Common
import Foundation
import FileProvider
import Foundation
import OuisyncCommon
import OuisyncLib


extension Extension: NSFileProviderServicing {
public func supportedServiceSources(for itemIdentifier: NSFileProviderItemIdentifier,
completionHandler: @escaping ([NSFileProviderServiceSource]?, Error?) -> Void) -> Progress {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
//
// Created by Peter Jankuliak on 15/03/2024.
//

import FileProvider
import Network
import OuisyncLib
import System
import OuisyncCommon
import OSLog
import Common
import Network
import System


open class Extension: NSObject, NSFileProviderReplicatedExtension {
static let WRITE_CHUNK_SIZE: UInt64 = 32768 // TODO: Decide on optimal value
Expand Down Expand Up @@ -539,7 +539,7 @@ open class Extension: NSObject, NSFileProviderReplicatedExtension {
do {
try await manager.signalEnumerator(for: .workingSet)
} catch let error as NSError {
NSLog("❌ failed to signal working set for \(Common.ouisyncFileProviderDomain): \(error)")
NSLog("❌ failed to signal working set for \(ouisyncFileProviderDomain): \(error)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// Created by Peter Jankuliak on 10/06/2024.
//

import Foundation


struct Hash: Codable, Equatable, CustomDebugStringConvertible {
let data: Data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
//
// Created by Peter Jankuliak on 15/03/2024.
//

import FileProvider
import UniformTypeIdentifiers
import MessagePack
import OuisyncLib
import System
import UniformTypeIdentifiers


enum EntryItem: Hashable, Equatable, CustomDebugStringConvertible {
case file(FileItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
//
// Created by Peter Jankuliak on 22/05/2024.
//

import Foundation
import FileProvider
import Foundation
import OuisyncLib
import System // for FilePath


typealias RepoName = String


enum ItemIdentifier: CustomDebugStringConvertible, Hashable, Equatable {
case rootContainer
case trashContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//
// Created by Peter Jankuliak on 17/04/2024.
//

import Foundation
import System


public class Path {
public let path: FilePath

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// Created by Peter Jankuliak on 18/06/2024.
//

import Foundation
import FileProvider
import Foundation


enum Version: Codable, CustomDebugStringConvertible {
case valid(ValidVersion)
Expand Down
8 changes: 8 additions & 0 deletions darwin/OuisyncCommon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
24 changes: 24 additions & 0 deletions darwin/OuisyncCommon/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version: 5.9
import PackageDescription


/* This package hosts functionality that is shared by the ios and macos versions of the client,
regardless of entry point (app vs extension). It is best suited for:
* common configuration options like well known ids and paths
* IPC protocols, shared between providers and consumers
* tools that work around or abstract over operating system behavior
* backports of functionality that is not available on older operating systems

Intentionally does not link with the rust core library, see `OuisyncBackend` if you need that. */
let package = Package(
name: "OuisyncCommon",
platforms: [.iOS(.v16), .macOS(.v13)],
products: [
.library(name: "OuisyncCommon",
targets: ["OuisyncCommon"]),
],
targets: [
.target(name: "OuisyncCommon",
path: "Sources"),
]
)
5 changes: 5 additions & 0 deletions darwin/OuisyncCommon/Sources/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class Constants {
// TODO: merge the following:
public static let flutterConfigChannel = "org.equalitie.ouisync/native"
public static let flutterForwardingChannel = "org.equalitie.ouisync/backend"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@

import Foundation


#if os(macOS)
private let appGroup = "5SR9R72Z83.org.equalitie.ouisync"
#else
private let appGroup = "group.org.equalitie"
#endif
private let rootURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)!


public class Directories {
private static let rootURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "5SR9R72Z83.org.equalitie.ouisync")!
public static let rootPath = rootURL.path(percentEncoded: false)
public static let configsPath = rootPath + "config"
public static let logsPath = rootPath + "logs/ouisync.log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ public let ouisyncFileProviderDomain = NSFileProviderDomain(identifier: ouisyncF
// Used to send notifications from the extension's backend to Flutter.
func fromFileProviderToApp(_ message: [UInt8])
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//
// Created by Peter Jankuliak on 04/06/2024.
//

import Foundation

class Log {
enum Level: UInt8 {

public class Log {
public enum Level: UInt8 {
case trace = 0
case info
case error
Expand All @@ -22,7 +22,7 @@ class Log {
fileprivate var nextChildId: UInt64 = 0
var selfLevel: Level? = nil

init(_ label: String) {
public init(_ label: String) {
self.parent = nil
self.label = label
self.id = Self.nextRootId
Expand All @@ -37,22 +37,22 @@ class Log {
parent.nextChildId += 1
}

func child(_ label: String) -> Log {
public func child(_ label: String) -> Log {
Log(label, self, selfLevel)
}

@discardableResult
func trace(_ msg: String) -> Log {
public func trace(_ msg: String) -> Log {
print(.trace, msg)
}

@discardableResult
func info(_ msg: String) -> Log {
public func info(_ msg: String) -> Log {
print(.info, msg)
}

@discardableResult
func error(_ msg: String) -> Log {
public func error(_ msg: String) -> Log {
print(.error, msg)
}

Expand All @@ -64,7 +64,7 @@ class Log {
return self
}

func level(_ l: Level) -> Log {
public func level(_ l: Level) -> Log {
self.selfLevel = l
return self
}
Expand Down
Loading

0 comments on commit 616251a

Please sign in to comment.