Skip to content

Commit

Permalink
App Group
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Apr 27, 2024
1 parent 2e18a5e commit c468eaf
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 6 deletions.
1 change: 1 addition & 0 deletions Configurations/Project.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Configurations/Utility.xcconfig
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 20 additions & 2 deletions Edit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -898,6 +900,10 @@
C958C7832BC7019100EC95F8 /* LineNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineNumberView.swift; sourceTree = "<group>"; };
C95B91012BD825B6006FDD00 /* Query+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Query+Extras.swift"; sourceTree = "<group>"; };
C95B91032BD825EE006FDD00 /* ThemeModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeModifiers.swift; sourceTree = "<group>"; };
C95BBE362BDD03F200C9E1B9 /* FileManager+AppGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+AppGroup.swift"; sourceTree = "<group>"; };
C95BBE382BDD058800C9E1B9 /* Utility-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Utility-Bridging-Header.h"; sourceTree = "<group>"; };
C95BBE3D2BDD075300C9E1B9 /* Utility.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Utility.xcconfig; sourceTree = "<group>"; };
C95BBE3E2BDD110700C9E1B9 /* Constants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = "<group>"; };
C96A852C2A7A6E22005ED222 /* DirectoryDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DirectoryDocument.swift; sourceTree = "<group>"; };
C96A852E2A7A703D005ED222 /* OpenPanelAccessoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenPanelAccessoryViewController.swift; sourceTree = "<group>"; };
C96A85332A7A8339005ED222 /* URL+Bookmarks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URL+Bookmarks.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1823,6 +1829,7 @@
C9BDB5542B00FF5A009225FB /* SwiftExtension.xcconfig */,
C9EA094D2B4D5F6D00732203 /* TreeSitterParsers.xcconfig */,
C926738A2B078B0200B3CE2F /* WorkaroundModule.xcconfig */,
C95BBE3D2BDD075300C9E1B9 /* Utility.xcconfig */,
);
path = Configurations;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 = "<group>";
Expand Down Expand Up @@ -2796,6 +2806,7 @@
};
C9FE53F32A7A5EF900CACA1A = {
CreatedOnToolsVersion = 15.0;
LastSwiftMigration = 1530;
};
};
};
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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;
};
Expand Down
10 changes: 10 additions & 0 deletions Edit/Modules/Utility/Constants.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import Foundation;

#include <os/base.h>

#ifdef APP_GROUP
NSString* const CHMAppGroupIdentifier = @OS_STRINGIFY(APP_GROUP);
#else
#error Undefined
#endif

7 changes: 7 additions & 0 deletions Edit/Modules/Utility/FileManager+AppGroup.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

extension FileManager {
public var appGroupContainerURL: URL? {
containerURL(forSecurityApplicationGroupIdentifier: CHMAppGroupIdentifier)
}
}
7 changes: 7 additions & 0 deletions Edit/Modules/Utility/Utility-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions Edit/Resources/Edit.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(APP_GROUP)</string>
</array>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
Expand Down
1 change: 1 addition & 0 deletions Edit/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Document
import ExtensionHost
import PreferencesWindow
import Theme
import Utility

@main
@MainActor
Expand Down
12 changes: 8 additions & 4 deletions Preview/Preview.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(APP_GROUP)</string>
</array>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>

0 comments on commit c468eaf

Please sign in to comment.