Last active
April 24, 2025 12:53
-
-
Save Willian-Zhang/c34861d2010414bd972f48d32d8d7006 to your computer and use it in GitHub Desktop.
Mac enable AI Fix 15.4.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $EUID -ne 0 ]]; then | |
sleep 3 | |
exit 3 | |
fi | |
label=com.apple.eligibilityd | |
getpid() { | |
pgrep eligibilityd | |
} | |
TEMP_PID_FILE="/tmp/eligibilityfix.pid" | |
PID=$(pgrep eligibilityd) | |
if [ ! -z "$PID" ]; then | |
echo "eligibilityd found with PID $PID" | |
# Check if we've already handled this PID | |
if [ -f "$TEMP_PID_FILE" ] && [ "$(cat $TEMP_PID_FILE)" == "$PID" ]; then | |
echo "Already processed eligibilityd with PID $PID" | |
else | |
lldb --batch \ | |
-o "process attach --name eligibilityd" \ | |
-o 'e (void) [[[InputManager sharedInstance] objectForInputValue:6] setValue:@"US" forKey:@"_deviceRegionCode"]' \ | |
-o 'e (void) [[EligibilityEngine sharedInstance] recomputeAllDomainAnswers]' \ | |
-o "process detach" \ | |
-o quit || { echo "lldb command failed"; sleep 3; exit 1; } | |
lldb -b <<'LLDB' || { echo "lldb command hook failed"; sleep 3; exit 4; } | |
process attach --name eligibilityd | |
expr -l objc -- @import ObjectiveC | |
expr -l objc -- method_setImplementation( class_getInstanceMethod(objc_getClass("GlobalConfiguration"), sel_getUid("supportsForcedAnswers")), imp_implementationWithBlock(^BOOL(id _self){ return YES; })) | |
expr -l objc -- method_setImplementation( class_getInstanceMethod(objc_getClass("DeviceRegionCodeInput"), sel_getUid("isChinaSKU")), imp_implementationWithBlock(^BOOL(id _self){ return NO; })) | |
process detach | |
quit | |
LLDB | |
out=$(lldb -b \ | |
-o 'process attach --name eligibilityd' \ | |
-o 'expr -- (int)[[GlobalConfiguration new] supportsForcedAnswers]' \ | |
-o quit 2>/dev/null) || { echo "lldb command hook failed"; sleep 3; exit 5; } | |
val=$(echo "$out" | awk -F'= ' '/=/{v=$2} END{print v}') | |
[ "$val" = 0 ] && exit 5 | |
out=$(lldb -b \ | |
-o 'process attach --name eligibilityd' \ | |
-o 'expr -- (int)[[DeviceRegionCodeInput new] isChinaSKU]' \ | |
-o quit 2>/dev/null) || { echo "lldb command hook failed"; sleep 3; exit 6; } | |
val=$(echo "$out" | awk -F'= ' '/=/{v=$2} END{print v}') | |
[ "$val" = 1 ] && exit 6 | |
# Save PID to temp file only if lldb command succeeded | |
echo "$PID" > "$TEMP_PID_FILE" | |
echo "Successfully processed and saved PID" | |
fi | |
else | |
echo "eligibilityd not found" | |
sleep 1 | |
exit 2 | |
fi | |
### | |
INSTALL_PATH="/usr/local/bin/eligibilityfix.sh" | |
if [[ ! -f "$INSTALL_PATH" ]]; then | |
sudo mkdir -p /usr/local/bin | |
sudo cp "$0" "$INSTALL_PATH" | |
sudo chmod +x "$INSTALL_PATH" | |
fi | |
LAUNCHD_PLIST=/Library/LaunchDaemons/com.chinaSKU.eligibility.fix.plist | |
if [[ ! -f "$LAUNCHD_PLIST" ]]; then | |
cat <<EOL | sudo tee $LAUNCHD_PLIST > /dev/null | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.chinaSKU.eligibility.fix</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/bash</string> | |
<string>/usr/local/bin/eligibilityfix.sh</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>KeepAlive</key> | |
<dict> | |
<key>OtherJobEnabled</key> | |
<dict> | |
<key>com.apple.eligibilityd</key> | |
<true/> | |
</dict> | |
</dict> | |
<key>StandardErrorPath</key> | |
<string>/tmp/eligibilityfix.err</string> | |
<key>StandardOutPath</key> | |
<string>/tmp/eligibilityfix.log</string> | |
</dict> | |
</plist> | |
EOL | |
sudo chown root:wheel $LAUNCHD_PLIST | |
sudo chmod 644 $LAUNCHD_PLIST | |
sudo launchctl load "$LAUNCHD_PLIST" | |
fi | |
echo "Done!!!" | |
while :; do | |
curPID=$(getpid) | |
if [ -n "$curPID" ] && [ "$curPID" != "$PID" ]; then | |
echo "eligibilityd PID changed from $PID to $curPID" | |
exit 0 | |
fi | |
sleep 2 | |
done |
update: fix an issue that writing tool is not available and siri icon remains siri on chinese model
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
originally by songjialin here: Kyle-Ye/XcodeLLMEligible#73 (comment)