Location>code7788 >text

XCode compiles PAG source code

Popularity:994 ℃/2024-07-28 15:49:54

To be used in recent workPAGinterchangeabilityLottie, to make it easier to read the source code, use theXCodeCompiled its source code.

1 Download source code

Compiling the source code starts with downloading the source code about thePAGThe source code can be accessed directly atgithubUp for download.

2 Adding relevant dependencies

After downloading the source code, go to thePAGIn the project root directory, execute the following script.

./sync_deps.sh

3 Building the iOS PAGViewer Project

PAGThe project contains code under a variety of platforms, includingiOSWindowsLinuxetc. We only focus oniOS

From the root directory, go to theiOSdirectory, double-click thegen_iosfile. After execution, the directory will have an additional

4 Setting Up XCode Signing Certificates

strike (on the keyboard)Go toPAGproject project, do the following configuration so that thePAGViewerCompile it on your own phone.

image

After setting theTeamAfter that it will report an error and can be deletedBundle Identifierand then clickSigning CertificationlowerTry AgainButton.

5 Compiling

existXCodechoose fromPAGViewer``Targetas well as toiPhoneMobile, click to compile:.

image

6 Script Setup

A smooth source code compilation is often unattainable.PAGThe same goes for source code compilation.

During compilation, the following error is reported.

image

Look at the error message, it's compilingtgfxproject, and when running the script, the script command error isnodeCommand.

first checkMacWhether or not you have installed thenode

existMacterminal operationnode -vIf the following version information is output, it means that it has been installed.

v22.5.1

Now that it's installednodeThat.XCodeWhy do you still report that you can't find it?

The reason.XCodeWhen running the script thePATHenvironment variable is the same as the one in the terminalPATHThe environment variables are different.

XCodeThe process environment variables for themacOSset by the system at startup, not by the user'sShellConfiguration files (e.g.~/.bash_profile) set directly.

That is, we installed thenodeThe paths that are not in theXCode(used form a nominal expression)PATHunder the environment variable.

In order to viewXCode(used form a nominal expression)PATHenvironment variable, which can be set as shown below, by setting theXCode(used form a nominal expression)PATHEnvironment variables are output to theXCode(used form a nominal expression)ReportPanel.

image

figure aboveCMake PostBuild Ruleswill execute a script, and it is this script that reports errors in compilation.

Add to the scriptechocommand, outputXCode(used form a nominal expression)PATHInformation.

echo "Current PATH: $PATH"

Compile againPAGViewer TargetThe first is that it still fails, but theXCode(used form a nominal expression)ReportThe panel already has the following outputs.

image

replacing the aboveXCode(used form a nominal expression)PATHThe information is copied and saved, and then theMacterminal operationwhich nodecommand to view theMacfirst (of multiple parts)nodeinstallation directory.

localhost:~$ which node
/opt/homebrew/bin/node

It can be verified thatMacuppernodeinstallation directory/opt/homebrew/bin(euphemism) pass awayXCode(used form a nominal expression)PATHin the environment variables.

To fix this, we need to add this directory to theXCodein the environment variable in the script you just created by adding aexportStatement.

image

When you're done, you'll see that compilingtgfx-vendorThe same scripting problem occurs and is solved as described above:.

image

Finally, compiling again reveals that thePAGThe source code was successfully compiled by you!!!!