Preface

Recently, I need to recompile an iOS jailbreak plugin named PassBy, and found that it reported errors frequently on my new device, so I recorded the exploration and solution process below.

Since I’m not a professional, and I don’t even know much about iOS development, this is a record of my exploration with the attitude of learning. If there are any mistakes, welcome to criticize and correct in the comment section.

By the way, I would like to advertise my other related article haha:

iOS Jailbreak Plugin PassBy Customization, documenting my attempts to solve PassBy’s non-recognition of Bluetooth wearable devices other than the Apple Watch.

Trying to compile

Firstly

System: macOS Monterey 12.6.5

Chip type: Intel chip, not M series

Xcode version: 14.2

I first tried to compile directly by typing make package, which prompted openURL has been deprecated.

openurl deprecated

At this point I guessed that the Xcode version was too high to cause the mismatch, and I was going to go to the source code on GitHub first to see if the author had made any updates. Unfortunately, there was nothing I could do but try to modify the code.

According to the error message I first found the relevant c file, searched for the openURL keyword and commented out the relevant code.

comment openURL code

Continue to look for, you can find that this is not affect the main function of the code, should be to perform a donation and source code to open the URL of the operation, because I am not familiar with Objective-C language, the simplest way is to directly comment out, but fortunately does not affect the main function of the plug-in. The two URLs I pasted below:

comment openURL code

Secondly

Trying to continue compiling, unsurprisingly, a new problem arises.

This time, the problem is even more difficult, as theos is directly prompted by the Xcode compiler that it cannot find the Message framework.

Message framework not found

This problem would not be something I could fix with a simple modification. My guess is that the newer versions of Xcode have discarded the framework, which leaves me with two options: either refactor the code (which would be too difficult for me to do), or switch to an older version of Xcode (which is a bit of an unknown quantity until I get my hands on it, and I can’t guarantee that I’ll be able to fix it).

I can only try to change the Xcode version.

Change the Xcode version

First check the current version, you can see that it is version 14.2.

View version

On the Xcode support page you can clearly see the minimum system requirements for each Xcode version as well as the included SDKs and other information.

Xcode version differences

Next go to Apple’s official download page about all versions of Xcode and just download an older version. I downloaded version 12.5.1.

Download version 12.5.1 of Xcode

The next step is to extract the .xip file, change the name of the extracted Xcode.app to a name like Xcode_12.5.app, and finally move it to the /Application directory.

Unzip and rename

As you can see in the image above, my old version of Xcode doesn’t open directly, but it doesn’t matter for the purposes of this chapter, we don’t need to open the old version of Xcode directly to operate it. Please read on to find out why.

It takes a while to unpack, so be patient.

Alternatively, you can download and update Xcode in the usual way. With a multi-threaded download tool, you can basically run at full broadband speed and avoid App Store download failures. The disadvantage is that decompression is more time-consuming.

Switch Development

Note that the subtitle of this section is not “Switching Xcode Versions”, because for us, all we need is the scripting tools that come with older versions of Xcode in the development directory, such as gcc and so on.

developer tools directory

Next just use this command to switch the xcode-select directory:

1
sudo xcode-select -s /Applications/{modify here to a specific filename}/Contents/Developer/

Just change it to your old version of the file name, and enter the password without showing it.

switch path

At this point, enter the command again to verify:

1
2
3
4
xcodebuild -version
xcode-select -p
gcc -v
g++ -v

old version of gcc

The output of all the above commands can be seen in the words of the name of the old version of Xcode file you chose, something like Xcode_12.5.

Thirdly

Trying to compile again, the problem is finally solved.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
yuesir at iMac in /Volumes/Data/Xcode/PassBy
$ make package
> Making all for tweak PassBy…
make[2]: Nothing to be done for 'internal-library-compile'.
> Making all in passbyprefs…
> Making all for bundle PassByPrefs…
==> Copying resource directories into the bundle wrapper…
==> Compiling PassByRootListController.m (arm64)==> Compiling PassByRootListController.m (arm64e)==> Linking bundle PassByPrefs (arm64)==> Generating debug symbols for PassByPrefs…
==> Stripping PassByPrefs (arm64)==> Linking bundle PassByPrefs (arm64e)==> Generating debug symbols for PassByPrefs…
==> Stripping PassByPrefs (arm64e)==> Merging bundle PassByPrefs…
==> Signing PassByPrefs…
> Making all in passbyflipswitch…
> Making all for bundle PassByFlipswitch…
==> Copying resource directories into the bundle wrapper…
make[3]: Nothing to be done for 'internal-bundle-compile'.
> Making stage for tweak PassBy…
> Making stage in passbyprefs…
> Making stage for bundle PassByPrefs…
> Making stage in passbyflipswitch…
> Making stage for bundle PassByFlipswitch…
dm.pl: building package `com.giorgioiavicoli.passby:iphoneos-arm' in `./packages/com.giorgioiavicoli.passby_1.9.5_iphoneos-arm.deb'

In fact, I tried to restore the above commented out code to normal, but I didn’t realize that it still reported the same error!

I suspected that it might be a problem with the version of Command Line Tools installed. I didn’t try it because I didn’t know what would happen if I installed a lower version of Tools.

Switch Back

1
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/

Simply verify it:

Switch back to original version

Script

Here’s another script shared by others, but I didn’t try it myself, so I’m posting the link here as a thank you.

Link to the article: https://www.cnblogs.com/zndxall/p/12463744.html

Thanks

Apple Xcode

Xcode installs multiple versions and switches versions automatically