A package manager for Xcode to build C/C++/Rust/Go project.
-
This software is being actively developed. It's in beta stage and may not be stable. Some features are subject to change without notice.
-
Please do NOT place your own files under
~/.xcpkg
directory, asxcpkg
will change files under~/.xcpkg
directory without notice. -
Please do NOT run
xcpkg
command in parallel to avoid generating dirty data.
In this way, you will be liberated from the rut of setting up the build environment.
In this way, all you need to do is just clicking the buttons and waiting for finishing. After finishing, a url refers to a zip archive will be provided to download.
For more details please refer to https://github.com/leleliu008/xcpkg-package-manually-build
curl -LO https://raw.githubusercontent.com/leleliu008/xcpkg/master/xcpkg
chmod a+x xcpkg
./xcpkg setup
wget https://cdn.jsdelivr.net/gh/leleliu008/xcpkg/xcpkg
chmod a+x xcpkg
./xcpkg setup
git clone --depth 1 https://github.com/leleliu008/xcpkg
xcpkg/xcpkg setup
all relevant directories and files are located under ~/.xcpkg
directory.
-
show help of this command
xcpkg -h xcpkg --help
-
show version of this command
xcpkg -V xcpkg --version
-
show basic information about this software
xcpkg env
-
show basic information about your current running operation system
xcpkg sysinfo
-
show your current activated Xcode information
xcpkg xcinfo
-
show the given Xcode information
xcpkg xcinfo --developer-dir=/Applications/Xcode12.app/Contents/Developer
-
show the supported target platform names only
xcpkg xcinfo --list-supported-platform-names xcpkg xcinfo --list-supported-platform-names --developer-dir=/Applications/Xcode12.app/Contents/Developer
-
generate url-transform sample
xcpkg gen-url-transform-sample
-
install essential tools
xcpkg setup
This command is actually to do two things:
-
integrate
zsh-completion
scriptxcpkg integrate zsh xcpkg integrate zsh --output-dir=/usr/local/share/zsh/site-functions xcpkg integrate zsh -v
This project provides a zsh-completion script for
xcpkg
. when you've typedxcpkg
then typeTAB
key, the rest of the arguments will be automatically complete for you.Note: to apply this feature, you may need to run the command
autoload -U compinit && compinit
in your terminal (your current running shell must be zsh). -
update all available formula repositories
xcpkg update
-
search all available packages whose name matches the given regular expression pattern
xcpkg search curl xcpkg search curl -v xcpkg search '^lib'
-
show information of the given available package
xcpkg info-available curl xcpkg info-available curl --yaml xcpkg info-available curl --json xcpkg info-available curl version xcpkg info-available curl license xcpkg info-available curl summary xcpkg info-available curl web-url xcpkg info-available curl git-url xcpkg info-available curl git-sha xcpkg info-available curl git-ref xcpkg info-available curl src-url xcpkg info-available curl src-sha
-
show information of the given installed package
xcpkg info-installed iPhoneOS-12.0-arm64/curl xcpkg info-installed iPhoneOS-12.0-arm64/curl --prefix xcpkg info-installed iPhoneOS-12.0-arm64/curl --files xcpkg info-installed iPhoneOS-12.0-arm64/curl --yaml xcpkg info-installed iPhoneOS-12.0-arm64/curl --json xcpkg info-installed iPhoneOS-12.0-arm64/curl version xcpkg info-installed iPhoneOS-12.0-arm64/curl license xcpkg info-installed iPhoneOS-12.0-arm64/curl summary xcpkg info-installed iPhoneOS-12.0-arm64/curl web-url xcpkg info-installed iPhoneOS-12.0-arm64/curl git-url xcpkg info-installed iPhoneOS-12.0-arm64/curl git-sha xcpkg info-installed iPhoneOS-12.0-arm64/curl git-ref xcpkg info-installed iPhoneOS-12.0-arm64/curl src-url xcpkg info-installed iPhoneOS-12.0-arm64/curl src-sha xcpkg info-installed iPhoneOS-12.0-arm64/curl builtat xcpkg info-installed iPhoneOS-12.0-arm64/curl builtat-iso-8601 xcpkg info-installed iPhoneOS-12.0-arm64/curl builtat-rfc-3339 xcpkg info-installed iPhoneOS-12.0-arm64/curl builtat-iso-8601-utc xcpkg info-installed iPhoneOS-12.0-arm64/curl builtat-rfc-3339-utc
-
show packages that are depended by the given package
xcpkg depends curl xcpkg depends curl -t dot xcpkg depends curl -t box xcpkg depends curl -t png xcpkg depends curl -t svg xcpkg depends curl -t dot -o dependencies/ xcpkg depends curl -t box -o dependencies/ xcpkg depends curl -t png -o dependencies/ xcpkg depends curl -t svg -o dependencies/ xcpkg depends curl -o curl-dependencies.dot xcpkg depends curl -o curl-dependencies.box xcpkg depends curl -o curl-dependencies.png xcpkg depends curl -o curl-dependencies.svg
-
download resources of the given package to the local cache
xcpkg fetch curl xcpkg fetch curl -v
-
install packages
xcpkg install curl xcpkg install curl --upgrade xcpkg install curl --target=iPhoneOS-12.0-arm64 xcpkg install curl --developer-dir=/Applications/Xcode12.app/Contents/Developer xcpkg install iPhoneOS-12.0-arm64/curl
-
reinstall packages
xcpkg reinstall curl xcpkg reinstall iPhoneOS-12.0-arm64/curl
-
uninstall packages
xcpkg uninstall curl xcpkg uninstall iPhoneOS-12.0-arm64/curl
-
upgrade the outdated packages
xcpkg upgrade xcpkg upgrade curl xcpkg upgrade iPhoneOS-12.0-arm64/curl
-
upgrade this software
xcpkg upgrade-self xcpkg upgrade-self -v
-
list all available formula repositories
xcpkg formula-repo-list
-
add a new formula repository
xcpkg formula-repo-add my_repo https://github.com/leleliu008/xcpkg-formula-repository-my_repo xcpkg formula-repo-add my_repo https://github.com/leleliu008/xcpkg-formula-repository-my_repo master xcpkg formula-repo-add my_repo https://github.com/leleliu008/xcpkg-formula-repository-my_repo main
-
delete a existing formula repository
xcpkg formula-repo-del my_repo
-
check if the given package is available
xcpkg is-available curl
-
check if the given package is installed
xcpkg is-installed curl xcpkg is-installed iPhoneOS-12.0-arm64/curl
-
check if the given package is outdated
xcpkg is-outdated curl xcpkg is-outdated iPhoneOS-12.0-arm64/curl
-
list all available packages
xcpkg ls-available xcpkg ls-available -v
-
list all installed packages
xcpkg ls-installed xcpkg ls-installed -v
-
list all outdated packages
xcpkg ls-outdated xcpkg ls-outdated -v
-
list installed files of the given installed package in a tree-like format
xcpkg tree curl xcpkg tree iPhoneOS-12.0-arm64/curl -L 3
-
show logs of the given installed package
xcpkg logs curl xcpkg logs iPhoneOS-12.0-arm64/curl
-
pack the given installed package
xcpkg pack curl xcpkg pack iPhoneOS-12.0-arm64/curl xcpkg pack iPhoneOS-12.0-arm64/curl -t tar.xz xcpkg pack iPhoneOS-12.0-arm64/curl -t tar.gz xcpkg pack iPhoneOS-12.0-arm64/curl -t tar.lz xcpkg pack iPhoneOS-12.0-arm64/curl -t tar.bz2 xcpkg pack iPhoneOS-12.0-arm64/curl -t zip xcpkg pack iPhoneOS-12.0-arm64/curl -t zip -o a/ xcpkg pack iPhoneOS-12.0-arm64/curl -o a/x.zip
-
delete the unused cached files
xcpkg cleanup
-
HOME
This environment variable already have been set on macOS, if not set or set a empty string, you will receive an error message.
-
PATH
This environment variable already have been set on macOS, if not set or set a empty string, you will receive an error message.
-
DEVELOPER_DIR
If this environment variable is set,
xcpkg
will use it as the Xcode developer dir, otherwise,xcpkg
will run commandxcode-select -p
to determine the Xcode developer dir. -
SSL_CERT_FILE
curl -LO https://curl.se/ca/cacert.pem export SSL_CERT_FILE="$PWD/cacert.pem"
In general, you don't need to set this environment variable, but, if you encounter the reporting
the SSL certificate is invalid
, trying to run above commands in your terminal will do the trick. -
GOPROXY
export GOPROXY='https://goproxy.cn'
-
XCPKG_URL_TRANSFORM
export XCPKG_URL_TRANSFORM=/path/of/url-transform
/path/of/url-transform
command would be invoked as/path/of/url-transform <URL>
/path/of/url-transform
command must output a<URL>
you can generate a url-transform sample via
xcpkg gen-url-transform-sample
If you want to change the request url, you can set this environment variable. It is very useful for chinese users.
-
XCPKG_XTRACE
for debugging purposes.
enables
set -x
:export XCPKG_XTRACE=1
-
XCPKG_DEFAULT_TARGET
some commands need
<PACKAGE-SPEC>
to be specified.<PACKAGE-SPEC>
has the form<TARGET>/<PACKAGE-NAME>
. To simplify the usage,xcpkg
allows omitting<TARGET>/
. If<TARGET>/
is omitted, this environment variable will be used, if this environment variable is not set, then will retrieve your current running os's information.<TARGET>
has the form<TARGET-PLATFORM-NAME>-<TARGET-PLATFORM-VERSION>-<TARGET-PLATFORM-ARCH>
example:
export XCPKG_DEFAULT_TARGET=MacOSX-10.15-x86_64
Note: some commonly used environment variables are override by this software, these are CC
, CXX
, CPP
, AS
, AR
, LD
, CFLAGS
, CPPFLAGS
, LDFLAGS
, PKG_CONFIG_LIBDIR
, PKG_CONFIG_PATH
, ACLOCAL_PATH
a xcpkg formula is a YAML format file which is used to config a xcpkg package's meta-information including one sentence description, package version, installation instructions, etc.
a xcpkg formula's filename suffix must be .yml
a xcpkg formula'a filename prefix would be treated as the package name.
a xcpkg formula'a filename prefix must match regular expression pattern ^[A-Za-z0-9+-._@]{1,50}$
a uppm formula's file content only has one level mapping and shall has following KEY:
KEY | required? | overview |
---|---|---|
summary |
required | describe this package in one sentence. |
license |
optional | a space-separated list of SPDX license short identifiers |
version |
optional | the version of this package. If this mapping is not present, it will be calculated from src-url , if src-url is also not present, it will be calculated from running time as format date +%Y.%m.%d |
web-url |
optional | the home webpage of this package. If this mapping is not present, git-url must be present. |
git-url |
optional | the source code git repository. If src-url is not present, this mapping must be present. |
git-ref |
optional | reference: https://git-scm.com/book/en/v2/Git-Internals-Git-References example values: HEAD refs/heads/master refs/heads/main refs/tags/v1 , default value is HEAD |
git-sha |
optional | the full git commit id, 40-byte hexadecimal string, if git-ref and git-sha both are present, git-sha takes precedence over git-ref |
git-nth |
optional | tell xcpkg that how many depth commits would you like to be fetched. default is 1 , this would save your time and storage. If you want to fetch all commits, set this to 0 |
src-url |
optional | the source code download url of this package. If value of this mapping ends with one of .zip .tar.xz .tar.gz .tar.lz .tar.bz2 .tgz .txz .tlz .tbz2 , it will be uncompressed to $PACKAGE_WORKING_DIR/src when this package is installing, otherwise, it will be copied to $PACKAGE_WORKING_DIR/src also support format like dir://DIR |
src-uri |
optional | the mirror of src-url . |
src-sha |
optional | the sha256sum of source code.src-sha and src-url must appear together. |
fix-url |
optional | the patch file download url of this package. If value of this mapping ends with one of .zip .tar.xz .tar.gz .tar.lz .tar.bz2 .tgz .txz .tlz .tbz2 , it will be uncompressed to $PACKAGE_WORKING_DIR/fix when this package is installing, otherwise, it will be copied to $PACKAGE_WORKING_DIR/fix . |
fix-sha |
optional | the sha256sum of patch file.fix-sha and fix-url must appear together. |
res-url |
optional | other resource download url of this package. If value of this mapping ends with one of .zip .tar.xz .tar.gz .tar.lz .tar.bz2 .tgz .txz .tlz .tbz2 , it will be uncompressed to $PACKAGE_WORKING_DIR/res when this package is installing, otherwise, it will be copied to $PACKAGE_WORKING_DIR/res . |
res-sha |
optional | the sha256sum of resource file.res-sha and res-url must appear together. |
dep-pkg |
optional | a space-separated list of xcpkg packages that are depended by this package when installing and/or runtime, which will be installed via xcpkg. |
dep-upp |
optional | a space-separated list of uppm packages that are depended by this package when installing and/or runtime, which will be installed via uppm. |
dep-pym |
optional | a space-separated list of python packages that are depended by this package when installing and/or runtime, which will be installed via pip3. |
dep-plm |
optional | a space-separated list of perl modules that are depended by this package when installing and/or runtime, which will be installed via cpan. |
ccflags |
optional | append to CFLAGS |
xxflags |
optional | append to CXXFLAGS |
ppflags |
optional | append to CPPFLAGS |
ldflags |
optional | append to LDFLAGS |
bsystem |
optional | build system name. values can be some of autogen autotools configure cmake cmake-gmake cmake-ninja meson xmake gmake ninja cargo go |
bscript |
optional | the directory where the build script is located in, relative to PACKAGE_WORKING_DIR . build script such as configure , Makefile , CMakeLists.txt , meson.build , Cargo.toml , etc. |
binbstd |
optional | whether to build in the directory where the build script is located in, otherwise build in other directory. value shall be 0 or 1 . default value is 0 . |
symlink |
optional | whether to symlink installed files to $XCPKG_HOME/symlinked/* . value shall be 0 or 1 . default value is 1 . It is only meaningful when requesting for native building. |
do12345 |
optional | POSIX shell code to be run for native build. It is only meaningful when requesting for cross building. |
dopatch |
optional | POSIX shell code to be run to apply patches for target build. current working directory is $PACKAGE_BSCRIPT_DIR |
install |
optional | POSIX shell code to be run for target build. If this mapping is not present, xcpkg will run default install code according to bsystem |
commands that can be used out of the box:
command | usage-example |
---|---|
bash |
Reference |
CoreUtils |
Reference |
find |
Reference |
gawk |
Reference |
gsed |
Reference |
grep |
Reference |
yq |
Reference |
jq |
Reference |
git |
Reference |
curl |
Reference |
bsdtar |
Reference |
tree |
Reference |
pkg-config |
Reference |
echo |
echo 'your message.' |
info |
info 'your information.' |
warn |
warn "no package manager found." |
error |
error 'error message.' |
abort |
abort 1 "please specify a package name." |
success |
success "build success." |
sed_in_place |
sed_in_place 's/-mandroid//g' Configure |
wfetch |
wfetch <URL> [--uri=<URL-MIRROR>] [--sha256=<SHA256>] [-o <PATH> [-q] |
configure |
configure --enable-pic |
mesonw |
mesonw -Dneon=disabled -Darm-simd=disabled |
cmakew |
cmakew -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON |
gmakew |
gmakew |
xmakew |
xmakew |
cargow |
cargow |
gow |
gow |
shell variables can be used directly:
variable | overview |
---|---|
TIMESTAMP_UNIX |
the unix timestamp of this action. |
NATIVE_OS_KIND |
current running os kind. value shall be darwin |
NATIVE_OS_TYPE |
current running os type. value shall be macos |
NATIVE_OS_NAME |
current running os name. value shall be MacOSX |
NATIVE_OS_VERS |
current running os version. |
NATIVE_OS_ARCH |
current running os arch. value might be any one of x86_64 , arm64 , etc |
NATIVE_OS_NCPU |
current running os's cpu core count. |
NATIVE_OS_EUID |
current running os's effective user ID. |
NATIVE_OS_EGID |
current running os's effective group ID. |
TARGET_PLATFORM_NAME |
target platform name that is built for. value shall be any one of AppleTVOS AppleTVSimulator DriverKit MacOSX WatchOS WatchSimulator iPhoneOS iPhoneSimulator |
TARGET_PLATFORM_VERS |
target platform version that is built with. |
TARGET_PLATFORM_ARCH |
target platform arch that is built for. value might be any one of x86_64 , arm64 , etc |
CROSS_COMPILING |
value shall be 0 or 1. indicates whether is cross-compiling. |
XCPKG_VERSION |
the version of xcpkg . |
XCPKG_HOME |
the home directory of xcpkg . |
XCPKG |
the executable filepath of xcpkg . |
UPPM |
the executable filepath of uppm |
CC_FOR_BUILD |
the C Compiler for native build. |
CFLAGS_FOR_BUILD |
the flags of CC_FOR_BUILD . |
CXX_FOR_BUILD |
the C++ Compiler for native build. |
CXXFLAGS_FOR_BUILD |
the flags of CXX_FOR_BUILD . |
CPP_FOR_BUILD |
the C/C++ PreProcessor for native build. |
CPPFLAGS_FOR_BUILD |
the flags of CPP_FOR_BUILD . |
AS_FOR_BUILD |
the assembler for native build. |
AR_FOR_BUILD |
the archiver for native build. |
RANLIB_FOR_BUILD |
the archiver extra tool for native build. |
LD_FOR_BUILD |
the linker for native build. |
LDFLAGS_FOR_BUILD |
the flags of LD_FOR_BUILD . |
NM_FOR_BUILD |
a command line tool to list symbols from object files for native build. |
STRIP_FOR_BUILD |
a command line tool to discard symbols and other data from object files for native build. |
CC |
the C Compiler. |
CFLAGS |
the flags of CC . |
CXX |
the C++ Compiler. |
CXXFLAGS |
the flags of CXX . |
CPP |
the C/C++ PreProcessor. |
CPPFLAGS |
the flags of CPP . |
AS |
the assembler. |
AR |
the archiver. |
RANLIB |
the archiver extra tool. |
LD |
the linker. |
LDFLAGS |
the flags of LD . |
NM |
a command line tool to list symbols from object files. |
STRIP |
a command line tool to discard symbols and other data from object files. |
PACKAGE_WORKING_DIR |
the working directory when installing. |
PACKAGE_BSCRIPT_DIR |
the directory where the build script (e.g. Makefile , configure , CMakeLists.txt , meson.build , Cargo.toml , etc) is located in. |
PACKAGE_BCACHED_DIR |
the directory where the temporary files are stored in when building. |
PACKAGE_INSTALL_DIR |
the directory where the final files will be installed to. |
x_INSTALL_DIR |
the installation directory of x package. |
x_INCLUDE_DIR |
$x_INSTALL_DIR/include |
x_LIBRARY_DIR |
$x_INSTALL_DIR/lib |
a xcpkg formula repository is a git repository.
a xcpkg formula repository's root dir should have a formula
named sub dir, this repository's formulas all should be located in this dir.
a xcpkg formula repository's local path is ~/.xcpkg/repos.d/${XCPKGFormulaRepoName}
xcpkg supports multiple formula repositories.
After a xcpkg formula repository is successfully fetched from server to local, a config file for this repository would be created at ~/.xcpkg/repos.d/${XCPKGFormulaRepoName}/.xcpkg-formula-repo.yml
a typical xcpkg formula repository's config as following:
url: https://github.com/leleliu008/xcpkg-formula-repository-official-core
branch: master
pinned: 0
enabled: 1
created: 1673684639
updated: 1673684767
If a xcpkg formula repository is pinned
, which means it would not be updated.
If a xcpkg formula repository is disabled
, which means xcpkg would not search formulas in this formula repository.
xcpkg official formula repository's url: https://github.com/leleliu008/xcpkg-formula-repository-official-core
xcpkg official formula repository would be automatically fetched to local cache as name official-core
when you run xcpkg update
command.
Note: If you find that a package is not in xcpkg official formula repository yet, PR is welcomed.
I have built and packed some commonly used packages using this software:
- https://github.com/leleliu008/uppm-package-repository-macos10.15-x86_64
- https://github.com/leleliu008/uppm-package-repository-macos11.0-x86_64
- https://github.com/leleliu008/uppm-package-repository-macos12.0-x86_64
- https://github.com/leleliu008/uppm-package-repository-macos13.0-x86_64
- https://github.com/leleliu008/uppm-package-repository-macos11.0-arm64
- https://github.com/leleliu008/uppm-package-repository-macos12.0-arm64
- https://github.com/leleliu008/uppm-package-repository-macos13.0-arm64