From 254e65906a1b52bda25374ed0b9ac25b5fd77015 Mon Sep 17 00:00:00 2001
From: CodeST <694468528@qq.com>
Date: Tue, 18 Nov 2025 14:41:35 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0app=20groups?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CustomKeyboard/CustomKeyboard.entitlements | 13 ++++++++-----
CustomKeyboard/KeyboardViewController.m | 4 ++++
Shared/KBConfig.h | 6 +++++-
keyBoard/Class/Home/VC/HomeMainVC.m | 7 +++++++
keyBoard/keyBoard.entitlements | 4 ++++
5 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/CustomKeyboard/CustomKeyboard.entitlements b/CustomKeyboard/CustomKeyboard.entitlements
index 47b6869..5ea4409 100644
--- a/CustomKeyboard/CustomKeyboard.entitlements
+++ b/CustomKeyboard/CustomKeyboard.entitlements
@@ -2,10 +2,13 @@
- keychain-access-groups
-
- $(AppIdentifierPrefix)com.loveKey.nyx.shared
-
+ com.apple.security.application-groups
+
+ group.com.loveKey.nyx
+
+ keychain-access-groups
+
+ $(AppIdentifierPrefix)com.loveKey.nyx.shared
+
-
diff --git a/CustomKeyboard/KeyboardViewController.m b/CustomKeyboard/KeyboardViewController.m
index 37bf554..30007f1 100644
--- a/CustomKeyboard/KeyboardViewController.m
+++ b/CustomKeyboard/KeyboardViewController.m
@@ -48,6 +48,10 @@ static CGFloat KEYBOARDHEIGHT = 256 + 20;
[self kb_applyTheme];
}];
[self kb_applyTheme];
+
+// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
+// NSString *value = [sharedDefaults objectForKey:@"TestSharedString"];
+// NSLog(@"[Keyboard] 读取到的数据: %@", value);
}
diff --git a/Shared/KBConfig.h b/Shared/KBConfig.h
index 00b85c6..c242718 100644
--- a/Shared/KBConfig.h
+++ b/Shared/KBConfig.h
@@ -13,9 +13,13 @@
#import
#endif
-
+/// APP名称
#define AppName @"Key of Love"
+/// APP Groups
+#define AppGroup @"group.com.loveKey.nyx"
+
+
// 基础baseUrl
#ifndef KB_BASE_URL
//#define KB_BASE_URL @"https://m1.apifoxmock.com/m1/5438099-5113192-default/"
diff --git a/keyBoard/Class/Home/VC/HomeMainVC.m b/keyBoard/Class/Home/VC/HomeMainVC.m
index 4e6c27e..0c77ca7 100644
--- a/keyBoard/Class/Home/VC/HomeMainVC.m
+++ b/keyBoard/Class/Home/VC/HomeMainVC.m
@@ -51,6 +51,13 @@
KBGuideVC *vc = [KBGuideVC new];
[weakSelf.navigationController pushViewController:vc animated:true];
};
+
+ /// 测试groups
+// NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:AppGroup];
+// // 写入一个简单字符串
+// [sharedDefaults setObject:@"Hello From Main App" forKey:@"TestSharedString"];
+// [sharedDefaults synchronize];
+// NSLog(@"[MainApp] 写入完成");
}
// 在界面可见后做“首次安装”检查,避免在 viewDidLoad 期间 push 引起的转场警告
diff --git a/keyBoard/keyBoard.entitlements b/keyBoard/keyBoard.entitlements
index eabbbc8..a7f7eb5 100644
--- a/keyBoard/keyBoard.entitlements
+++ b/keyBoard/keyBoard.entitlements
@@ -10,6 +10,10 @@
applinks:app.tknb.net
+ com.apple.security.application-groups
+
+ group.com.loveKey.nyx
+
keychain-access-groups
$(AppIdentifierPrefix)com.loveKey.nyx.shared