diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 28a06189d98..f66febbfda6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -74,6 +74,16 @@ jobs: PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig SKIP_SSH_TESTS: true SKIP_NEGOTIATE_TESTS: true + - name: "iOS" + id: ios + os: macos-12 + setup-script: ios + env: + CC: clang + CMAKE_OPTIONS: -DBUILD_TESTS=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON -DCMAKE_TOOLCHAIN_FILE=../ios.toolchain.cmake -DCMAKE_SYSTEM_NAME=iOS -DPLATFORM=OS64 + CMAKE_GENERATOR: Ninja + PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig + SKIP_TESTS: true # Cannot exec iOS app on macOS - name: "Windows (amd64, Visual Studio, Schannel)" id: windows-amd64-vs os: windows-2019 diff --git a/README.md b/README.md index 4d84df521c1..afeaeaaa38f 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Table of Contents * [Advanced Usage](#advanced-usage) * [Compiler and linker options](#compiler-and-linker-options) * [macOS](#macos) + * [iOS](#ios) * [Android](#android) * [MinGW](#mingw) * [Language Bindings](#language-bindings) @@ -329,6 +330,30 @@ If you'd like to work with Xcode, you can generate an Xcode project with "-G Xco > (10.4.4 ~ 10.6), CMake sets it all up for you if you use > `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"` when configuring. +iOS +------- + +1. Get an iOS cmake toolchain File: + +You can use a pre-existing toolchain file like [ios-cmake](https://github.com/leetal/ios-cmake) or write your own. + +2. Specify the toolchain and system Name: + +- The CMAKE_TOOLCHAIN_FILE variable points to the toolchain file for iOS. +- The CMAKE_SYSTEM_NAME should be set to iOS. + +3. Example Command: + +Assuming you're using the ios-cmake toolchain, the command might look like this: + +``` +cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=path/to/ios.toolchain.cmake -DCMAKE_SYSTEM_NAME=iOS -DPLATFORM=OS64 .. +``` + +4. Build the Project: + +After generating the project, open the .xcodeproj file in Xcode, select your iOS device or simulator as the target, and build your project. + Android ------- diff --git a/ci/setup-ios-build.sh b/ci/setup-ios-build.sh new file mode 100755 index 00000000000..94af4e486de --- /dev/null +++ b/ci/setup-ios-build.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -ex + +brew update +brew install pkgconfig libssh2 ninja + +ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib + +curl -s -L https://raw.githubusercontent.com/leetal/ios-cmake/master/ios.toolchain.cmake -o ios.toolchain.cmake diff --git a/cmake/FindIntlIconv.cmake b/cmake/FindIntlIconv.cmake index 9e6ded99dc4..07959ca1a19 100644 --- a/cmake/FindIntlIconv.cmake +++ b/cmake/FindIntlIconv.cmake @@ -15,6 +15,12 @@ find_path(ICONV_INCLUDE_DIR iconv.h) check_function_exists(iconv_open libc_has_iconv) find_library(iconv_lib NAMES iconv libiconv libiconv-2 c) +# workaround the iOS issue where iconv is provided by libc +# We set it to false to force it add -liconv to the linker flags +if(CMAKE_SYSTEM_NAME MATCHES "iOS") + set(libc_has_iconv FALSE) +endif() + if(ICONV_INCLUDE_DIR AND libc_has_iconv) set(ICONV_FOUND TRUE) set(ICONV_LIBRARIES "") diff --git a/cmake/SelectGSSAPI.cmake b/cmake/SelectGSSAPI.cmake index 5bde11697df..829850a4de9 100644 --- a/cmake/SelectGSSAPI.cmake +++ b/cmake/SelectGSSAPI.cmake @@ -2,7 +2,7 @@ include(SanitizeBool) # We try to find any packages our backends might use find_package(GSSAPI) -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") +if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "iOS") include(FindGSSFramework) endif() diff --git a/cmake/SelectHTTPSBackend.cmake b/cmake/SelectHTTPSBackend.cmake index d293001f567..61bc763fce5 100644 --- a/cmake/SelectHTTPSBackend.cmake +++ b/cmake/SelectHTTPSBackend.cmake @@ -3,7 +3,7 @@ include(SanitizeBool) # We try to find any packages our backends might use find_package(OpenSSL) find_package(mbedTLS) -if(CMAKE_SYSTEM_NAME MATCHES "Darwin") +if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "iOS") find_package(Security) find_package(CoreFoundation) endif() diff --git a/cmake/SelectRegex.cmake b/cmake/SelectRegex.cmake index 2a3a91b8cd3..840ec7f349f 100644 --- a/cmake/SelectRegex.cmake +++ b/cmake/SelectRegex.cmake @@ -5,7 +5,12 @@ if(REGEX_BACKEND STREQUAL "") check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L) if(HAVE_REGCOMP_L) - set(REGEX_BACKEND "regcomp_l") + # 'regcomp_l' has been explicitly marked unavailable on iOS_SDK + if(CMAKE_SYSTEM_NAME MATCHES "iOS") + set(REGEX_BACKEND "regcomp") + else() + set(REGEX_BACKEND "regcomp_l") + endif() elseif(PCRE_FOUND) set(REGEX_BACKEND "pcre") else() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed3f4a51427..73c46e21043 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -127,7 +127,8 @@ endif() # realtime support check_library_exists(rt clock_gettime "time.h" NEED_LIBRT) -if(NEED_LIBRT) + +if(NEED_LIBRT AND NOT CMAKE_SYSTEM_NAME MATCHES "iOS") list(APPEND LIBGIT2_SYSTEM_LIBS rt) list(APPEND LIBGIT2_PC_LIBS "-lrt") endif() @@ -201,7 +202,7 @@ add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support") add_subdirectory(libgit2) add_subdirectory(util) -if(BUILD_CLI) +if(BUILD_CLI AND NOT CMAKE_SYSTEM_NAME MATCHES "iOS") add_subdirectory(cli) endif()