Make app groups work on both iOS and macOS

This commit is contained in:
Roopesh Chander 2018-12-28 00:33:31 +05:30
parent c8a8d4ba1e
commit c41be2a29d
7 changed files with 30 additions and 5 deletions

View File

@ -6,7 +6,12 @@ import os.log
extension FileManager {
private static var sharedFolderURL: URL? {
guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: "com.wireguard.ios.app_group_id") as? String else {
#if os(iOS)
let appGroupIdInfoDictionaryKey = "com.wireguard.ios.app_group_id"
#elseif os(OSX)
let appGroupIdInfoDictionaryKey = "com.wireguard.macos.app_group_id"
#endif
guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: appGroupIdInfoDictionaryKey) as? String else {
os_log("Cannot obtain app group ID from bundle", log: OSLog.default, type: .error)
return nil
}

View File

@ -689,6 +689,9 @@
6FB1BD5C21D2607A00A991BF = {
CreatedOnToolsVersion = 10.1;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
};
com.apple.NetworkExtensions = {
enabled = 1;
};
@ -696,6 +699,11 @@
};
6FB1BD9021D4BFE600A991BF = {
CreatedOnToolsVersion = 10.1;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 1;
};
};
};
6FDEF7DD21846BC100D8FBF6 = {
CreatedOnToolsVersion = 10.0;

View File

@ -123,6 +123,6 @@
</dict>
</array>
<key>com.wireguard.ios.app_group_id</key>
<string>group.$(APP_ID_IOS)</string>
<string>group.$(APP_ID_IOS)</string>
</dict>
</plist>

View File

@ -28,5 +28,7 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>com.wireguard.macos.app_group_id</key>
<string>$(DEVELOPMENT_TEAM).group.$(APP_ID_MACOS)</string>
</dict>
</plist>

View File

@ -8,6 +8,10 @@
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(DEVELOPMENT_TEAM).group.$(APP_ID_MACOS)</string>
</array>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>

View File

@ -30,6 +30,8 @@
<string>$(PRODUCT_MODULE_NAME).PacketTunnelProvider</string>
</dict>
<key>com.wireguard.ios.app_group_id</key>
<string>group.$(APP_ID_IOS)</string>
<string>group.$(APP_ID_IOS)</string>
<key>com.wireguard.macos.app_group_id</key>
<string>$(DEVELOPMENT_TEAM).group.$(APP_ID_MACOS)</string>
</dict>
</plist>

View File

@ -2,11 +2,15 @@
<!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.developer.networking.networkextension</key>
<array>
<string>packet-tunnel-provider</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(DEVELOPMENT_TEAM).group.$(APP_ID_MACOS)</string>
</array>
</dict>
</plist>