diff --git a/Configurations/Project.xcconfig b/Configurations/Project.xcconfig index b39040d..c947002 100644 --- a/Configurations/Project.xcconfig +++ b/Configurations/Project.xcconfig @@ -2,6 +2,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES ALWAYS_SEARCH_USER_PATHS = NO +APP_GROUP=$(DEVELOPMENT_TEAM).$(BUNDLE_ID_PREFIX).Edit ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES CLANG_ANALYZER_NONNULL = YES CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE diff --git a/Configurations/Utility.xcconfig b/Configurations/Utility.xcconfig new file mode 100644 index 0000000..42ec04d --- /dev/null +++ b/Configurations/Utility.xcconfig @@ -0,0 +1,5 @@ +#include "Configurations/Module.xcconfig" + +SWIFT_OBJC_BRIDGING_HEADER = Edit/Modules/Utility/Utility-Bridging-Header.h + +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) APP_GROUP=$(APP_GROUP) diff --git a/Edit.xcodeproj/project.pbxproj b/Edit.xcodeproj/project.pbxproj index 66a6bc7..92fa227 100644 --- a/Edit.xcodeproj/project.pbxproj +++ b/Edit.xcodeproj/project.pbxproj @@ -62,6 +62,8 @@ C95B913C2BD98CF1006FDD00 /* TextStory in Frameworks */ = {isa = PBXBuildFile; productRef = C95B913B2BD98CF1006FDD00 /* TextStory */; }; C95B913E2BD98D01006FDD00 /* SwiftTreeSitterLayer in Frameworks */ = {isa = PBXBuildFile; productRef = C95B913D2BD98D01006FDD00 /* SwiftTreeSitterLayer */; }; C95B913F2BD99328006FDD00 /* LanguageData in Resources */ = {isa = PBXBuildFile; fileRef = C9CDEB872B55B889009E252A /* LanguageData */; }; + C95BBE372BDD03F200C9E1B9 /* FileManager+AppGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C95BBE362BDD03F200C9E1B9 /* FileManager+AppGroup.swift */; }; + C95BBE3F2BDD110700C9E1B9 /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = C95BBE3E2BDD110700C9E1B9 /* Constants.m */; }; C96A852D2A7A6E22005ED222 /* DirectoryDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = C96A852C2A7A6E22005ED222 /* DirectoryDocument.swift */; }; C96A852F2A7A703D005ED222 /* OpenPanelAccessoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C96A852E2A7A703D005ED222 /* OpenPanelAccessoryViewController.swift */; }; C96A85342A7A8339005ED222 /* URL+Bookmarks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C96A85332A7A8339005ED222 /* URL+Bookmarks.swift */; }; @@ -898,6 +900,10 @@ C958C7832BC7019100EC95F8 /* LineNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineNumberView.swift; sourceTree = ""; }; C95B91012BD825B6006FDD00 /* Query+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Query+Extras.swift"; sourceTree = ""; }; C95B91032BD825EE006FDD00 /* ThemeModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeModifiers.swift; sourceTree = ""; }; + C95BBE362BDD03F200C9E1B9 /* FileManager+AppGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+AppGroup.swift"; sourceTree = ""; }; + C95BBE382BDD058800C9E1B9 /* Utility-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Utility-Bridging-Header.h"; sourceTree = ""; }; + C95BBE3D2BDD075300C9E1B9 /* Utility.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Utility.xcconfig; sourceTree = ""; }; + C95BBE3E2BDD110700C9E1B9 /* Constants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = ""; }; C96A852C2A7A6E22005ED222 /* DirectoryDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DirectoryDocument.swift; sourceTree = ""; }; C96A852E2A7A703D005ED222 /* OpenPanelAccessoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenPanelAccessoryViewController.swift; sourceTree = ""; }; C96A85332A7A8339005ED222 /* URL+Bookmarks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URL+Bookmarks.swift"; sourceTree = ""; }; @@ -1823,6 +1829,7 @@ C9BDB5542B00FF5A009225FB /* SwiftExtension.xcconfig */, C9EA094D2B4D5F6D00732203 /* TreeSitterParsers.xcconfig */, C926738A2B078B0200B3CE2F /* WorkaroundModule.xcconfig */, + C95BBE3D2BDD075300C9E1B9 /* Utility.xcconfig */, ); path = Configurations; sourceTree = ""; @@ -1884,6 +1891,9 @@ C941F09E2B6C4CD90003B640 /* Dictionary+Fill.swift */, C9FE53FE2A7A5F1600CACA1A /* Logger+init.swift */, C9F79DD62A87E3FA005ED8E9 /* URL+Contents.swift */, + C95BBE362BDD03F200C9E1B9 /* FileManager+AppGroup.swift */, + C95BBE382BDD058800C9E1B9 /* Utility-Bridging-Header.h */, + C95BBE3E2BDD110700C9E1B9 /* Constants.m */, ); path = Utility; sourceTree = ""; @@ -2796,6 +2806,7 @@ }; C9FE53F32A7A5EF900CACA1A = { CreatedOnToolsVersion = 15.0; + LastSwiftMigration = 1530; }; }; }; @@ -3302,6 +3313,8 @@ files = ( C941F09F2B6C4CD90003B640 /* Dictionary+Fill.swift in Sources */, C9891AFA2AFE9A3900C8F393 /* NSFont+Measurements.swift in Sources */, + C95BBE372BDD03F200C9E1B9 /* FileManager+AppGroup.swift in Sources */, + C95BBE3F2BDD110700C9E1B9 /* Constants.m in Sources */, C9891AF82AFE996300C8F393 /* NSParagraphStyle+Helpers.swift in Sources */, C9FE53FF2A7A5F1600CACA1A /* Logger+init.swift in Sources */, C941F0A12B6C4DE00003B640 /* AsyncStream+Pair.swift in Sources */, @@ -4332,15 +4345,20 @@ }; C9FE53FB2A7A5EF900CACA1A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C9FE531A2A759BC400CACA1A /* Module.xcconfig */; + baseConfigurationReference = C95BBE3D2BDD075300C9E1B9 /* Utility.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; C9FE53FC2A7A5EF900CACA1A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C9FE531A2A759BC400CACA1A /* Module.xcconfig */; + baseConfigurationReference = C95BBE3D2BDD075300C9E1B9 /* Utility.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Edit/Modules/Utility/Constants.m b/Edit/Modules/Utility/Constants.m new file mode 100644 index 0000000..c687a9c --- /dev/null +++ b/Edit/Modules/Utility/Constants.m @@ -0,0 +1,10 @@ +@import Foundation; + +#include + +#ifdef APP_GROUP +NSString* const CHMAppGroupIdentifier = @OS_STRINGIFY(APP_GROUP); +#else +#error Undefined +#endif + diff --git a/Edit/Modules/Utility/FileManager+AppGroup.swift b/Edit/Modules/Utility/FileManager+AppGroup.swift new file mode 100644 index 0000000..a5d3bf1 --- /dev/null +++ b/Edit/Modules/Utility/FileManager+AppGroup.swift @@ -0,0 +1,7 @@ +import Foundation + +extension FileManager { + public var appGroupContainerURL: URL? { + containerURL(forSecurityApplicationGroupIdentifier: CHMAppGroupIdentifier) + } +} diff --git a/Edit/Modules/Utility/Utility-Bridging-Header.h b/Edit/Modules/Utility/Utility-Bridging-Header.h new file mode 100644 index 0000000..8dd7694 --- /dev/null +++ b/Edit/Modules/Utility/Utility-Bridging-Header.h @@ -0,0 +1,7 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +@import Foundation; + +extern NSString* const CHMAppGroupIdentifier; diff --git a/Edit/Resources/Edit.entitlements b/Edit/Resources/Edit.entitlements index 1046e77..4a18276 100644 --- a/Edit/Resources/Edit.entitlements +++ b/Edit/Resources/Edit.entitlements @@ -4,6 +4,10 @@ com.apple.security.app-sandbox + com.apple.security.application-groups + + $(APP_GROUP) + com.apple.security.files.user-selected.read-write diff --git a/Edit/Sources/AppDelegate.swift b/Edit/Sources/AppDelegate.swift index 70ada67..9f22462 100644 --- a/Edit/Sources/AppDelegate.swift +++ b/Edit/Sources/AppDelegate.swift @@ -6,6 +6,7 @@ import Document import ExtensionHost import PreferencesWindow import Theme +import Utility @main @MainActor diff --git a/Preview/Preview.entitlements b/Preview/Preview.entitlements index f2ef3ae..53a9688 100644 --- a/Preview/Preview.entitlements +++ b/Preview/Preview.entitlements @@ -2,9 +2,13 @@ - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - + com.apple.security.app-sandbox + + com.apple.security.application-groups + + $(APP_GROUP) + + com.apple.security.files.user-selected.read-only +