Skip to content

Commit 6d9bbfe

Browse files
committed
Init commit
0 parents  commit 6d9bbfe

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2024 Kyle-Ye
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Ways to enjoy Xcode LLM on ChinaSKU Mac
2+
3+
Ways to enjoy Xcode LLM on ChinaSKU Mac without disabling SIP.
4+
5+
在不禁用系统完整性保护 (SIP) 的情况下在国行 Mac 上使用 Xcode LLM 的方法。
6+
7+
For older methods which requires SIP disabled, please see Related links section.
8+
9+
对于需要禁用系统完整性保护 (SIP) 的旧方法,请参阅 "相关链接" 部分。
10+
11+
## Notes / 注意事项
12+
13+
## Usage
14+
15+
### Script Execution / 脚本执行
16+
17+
TODO
18+
19+
### Manual Execution / 手动执行
20+
21+
#### Method 1 (Recommended) / 方案一(推荐)
22+
23+
Need one time SIP disable during the script.
24+
25+
1. Disable SIP in recovery mode with `csrutil disable` and reboot.
26+
2. Download `eligibility_util` in the release page and execute `eligibility_util forceDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM --answer 4`
27+
3. Enable SIP in recovery mode with `csrutil enable` and reboot.
28+
29+
> Read [Disabling and Enabling System Integrity Protection](https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection) if you are unfamiliar with SIP operation.
30+
31+
在脚本执行期间需要临时禁用一次 SIP。
32+
33+
1. 在恢复模式下通过 `csrutil disable` 禁用 SIP 并重启。
34+
2. 在发布页面中下载 `eligibility_util` 并执行 `eligibility_util forceDomainAnswer --domain-name OS_ELIGIBILITY_DOMAIN_XCODE_LLM --answer 4`
35+
3. 在恢复模式下通过 `csrutil enable` 恢复 SIP 并重启。
36+
37+
> 如果你不熟悉 SIP 操作,请阅读 [Disabling and Enabling System Integrity Protection](https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection)
38+
39+
40+
#### Method 2 / 方案二
41+
42+
No SIP disabled needed in total.
43+
44+
1. Download `eligibility_overrides.data` file from the release page
45+
2. Find the correct container path for `eligibilityd` under `~/Library/Daemon Containers/<UUID>`
46+
3. Move the downloaded file to `eligibilityd`'s daemon container's `Data/Library/Caches/NeverRestore/` folder. If you are not sure which one is for `eligibilityd`, you can try it one by one or just add the file to all of the containers.
47+
48+
完全不需要禁用 SIP。
49+
50+
1. 从发布页面下载 `eligibility_overrides.data` 文件
51+
2.`~/Library/Daemon Containers/<UUID>`下找到`eligibilityd`的正确容器路径
52+
3. 将下载的文件移动到相应的 Deamon 容器的 `Data/Library/Caches/NeverRestore/` 文件夹中。如果您不确定哪个是 eligibilityd 的容器目录,您可以一个一个地尝试,或者将下载的文件添加到所有 Deamon 容器中。
53+
54+
## Related links / 相关链接
55+
56+
- https://gist.github.com/Kyle-Ye/4ad1aa92df3a31bd812487af65e16947
57+
- https://gist.github.com/unixzii/6f25be1842399022e16ad6477a304286
58+
59+
## License / 版权信息
60+
61+
MIT. See LICENSE file.
62+
63+
MIT。详见 LICENSE 文件。

override_xcodellm.sh

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/zsh
2+
3+
# Constants
4+
UTIL_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/download/latest/eligibility_util"
5+
OVERRIDE_URL="https://github.com/Kyle-Ye/XcodeLLMEligible/releases/download/latest/eligibility_overrides.data"
6+
DOWNLOAD_DIR="/tmp"
7+
UTIL_FILE="${DOWNLOAD_DIR}/eligibility_util"
8+
OVERRIDES_FILE="${DOWNLOAD_DIR}/eligibility_overrides.data"
9+
DAEMON_CONTAINERS_DIR=~/Library/Daemon\ Containers/
10+
11+
# Function to download files
12+
download_file() {
13+
local url="$1"
14+
local output_path="$2"
15+
curl -L -o "$output_path" "$url"
16+
}
17+
18+
method_util() {
19+
echo "Downloading eligibility_util..."
20+
download_file "$UTIL_URL" "$UTIL_FILE"
21+
chmod +x "$UTIL_FILE"
22+
echo "Running ./eligibility_util --help"
23+
"$UTIL_FILE" --help
24+
}
25+
26+
method_override() {
27+
echo "Downloading eligibility_overrides.data..."
28+
download_file "$OVERRIDE_URL" "$OVERRIDES_FILE"
29+
echo "Copying eligibility_overrides.data to each Daemon Container..."
30+
for dir in "$DAEMON_CONTAINERS_DIR"*/ ; do
31+
if [[ -d "$dir" ]]; then
32+
dest_dir="${dir}Data/Library/Caches/NeverRestore/"
33+
mkdir -p "$dest_dir"
34+
cp "$OVERRIDES_FILE" "$dest_dir"
35+
echo "Copied to $dest_dir"
36+
fi
37+
done
38+
}
39+
40+
# Function to check SIP status
41+
check_sip_status() {
42+
local sip_status=$(csrutil status)
43+
if echo "$sip_status" | grep -q "enabled"; then
44+
echo "SIP is enabled."
45+
return 1
46+
else
47+
echo "SIP is disabled."
48+
return 0
49+
fi
50+
}
51+
52+
uninstall() {
53+
echo "Uninstalling..."
54+
echo "Removing eligibility_overrides.data from Daemon Containers..."
55+
for dir in "$DAEMON_CONTAINERS_DIR"*/ ; do
56+
if [[ -d "$dir" ]]; then
57+
dest_file="${dir}Data/Library/Caches/NeverRestore/eligibility_overrides.data"
58+
if [[ -f "$dest_file" ]]; then
59+
rm -rf "$dest_file"
60+
echo "Removed $dest_file"
61+
fi
62+
fi
63+
done
64+
}
65+
66+
# Main script logic
67+
action="install"
68+
if [[ $# -gt 0 ]]; then
69+
action="$1"
70+
fi
71+
72+
case "$action" in
73+
install)
74+
echo "Performing install action..."
75+
if check_sip_status; then
76+
method_util
77+
else
78+
method_override
79+
fi
80+
;;
81+
uninstall)
82+
uninstall
83+
;;
84+
*)
85+
echo "Unknown action: $action"
86+
echo "Usage: $0 [install|uninstall]"
87+
exit 1
88+
;;
89+
esac
90+
91+
echo "Script completed."

0 commit comments

Comments
 (0)