Skip to content

Instantly share code, notes, and snippets.

@unixzii
Last active November 20, 2024 06:39
Show Gist options
  • Save unixzii/6f25be1842399022e16ad6477a304286 to your computer and use it in GitHub Desktop.
Save unixzii/6f25be1842399022e16ad6477a304286 to your computer and use it in GitHub Desktop.
A guide to force enabling Xcode LLM feature on China-SKU Macs.

Introduction

Apple restricted the access to Xcode LLM (Predictive code completion) feature on China models of Mac. This guide provides a way to bypass that restriction. It's verified on macOS 15.0 Beta (24A5264n), but there is no guarentee that it will always work on later macOS versions.

Prerequisites

  • Xcode is installed and run at least once.
  • SIP debugging restrictions are disabled (via csrutil enable --without debug command in recovery mode).

Disclaimer

Disabling SIP can cause some unknown effect. And for now, Xcode LLM is not stable and may cause kernel panics, which will lose some of your document modifications. Please use with caution.

Bypass Steps

1. Attach to eligibilityd using LLDB

$ sudo lldb

Then execute the below command in LLDB console:

(lldb) process attach --name eligibilityd

It should stop the main thread of eligibilityd process and show a (lldb) prompt if successful.

2. Modify the device region

(lldb) e (void) [[[InputManager sharedInstance] objectForInputValue:6] setValue:@"US" forKey:@"_deviceRegionCode"]

3. Recompute the domain answers

(lldb) e (void) [[EligibilityEngine sharedInstance] recomputeAllDomainAnswers]

4. Verify the domain answer (Optional)

You can check whether the operation is effective by executing:

(lldb) po [[[[EligibilityEngine sharedInstance] domains] objectForKey:@"OS_ELIGIBILITY_DOMAIN_XCODE_LLM"] answer]

If it prints 0x0000000000000004 then it's all good.

5. Detach the process and exit LLDB

(lldb) process detach
(lldb) exit

6. Restart Xcode and enjoy!

Acknowledgement

Thanks for those who make this possible together: Lakr233, Sou1gh0st, Yuriko.

@ChinaHarry23
Copy link

Screenshot 2024-06-23 at 8 28 47 AM it works like a charm, cheers

@ChinaHarry23
Copy link

I'm guessing all AI annoucement will be unrelated for us the Chinese people

@Gargo
Copy link

Gargo commented Jul 2, 2024

could you please suggest something similar but for 16gb limitation? I suppose it is like "obligatory" TPM module in windows.

@pengchengz30
Copy link

Appreciate, it works on my Mac!
72631720511791_ pic

@pengchengz30
Copy link

Appreciate, it works on my Mac! 72631720511791_ pic

However, SIP should be remained disabled. Once I turned it on, the option grayed out again.
Screenshot 2024-07-09 at 16 27 01

@wyon1314
Copy link

omg mymac show this error:attach failed: debugserver is x86_64 binary running in translation, attach failed.

me too, How to solve this situation

arch -arm64 sudo lldb

@XuWeinan123
Copy link

好奇问一嘴,禁用 SIP 后,修改系统文件,然后重新开启 SIP 会恢复 device region 吗。如果不会的话,修改完重新开启 SIP 系统是不是就可以在安全的方式下使用 Swift Assist 了。
Just curious, after disabling SIP, modifying system files, and then re-enabling SIP, will it restore the device region? If not, after modifying and re-enabling SIP, can the system be used securely with Swift Assist?

@pengchengz30
Copy link

好奇问一嘴,禁用 SIP 后,修改系统文件,然后重新开启 SIP 会恢复 device region 吗。如果不会的话,修改完重新开启 SIP 系统是不是就可以在安全的方式下使用 Swift Assist 了。 Just curious, after disabling SIP, modifying system files, and then re-enabling SIP, will it restore the device region? If not, after modifying and re-enabling SIP, can the system be used securely with Swift Assist?

我前面试了 不行 又变成灰的了。
I've tried to turn SIP back on, but the option grayed out.

@TmFtZW9mR2l0aHVi
Copy link

重启电脑就失效了,能否实现自动执行命令?
The command will fail if I restart the computer. Is it possible to execute the command automatically?

@Kyle-Ye
Copy link

Kyle-Ye commented Aug 2, 2024

可以尝试基于 override 文件的方式,该方式理论上是永久的

https://github.com/Kyle-Ye/XcodeLLMEligible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment