8000 Add SecCopyErrorMessageString for iOS and update README for iOS by Kyle-Ye · Pull Request #6862 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Add SecCopyErrorMessageString for iOS and update README for iOS #6862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally sen 8000 d you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 26, 2024
10 changes: 10 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
-------

Expand Down
10 changes: 10 additions & 0 deletions ci/setup-ios-build.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions cmake/FindIntlIconv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
2 changes: 1 addition & 1 deletion cmake/SelectGSSAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion cmake/SelectHTTPSBackend.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion cmake/SelectRegex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ if(REGEX_BACKEND STREQUAL "")
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
628C
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()
Expand Down
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
Loading
0