From 7c4bde59b923d3e78ce1c3404e38e45b9b109eea Mon Sep 17 00:00:00 2001 From: Islam <2553451+qalandarov@users.noreply.github.com> Date: Mon, 15 Sep 2025 12:58:49 +0100 Subject: [PATCH] Xcode Configuration files: `.xcconfigs` + Remove `xcodegen` (#608) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create configs files with basic settings populated * Add Configs and set the global Debug/Release settings * Update build settings to be read from the configs * Remove `xcodegen`’s `project.yml` * Configurable and dynamic bundle and group ids * Simplified local development with custom Team IDs --- .gitignore | 3 + Configs/Debug.xcconfig | 4 + Configs/Local.xcconfig.example | 5 + Configs/Release.xcconfig | 11 + README.md | 38 +-- bitchat.xcodeproj/project.pbxproj | 174 +++++++------ bitchat/BitchatApp.swift | 5 +- bitchat/Services/KeychainManager.swift | 4 +- .../ShareViewController.swift | 5 +- project.yml | 236 ------------------ setup.sh | 40 --- 11 files changed, 134 insertions(+), 391 deletions(-) create mode 100644 Configs/Debug.xcconfig create mode 100644 Configs/Local.xcconfig.example create mode 100644 Configs/Release.xcconfig delete mode 100644 project.yml delete mode 100755 setup.sh diff --git a/.gitignore b/.gitignore index e0538486..d1081291 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,6 @@ TestResult.xcresult/ *.xcresult/ build.log *.log + +# Local configs +Local.xcconfig diff --git a/Configs/Debug.xcconfig b/Configs/Debug.xcconfig new file mode 100644 index 00000000..0753eb57 --- /dev/null +++ b/Configs/Debug.xcconfig @@ -0,0 +1,4 @@ +#include "Release.xcconfig" + +// Optional include of local configs +#include? "Local.xcconfig" diff --git a/Configs/Local.xcconfig.example b/Configs/Local.xcconfig.example new file mode 100644 index 00000000..899c5a62 --- /dev/null +++ b/Configs/Local.xcconfig.example @@ -0,0 +1,5 @@ +// Your Apple Developer Team ID - https://stackoverflow.com/a/18727947 +DEVELOPMENT_TEAM = ABC123 + +// Unique bundle id to be able to register and run locally +PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.$(DEVELOPMENT_TEAM) diff --git a/Configs/Release.xcconfig b/Configs/Release.xcconfig new file mode 100644 index 00000000..a1c0d2ec --- /dev/null +++ b/Configs/Release.xcconfig @@ -0,0 +1,11 @@ +MARKETING_VERSION = 1.4.0 +CURRENT_PROJECT_VERSION = 1 + +IPHONEOS_DEPLOYMENT_TARGET = 16.0 +MACOSX_DEPLOYMENT_TARGET = 13.0 +SWIFT_VERSION = 5.0 + +DEVELOPMENT_TEAM = L3N5LHJD5Y +CODE_SIGN_STYLE = Automatic + +PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat diff --git a/README.md b/README.md index 499ff649..e1becc62 100644 --- a/README.md +++ b/README.md @@ -94,45 +94,25 @@ For detailed protocol documentation, see the [Technical Whitepaper](WHITEPAPER.m ## Setup -### Option 1: Using XcodeGen (Recommended) - -1. Install XcodeGen if you haven't already: - - ```bash - brew install xcodegen - ``` - -2. Generate the Xcode project: +### Option 1: Using Xcode ```bash cd bitchat - xcodegen generate - ``` - -3. Open the generated project: - ```bash open bitchat.xcodeproj ``` -### Option 2: Using Swift Package Manager + To run on a device there're a few steps to prepare the code: + - Clone the local configs: `cp Configs/Local.xcconfig.example Configs/Local.xcconfig` + - Add your Developer Team ID into the newly created `Configs/Local.xcconfig` + - Bundle ID would be set to `chat.bitchat.` (unless you set to something else) + - Entitlements need to be updated manually (TODO: Automate): + - Search and replace `group.chat.bitchat` with `group.` (e.g. `group.chat.bitchat.ABC123`) -1. Open the project in Xcode: +### Option 2: Using `just` ```bash - cd bitchat - open Package.swift + brew install just ``` -2. Select your target device and run - -### Option 3: Manual Xcode Project - -1. Open Xcode and create a new iOS/macOS App -2. Copy all Swift files from the `bitchat` directory into your project -3. Update Info.plist with Bluetooth permissions -4. Set deployment target to iOS 16.0 / macOS 13.0 - -### Option 4: just - Want to try this on macos: `just run` will set it up and run from source. Run `just clean` afterwards to restore things to original state for mobile app building and development. diff --git a/bitchat.xcodeproj/project.pbxproj b/bitchat.xcodeproj/project.pbxproj index 73be9195..fb2a79ee 100644 --- a/bitchat.xcodeproj/project.pbxproj +++ b/bitchat.xcodeproj/project.pbxproj @@ -122,6 +122,11 @@ path = bitchatTests; sourceTree = ""; }; + A6E367C92E76469E0032EA8A /* Configs */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = Configs; + sourceTree = ""; + }; /* End PBXFileSystemSynchronizedRootGroup section */ /* Begin PBXFrameworksBuildPhase section */ @@ -160,6 +165,7 @@ E0A1B2C3D4E5F6012345678A /* relays/online_relays_gps.csv */, A6E32D212E762EAB0032EA8A /* bitchatShareExtension */, A6E32D412E762EAE0032EA8A /* bitchatTests */, + A6E367C92E76469E0032EA8A /* Configs */, 0481A3542E6D877600FC845E /* Frameworks */, 9F37F9F2C353B58AC809E93B /* Products */, ); @@ -285,28 +291,6 @@ attributes = { BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 1640; - TargetAttributes = { - 0576A29205865664C0937536 = { - DevelopmentTeam = L3N5LHJD5Y; - ProvisioningStyle = Automatic; - }; - 47FF23248747DD7CB666CB91 = { - DevelopmentTeam = L3N5LHJD5Y; - ProvisioningStyle = Automatic; - }; - 57CA17A36A2532A6CFF367BB = { - DevelopmentTeam = L3N5LHJD5Y; - ProvisioningStyle = Automatic; - }; - 6CB97DF2EA57234CB3E563B8 = { - DevelopmentTeam = L3N5LHJD5Y; - ProvisioningStyle = Automatic; - }; - AF077EA0474EDEDE2C72716C = { - DevelopmentTeam = L3N5LHJD5Y; - ProvisioningStyle = Automatic; - }; - }; }; buildConfigurationList = 3EA424CBD51200895D361189 /* Build configuration list for PBXProject "bitchat" */; developmentRegion = en; @@ -397,21 +381,24 @@ /* Begin XCBuildConfiguration section */ 077A5203074247CF8F766E2F /* Debug configuration for PBXNativeTarget "bitchatTests_iOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Debug.xcconfig; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; INFOPLIST_FILE = bitchatTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.tests; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).tests"; SDKROOT = iphoneos; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/bitchat.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/bitchat"; }; @@ -419,21 +406,24 @@ }; 0DACAA261446D178EDD30ECA /* Release configuration for PBXNativeTarget "bitchatTests_iOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Release.xcconfig; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; INFOPLIST_FILE = bitchatTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.tests; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).tests"; SDKROOT = iphoneos; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/bitchat.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/bitchat"; }; @@ -441,153 +431,169 @@ }; 147FDAE548082D5B921C6F0B /* Release configuration for PBXNativeTarget "bitchatTests_macOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Release.xcconfig; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; COMBINE_HIDPI_IMAGES = YES; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; INFOPLIST_FILE = bitchatTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 13.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.tests; + MACOSX_DEPLOYMENT_TARGET = "$(MACOSX_DEPLOYMENT_TARGET)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).tests"; SDKROOT = macosx; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/bitchat.app/Contents/MacOS/bitchat"; }; name = Release; }; 3DCF45111852FB2AEBE05E31 /* Release configuration for PBXNativeTarget "bitchatShareExtension" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Release.xcconfig; buildSettings = { CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES; CODE_SIGN_ENTITLEMENTS = bitchatShareExtension/bitchatShareExtension.entitlements; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; INFOPLIST_FILE = bitchatShareExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = bitchat; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.ShareExtension; + MARKETING_VERSION = "$(MARKETING_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).ShareExtension"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; 702E7395723CADA4B830F4A9 /* Debug configuration for PBXNativeTarget "bitchat_iOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Debug.xcconfig; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; CODE_SIGN_ENTITLEMENTS = bitchat/bitchat.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; ENABLE_PREVIEWS = NO; INFOPLIST_FILE = bitchat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = bitchat; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.4.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; + MARKETING_VERSION = "$(MARKETING_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = bitchat; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; 7FA2BADBF3B325125030CAB1 /* Debug configuration for PBXNativeTarget "bitchatTests_macOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Debug.xcconfig; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; COMBINE_HIDPI_IMAGES = YES; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; INFOPLIST_FILE = bitchatTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 13.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.tests; + MACOSX_DEPLOYMENT_TARGET = "$(MACOSX_DEPLOYMENT_TARGET)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).tests"; SDKROOT = macosx; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/bitchat.app/Contents/MacOS/bitchat"; }; name = Debug; }; B36671AEACCBF92BE10852E9 /* Release configuration for PBXNativeTarget "bitchat_iOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Release.xcconfig; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; CODE_SIGN_ENTITLEMENTS = bitchat/bitchat.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = bitchat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = bitchat; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.4.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; + MARKETING_VERSION = "$(MARKETING_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = bitchat; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; BB044400A0F06B93F22D0D55 /* Release configuration for PBXNativeTarget "bitchat_macOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Release.xcconfig; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; CODE_SIGN_ENTITLEMENTS = "bitchat/bitchat-macOS.entitlements"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; COMBINE_HIDPI_IMAGES = YES; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = bitchat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = bitchat; @@ -595,13 +601,13 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.4.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; + MACOSX_DEPLOYMENT_TARGET = "$(MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "$(MARKETING_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = bitchat; REGISTER_APP_GROUPS = YES; SDKROOT = macosx; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; }; name = Release; }; @@ -639,10 +645,9 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = "$(CURRENT_PROJECT_VERSION)"; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEVELOPMENT_TEAM = L3N5LHJD5Y; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; @@ -654,29 +659,32 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; + MACOSX_DEPLOYMENT_TARGET = "$(MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "$(MARKETING_VERSION)"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; }; name = Release; }; CC79F65842D42034ACEE79B7 /* Debug configuration for PBXNativeTarget "bitchat_macOS" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Debug.xcconfig; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; CODE_SIGN_ENTITLEMENTS = "bitchat/bitchat-macOS.entitlements"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; COMBINE_HIDPI_IMAGES = YES; DEAD_CODE_STRIPPING = YES; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; ENABLE_PREVIEWS = NO; INFOPLIST_FILE = bitchat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = bitchat; @@ -684,13 +692,13 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.4.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat; + MACOSX_DEPLOYMENT_TARGET = "$(MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "$(MARKETING_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)"; PRODUCT_NAME = bitchat; REGISTER_APP_GROUPS = YES; SDKROOT = macosx; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; }; name = Debug; }; @@ -728,10 +736,9 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = "$(CURRENT_PROJECT_VERSION)"; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = L3N5LHJD5Y; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; @@ -749,43 +756,46 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; + MACOSX_DEPLOYMENT_TARGET = "$(MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = "$(MARKETING_VERSION)"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; }; name = Debug; }; DAC5E82049F8A97360BE63D6 /* Debug configuration for PBXNativeTarget "bitchatShareExtension" */ = { isa = XCBuildConfiguration; + baseConfigurationReferenceAnchor = A6E367C92E76469E0032EA8A /* Configs */; + baseConfigurationReferenceRelativePath = Debug.xcconfig; buildSettings = { CODE_SIGNING_ALLOWED = YES; CODE_SIGNING_REQUIRED = YES; CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES; CODE_SIGN_ENTITLEMENTS = bitchatShareExtension/bitchatShareExtension.entitlements; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = "$(CODE_SIGN_STYLE)"; + DEVELOPMENT_TEAM = "$(DEVELOPMENT_TEAM)"; INFOPLIST_FILE = bitchatShareExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = bitchat; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; + IPHONEOS_DEPLOYMENT_TARGET = "$(IPHONEOS_DEPLOYMENT_TARGET)"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.4.0; - PRODUCT_BUNDLE_IDENTIFIER = chat.bitchat.ShareExtension; + MARKETING_VERSION = "$(MARKETING_VERSION)"; + PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).ShareExtension"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = "$(SWIFT_VERSION)"; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; diff --git a/bitchat/BitchatApp.swift b/bitchat/BitchatApp.swift index 812f738f..75b7b907 100644 --- a/bitchat/BitchatApp.swift +++ b/bitchat/BitchatApp.swift @@ -11,6 +11,9 @@ import UserNotifications @main struct BitchatApp: App { + static let bundleID = Bundle.main.bundleIdentifier ?? "chat.bitchat" + static let groupID = "group.\(bundleID)" + @StateObject private var chatViewModel: ChatViewModel #if os(iOS) @Environment(\.scenePhase) var scenePhase @@ -130,7 +133,7 @@ struct BitchatApp: App { private func checkForSharedContent() { // Check app group for shared content from extension - guard let userDefaults = UserDefaults(suiteName: "group.chat.bitchat") else { + guard let userDefaults = UserDefaults(suiteName: BitchatApp.groupID) else { return } diff --git a/bitchat/Services/KeychainManager.swift b/bitchat/Services/KeychainManager.swift index a2ca6b3f..ce378daa 100644 --- a/bitchat/Services/KeychainManager.swift +++ b/bitchat/Services/KeychainManager.swift @@ -23,8 +23,8 @@ protocol KeychainManagerProtocol { final class KeychainManager: KeychainManagerProtocol { // Use consistent service name for all keychain items - private let service = "chat.bitchat" - private let appGroup = "group.chat.bitchat" + private let service = BitchatApp.bundleID + private let appGroup = "group.\(BitchatApp.bundleID)" private func isSandboxed() -> Bool { #if os(macOS) diff --git a/bitchatShareExtension/ShareViewController.swift b/bitchatShareExtension/ShareViewController.swift index d41b3543..58300eec 100644 --- a/bitchatShareExtension/ShareViewController.swift +++ b/bitchatShareExtension/ShareViewController.swift @@ -12,6 +12,9 @@ import UniformTypeIdentifiers /// Modern share extension using UIKit + UTTypes. /// Avoids deprecated Social framework and SLComposeServiceViewController. final class ShareViewController: UIViewController { + // Bundle.main.bundleIdentifier would get the extension's bundleID + private static let groupID = "group.chat.bitchat" + private let statusLabel: UILabel = { let l = UILabel() l.translatesAutoresizingMaskIntoConstraints = false @@ -149,7 +152,7 @@ final class ShareViewController: UIViewController { } private func saveToSharedDefaults(content: String, type: String) { - guard let userDefaults = UserDefaults(suiteName: "group.chat.bitchat") else { return } + guard let userDefaults = UserDefaults(suiteName: Self.groupID) else { return } userDefaults.set(content, forKey: "sharedContent") userDefaults.set(type, forKey: "sharedContentType") userDefaults.set(Date(), forKey: "sharedContentDate") diff --git a/project.yml b/project.yml deleted file mode 100644 index 90e9e4ae..00000000 --- a/project.yml +++ /dev/null @@ -1,236 +0,0 @@ -name: bitchat -options: - bundleIdPrefix: chat.bitchat - deploymentTarget: - iOS: 16.0 - macOS: 13.0 - createIntermediateGroups: true - -settings: - MARKETING_VERSION: 1.0.0 - CURRENT_PROJECT_VERSION: 1 - -packages: - P256K: - url: https://github.com/21-DOT-DEV/swift-secp256k1 - majorVersion: 0.21.1 - -targets: - bitchat_iOS: - type: application - platform: iOS - sources: - - bitchat - resources: - - bitchat/Assets.xcassets - - bitchat/LaunchScreen.storyboard - info: - path: bitchat/Info.plist - properties: - CFBundleDisplayName: bitchat - CFBundleShortVersionString: $(MARKETING_VERSION) - CFBundleVersion: $(CURRENT_PROJECT_VERSION) - NSBluetoothAlwaysUsageDescription: bitchat uses Bluetooth to create a secure mesh network for chatting with nearby users. - NSBluetoothPeripheralUsageDescription: bitchat uses Bluetooth to discover and connect with other bitchat users nearby. - NSCameraUsageDescription: bitchat uses the camera to scan QR codes to verify peers. - NSLocationWhenInUseUsageDescription: bitchat uses your approximate location to compute local geohash channels for optional public chats. Exact GPS is never shared. - UIBackgroundModes: - - bluetooth-central - - bluetooth-peripheral - UILaunchStoryboardName: LaunchScreen - UISupportedInterfaceOrientations: - - UIInterfaceOrientationPortrait - UISupportedInterfaceOrientations~ipad: - - UIInterfaceOrientationPortrait - - UIInterfaceOrientationPortraitUpsideDown - - UIInterfaceOrientationLandscapeLeft - - UIInterfaceOrientationLandscapeRight - UIRequiresFullScreen: false - CFBundleURLTypes: - - CFBundleURLSchemes: - - bitchat - # xcodegen quirk: include some macOS properties in iOS target - LSMinimumSystemVersion: $(MACOSX_DEPLOYMENT_TARGET) - settings: - PRODUCT_BUNDLE_IDENTIFIER: chat.bitchat - PRODUCT_NAME: bitchat - INFOPLIST_FILE: bitchat/Info.plist - ENABLE_PREVIEWS: YES - SWIFT_VERSION: 5.0 - IPHONEOS_DEPLOYMENT_TARGET: 16.0 - SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD: YES - CODE_SIGN_STYLE: Automatic - CODE_SIGNING_REQUIRED: YES - CODE_SIGNING_ALLOWED: YES - DEVELOPMENT_TEAM: L3N5LHJD5Y - ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon - ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS: YES - CODE_SIGN_ENTITLEMENTS: bitchat/bitchat.entitlements - dependencies: - - target: bitchatShareExtension - embed: true - - package: P256K - - framework: Frameworks/tor-nolzma.xcframework - embed: true - codeSign: true - - sdk: libz.tbd - - bitchat_macOS: - type: application - platform: macOS - sources: - - bitchat - resources: - - bitchat/Assets.xcassets - info: - path: bitchat/Info.plist - properties: - CFBundleDisplayName: bitchat - CFBundleShortVersionString: $(MARKETING_VERSION) - CFBundleVersion: $(CURRENT_PROJECT_VERSION) - LSMinimumSystemVersion: $(MACOSX_DEPLOYMENT_TARGET) - NSBluetoothAlwaysUsageDescription: bitchat uses Bluetooth to create a secure mesh network for chatting with nearby users. - NSBluetoothPeripheralUsageDescription: bitchat uses Bluetooth to discover and connect with other bitchat users nearby. - NSCameraUsageDescription: bitchat uses the camera to scan QR codes to verify peers. - NSLocationWhenInUseUsageDescription: bitchat uses your approximate location to compute local geohash channels for optional public chats. Exact GPS is never shared. - CFBundleURLTypes: - - CFBundleURLSchemes: - - bitchat - # xcodegen quirk: include some iOS properties in macOS target - UIBackgroundModes: - - bluetooth-central - - bluetooth-peripheral - UILaunchStoryboardName: LaunchScreen - UISupportedInterfaceOrientations: - - UIInterfaceOrientationPortrait - UIRequiresFullScreen: true - settings: - PRODUCT_BUNDLE_IDENTIFIER: chat.bitchat - PRODUCT_NAME: bitchat - INFOPLIST_FILE: bitchat/Info.plist - ENABLE_PREVIEWS: NO - SWIFT_VERSION: 5.0 - MACOSX_DEPLOYMENT_TARGET: 13.0 - CODE_SIGN_STYLE: Automatic - CODE_SIGNING_REQUIRED: YES - CODE_SIGNING_ALLOWED: YES - DEVELOPMENT_TEAM: L3N5LHJD5Y - ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon - ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS: YES - CODE_SIGN_ENTITLEMENTS: bitchat/bitchat-macOS.entitlements - dependencies: - - package: P256K - - framework: Frameworks/tor-nolzma.xcframework - embed: true - codeSign: true - - sdk: libz.tbd - - bitchatShareExtension: - type: app-extension - platform: iOS - sources: - - bitchatShareExtension - - bitchat/Services/TransportConfig.swift - info: - path: bitchatShareExtension/Info.plist - properties: - CFBundleDisplayName: bitchat - CFBundleShortVersionString: $(MARKETING_VERSION) - CFBundleVersion: $(CURRENT_PROJECT_VERSION) - NSExtension: - NSExtensionPointIdentifier: com.apple.share-services - NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).ShareViewController - NSExtensionAttributes: - NSExtensionActivationRule: - NSExtensionActivationSupportsText: true - NSExtensionActivationSupportsWebURLWithMaxCount: 1 - NSExtensionActivationSupportsImageWithMaxCount: 1 - settings: - PRODUCT_BUNDLE_IDENTIFIER: chat.bitchat.ShareExtension - INFOPLIST_FILE: bitchatShareExtension/Info.plist - SWIFT_VERSION: 5.0 - IPHONEOS_DEPLOYMENT_TARGET: 16.0 - CODE_SIGN_STYLE: Automatic - CODE_SIGNING_REQUIRED: YES - CODE_SIGNING_ALLOWED: YES - DEVELOPMENT_TEAM: L3N5LHJD5Y - CODE_SIGN_ENTITLEMENTS: bitchatShareExtension/bitchatShareExtension.entitlements - CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION: YES - - bitchatTests_iOS: - type: bundle.unit-test - platform: iOS - sources: - - bitchatTests - dependencies: - - target: bitchat_iOS - settings: - PRODUCT_BUNDLE_IDENTIFIER: chat.bitchat.tests - INFOPLIST_FILE: bitchatTests/Info.plist - SWIFT_VERSION: 5.0 - IPHONEOS_DEPLOYMENT_TARGET: 16.0 - TEST_HOST: $(BUILT_PRODUCTS_DIR)/bitchat.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/bitchat - BUNDLE_LOADER: $(TEST_HOST) - CODE_SIGN_STYLE: Automatic - CODE_SIGNING_REQUIRED: YES - CODE_SIGNING_ALLOWED: YES - DEVELOPMENT_TEAM: L3N5LHJD5Y - - bitchatTests_macOS: - type: bundle.unit-test - platform: macOS - sources: - - bitchatTests - dependencies: - - target: bitchat_macOS - settings: - PRODUCT_BUNDLE_IDENTIFIER: chat.bitchat.tests - INFOPLIST_FILE: bitchatTests/Info.plist - SWIFT_VERSION: 5.0 - MACOSX_DEPLOYMENT_TARGET: 13.0 - TEST_HOST: $(BUILT_PRODUCTS_DIR)/bitchat.app/Contents/MacOS/bitchat - BUNDLE_LOADER: $(TEST_HOST) - CODE_SIGN_STYLE: Automatic - CODE_SIGNING_REQUIRED: YES - CODE_SIGNING_ALLOWED: YES - DEVELOPMENT_TEAM: L3N5LHJD5Y - -schemes: - bitchat (iOS): - build: - targets: - bitchat_iOS: all - bitchatShareExtension: all - run: - config: Debug - executable: bitchat_iOS - test: - config: Debug - targets: - - bitchatTests_iOS - profile: - config: Release - executable: bitchat_iOS - analyze: - config: Debug - archive: - config: Release - - bitchat (macOS): - build: - targets: - bitchat_macOS: all - run: - config: Debug - executable: bitchat_macOS - test: - config: Debug - targets: - - bitchatTests_macOS - profile: - config: Release - executable: bitchat_macOS - analyze: - config: Debug - archive: - config: Release diff --git a/setup.sh b/setup.sh deleted file mode 100755 index 72b636a2..00000000 --- a/setup.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -echo "bitchat Setup Script" -echo "===================" - -# Check if XcodeGen is installed -if command -v xcodegen &> /dev/null; then - echo "✓ XcodeGen found" - echo "Generating Xcode project..." - xcodegen generate - echo "✓ Project generated successfully" - echo "" - echo "To open the project, run:" - echo " open bitchat.xcodeproj" -else - echo "⚠️ XcodeGen not found" - echo "" - echo "You have several options:" - echo "1. Install XcodeGen:" - echo " brew install xcodegen" - echo "" - echo "2. Open with Swift Package Manager:" - echo " open Package.swift" - echo "" - echo "3. Create a new Xcode project manually and add the source files" -fi - -echo "" -echo "Project Structure:" -echo "- bitchat/ Main source files" -echo " - BitchatApp.swift App entry point" -echo " - Views/ SwiftUI views" -echo " - ViewModels/ View models" -echo " - Services/ Bluetooth and encryption" -echo " - Protocols/ Protocol definitions" -echo "" -echo "Remember to:" -echo "1. Enable Bluetooth in device settings" -echo "2. Run on physical devices (Bluetooth doesn't work in simulator)" -echo "3. Test with multiple devices for mesh functionality" \ No newline at end of file