Skip to content

Commit 425333c

Browse files
authored
Update MLXChatExample for iOS Sandboxing (#285)
* Add conditional default value for HubApi * Add sandboxing for macOS
1 parent b97db61 commit 425333c

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Applications/MLXChatExample/Support/HubApi+default.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import Foundation
1212
extension HubApi {
1313
/// Default HubApi instance configured to download models to the user's Downloads directory
1414
/// under a 'huggingface' subdirectory.
15+
#if os(macOS)
1516
static let `default` = HubApi(
16-
downloadBase: URL.downloadsDirectory.appending(path: "huggingface"))
17+
downloadBase: URL.downloadsDirectory.appending(path: "huggingface")
18+
)
19+
#else
20+
static let `default` = HubApi(
21+
downloadBase: URL.cachesDirectory.appending(path: "huggingface")
22+
)
23+
#endif
1724
}

MLXChatExample.entitlements

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.developer.kernel.increased-memory-limit</key>
6+
<true/>
7+
<key>com.apple.security.app-sandbox</key>
8+
<true/>
9+
<key>com.apple.security.files.downloads.read-write</key>
10+
<true/>
11+
<key>com.apple.security.network.client</key>
12+
<true/>
13+
</dict>
14+
</plist>

mlx-swift-examples.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
/* End PBXCopyFilesBuildPhase section */
191191

192192
/* Begin PBXFileReference section */
193+
0A7C100B2DC37CEA00FD5155 /* MLXChatExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MLXChatExample.entitlements; sourceTree = "<group>"; };
193194
0AC74EBB2D136221003C90A7 /* VLMEval.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VLMEval.app; sourceTree = BUILT_PRODUCTS_DIR; };
194195
0AC74EC92D13622A003C90A7 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
195196
0AC74ECB2D13622A003C90A7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -522,6 +523,7 @@
522523
C39273672B60697700368D5D = {
523524
isa = PBXGroup;
524525
children = (
526+
0A7C100B2DC37CEA00FD5155 /* MLXChatExample.entitlements */,
525527
C325DE3F2B648CDB00628871 /* README.md */,
526528
F8D7023A2BB4E223003D7CF5 /* Package.swift */,
527529
C3C36A6C2CA714600099FFA4 /* Configuration */,
@@ -1311,6 +1313,7 @@
13111313
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
13121314
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
13131315
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
1316+
CODE_SIGN_ENTITLEMENTS = MLXChatExample.entitlements;
13141317
CODE_SIGN_STYLE = Automatic;
13151318
COPY_PHASE_STRIP = NO;
13161319
CURRENT_PROJECT_VERSION = 1;
@@ -1376,6 +1379,7 @@
13761379
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
13771380
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
13781381
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
1382+
CODE_SIGN_ENTITLEMENTS = MLXChatExample.entitlements;
13791383
CODE_SIGN_STYLE = Automatic;
13801384
COPY_PHASE_STRIP = NO;
13811385
CURRENT_PROJECT_VERSION = 1;

0 commit comments

Comments
 (0)