Modularization: Extract Tor into a separate module (#602)

* Extract Tor into a separate module

* Add Tor package as a dependency for iOS & macOS targets

* Move `tor-nolzma.xcframework` inside Tor

* Remove `libz` from Frameworks as its linked in Tor

* Remove stray `.gitkeep` from macOS target membership

* Fix missing import and access control for modularized Tor

- Add import Tor to NetworkActivationService
- Make TorManager.shutdownCompletely() public for external access

* Fix tor-nolzma.xcframework structure for Xcode builds

- Add missing Info.plist files to all framework slices
- Restructure macOS framework to use deep bundle format (Versions/)
- Keep iOS frameworks as shallow bundles (standard for iOS)

This fixes the Xcode build errors while maintaining SPM compatibility.

* Remove stale xcframework references from Xcode project

Xcode cleaned up old direct references to tor-nolzma.xcframework
since it's now managed internally by the Tor Swift package.

---------

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
Islam
2025-10-02 10:53:34 +01:00
committed by GitHub
parent 787386c66d
commit 3a35b3acc2
2271 changed files with 166 additions and 55 deletions
+3 -15
View File
@@ -16,6 +16,7 @@ let package = Package(
),
],
dependencies:[
.package(path: "localPackages/Tor"),
.package(path: "localPackages/BitLogger"),
.package(url: "https://github.com/21-DOT-DEV/swift-secp256k1", exact: "0.21.1")
],
@@ -25,8 +26,7 @@ let package = Package(
dependencies: [
.product(name: "P256K", package: "swift-secp256k1"),
.product(name: "BitLogger", package: "BitLogger"),
.target(name: "TorC"),
.target(name: "tor-nolzma")
.product(name: "Tor", package: "Tor")
],
path: "bitchat",
exclude: [
@@ -34,24 +34,12 @@ let package = Package(
"Assets.xcassets",
"bitchat.entitlements",
"bitchat-macOS.entitlements",
"LaunchScreen.storyboard",
"Services/Tor/C/"
"LaunchScreen.storyboard"
],
resources: [
.process("Localizable.xcstrings")
],
linkerSettings: [
.linkedLibrary("z")
]
),
.target(
name: "TorC",
path: "bitchat/Services/Tor/C"
),
.binaryTarget(
name: "tor-nolzma",
path: "Frameworks/tor-nolzma.xcframework"
),
.testTarget(
name: "bitchatTests",
dependencies: ["bitchat"],
+19 -21
View File
@@ -7,15 +7,13 @@
objects = {
/* Begin PBXBuildFile section */
0481A35D2E6DA18600FC845E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 0481A35C2E6DA18600FC845E /* libz.tbd */; };
0481A3A02E744D6300FC845E /* tor-nolzma.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0481A39F2E744D6300FC845E /* tor-nolzma.xcframework */; };
0481A3A12E744D6300FC845E /* tor-nolzma.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0481A39F2E744D6300FC845E /* tor-nolzma.xcframework */; };
048A88812E76FD18000FBCDD /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 0481A35C2E6DA18600FC845E /* libz.tbd */; };
17901751FD8010AFC8E750F2 /* bitchatShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 61F92EBA29C47C0FCC482F1F /* bitchatShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
3EE336D150427F736F32B56C /* P256K in Frameworks */ = {isa = PBXBuildFile; productRef = B1D9136AA0083366353BFA2F /* P256K */; };
885BBED78092484A5B069461 /* P256K in Frameworks */ = {isa = PBXBuildFile; productRef = 4EB6BA1B8464F1EA38F4E286 /* P256K */; };
A6E3E5702E77036A0032EA8A /* BitLogger in Frameworks */ = {isa = PBXBuildFile; productRef = A6E3E56F2E77036A0032EA8A /* BitLogger */; };
A6E3E5722E7703760032EA8A /* BitLogger in Frameworks */ = {isa = PBXBuildFile; productRef = A6E3E5712E7703760032EA8A /* BitLogger */; };
A6E3EA7F2E7706720032EA8A /* Tor in Frameworks */ = {isa = PBXBuildFile; productRef = A6E3EA7E2E7706720032EA8A /* Tor */; };
A6E3EA812E7706A80032EA8A /* Tor in Frameworks */ = {isa = PBXBuildFile; productRef = A6E3EA802E7706A80032EA8A /* Tor */; };
E0A1B2C3D4E5F6012345678D /* relays/online_relays_gps.csv in Resources */ = {isa = PBXBuildFile; fileRef = E0A1B2C3D4E5F6012345678A /* relays/online_relays_gps.csv */; };
E0A1B2C3D4E5F6012345678E /* relays/online_relays_gps.csv in Resources */ = {isa = PBXBuildFile; fileRef = E0A1B2C3D4E5F6012345678A /* relays/online_relays_gps.csv */; };
/* End PBXBuildFile section */
@@ -58,8 +56,6 @@
/* Begin PBXFileReference section */
03C57F452B55FD0FD8F51421 /* bitchatTests_macOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = bitchatTests_macOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0481A35C2E6DA18600FC845E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
0481A39F2E744D6300FC845E /* tor-nolzma.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = "tor-nolzma.xcframework"; sourceTree = "<group>"; };
61F92EBA29C47C0FCC482F1F /* bitchatShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = bitchatShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
8F3A7C058C2C8E1A06C8CF8B /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
96D0D41CA19EE5A772AA8434 /* bitchat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bitchat.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -87,7 +83,6 @@
membershipExceptions = (
Info.plist,
LaunchScreen.storyboard,
Services/Tor/C/include/.gitkeep,
);
target = 0576A29205865664C0937536 /* bitchat_macOS */;
};
@@ -136,32 +131,21 @@
isa = PBXFrameworksBuildPhase;
files = (
A6E3E5722E7703760032EA8A /* BitLogger in Frameworks */,
048A88812E76FD18000FBCDD /* libz.tbd in Frameworks */,
0481A3A02E744D6300FC845E /* tor-nolzma.xcframework in Frameworks */,
3EE336D150427F736F32B56C /* P256K in Frameworks */,
A6E3EA812E7706A80032EA8A /* Tor in Frameworks */,
);
};
B5A5CC493FFB3D8966548140 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
files = (
A6E3E5702E77036A0032EA8A /* BitLogger in Frameworks */,
0481A35D2E6DA18600FC845E /* libz.tbd in Frameworks */,
0481A3A12E744D6300FC845E /* tor-nolzma.xcframework in Frameworks */,
885BBED78092484A5B069461 /* P256K in Frameworks */,
A6E3EA7F2E7706720032EA8A /* Tor in Frameworks */,
);
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0481A3542E6D877600FC845E /* Frameworks */ = {
isa = PBXGroup;
children = (
0481A39F2E744D6300FC845E /* tor-nolzma.xcframework */,
0481A35C2E6DA18600FC845E /* libz.tbd */,
);
path = Frameworks;
sourceTree = "<group>";
};
18198ED912AAF495D8AF7763 = {
isa = PBXGroup;
children = (
@@ -170,7 +154,6 @@
A6E32D212E762EAB0032EA8A /* bitchatShareExtension */,
A6E32D412E762EAE0032EA8A /* bitchatTests */,
A6E367C92E76469E0032EA8A /* Configs */,
0481A3542E6D877600FC845E /* Frameworks */,
9F37F9F2C353B58AC809E93B /* Products */,
);
sourceTree = "<group>";
@@ -207,6 +190,7 @@
packageProductDependencies = (
B1D9136AA0083366353BFA2F /* P256K */,
A6E3E5712E7703760032EA8A /* BitLogger */,
A6E3EA802E7706A80032EA8A /* Tor */,
);
productName = bitchat_macOS;
productReference = 8F3A7C058C2C8E1A06C8CF8B /* bitchat.app */;
@@ -284,6 +268,7 @@
packageProductDependencies = (
4EB6BA1B8464F1EA38F4E286 /* P256K */,
A6E3E56F2E77036A0032EA8A /* BitLogger */,
A6E3EA7E2E7706720032EA8A /* Tor */,
);
productName = bitchat_iOS;
productReference = 96D0D41CA19EE5A772AA8434 /* bitchat.app */;
@@ -323,6 +308,7 @@
packageReferences = (
B8C407587481BBB190741C93 /* XCRemoteSwiftPackageReference "swift-secp256k1" */,
A6E3E56E2E77036A0032EA8A /* XCLocalSwiftPackageReference "localPackages/BitLogger" */,
A6E3EA7D2E7706720032EA8A /* XCLocalSwiftPackageReference "localPackages/Tor" */,
);
preferredProjectObjectVersion = 90;
projectDirPath = "";
@@ -880,6 +866,10 @@
isa = XCLocalSwiftPackageReference;
relativePath = localPackages/BitLogger;
};
A6E3EA7D2E7706720032EA8A /* XCLocalSwiftPackageReference "localPackages/Tor" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = localPackages/Tor;
};
/* End XCLocalSwiftPackageReference section */
/* Begin XCRemoteSwiftPackageReference section */
@@ -907,6 +897,14 @@
isa = XCSwiftPackageProductDependency;
productName = BitLogger;
};
A6E3EA7E2E7706720032EA8A /* Tor */ = {
isa = XCSwiftPackageProductDependency;
productName = Tor;
};
A6E3EA802E7706A80032EA8A /* Tor */ = {
isa = XCSwiftPackageProductDependency;
productName = Tor;
};
B1D9136AA0083366353BFA2F /* P256K */ = {
isa = XCSwiftPackageProductDependency;
package = B8C407587481BBB190741C93 /* XCRemoteSwiftPackageReference "swift-secp256k1" */;
+1
View File
@@ -6,6 +6,7 @@
// For more information, see <https://unlicense.org>
//
import Tor
import SwiftUI
import UserNotifications
+1
View File
@@ -1,5 +1,6 @@
import BitLogger
import Foundation
import Tor
/// Directory of online Nostr relays with approximate GPS locations, used for geohash routing.
@MainActor
+1
View File
@@ -2,6 +2,7 @@ import BitLogger
import Foundation
import Network
import Combine
import Tor
/// Manages WebSocket connections to Nostr relays
@MainActor
@@ -1,6 +1,7 @@
import Foundation
import BitLogger
import Combine
import Tor
/// Coordinates when the app is allowed to start Tor and connect to Nostr relays.
/// Policy: permit start when either location permissions are authorized OR
+1
View File
@@ -83,6 +83,7 @@ import SwiftUI
import Combine
import CommonCrypto
import CoreBluetooth
import Tor
#if os(iOS)
import UIKit
#endif

Some files were not shown because too many files have changed in this diff Show More