MohGovIL / hamagen-react-native

Israel's Ministry of Health's COVID-19 Exposure Prevention App
https://health.gov.il/
MIT License
509 stars 153 forks source link

Document building ios app / passing `pod install` on linux #253

Closed emanuelb closed 4 years ago

emanuelb commented 4 years ago

Currently pod install is used when running npm install or yarn install even when building apk, not matter what the OS is #244

It might be possible to pass the pod install command successfully (or even build the IOS app on linux) not by cheating (such as using alias/links to /bin/true from pod command)

Here is not successful try to pass pod install command on linux (need more work, download correct iphonesdk and probably more stuff to fix)

I opened issue upstream for CocoaPods to add instructions for installation on linux (deps list, etc..) https://github.com/CocoaPods/CocoaPods/issues/9956

FROM docker.io/debian:sid-slim

ENV DEBIAN_FRONTEND=noninteractive \
    NODE_ENV="production"

RUN set -ex; \
    apt-get update; \
    apt-get install --yes --no-install-recommends \
# for darwin-sdk (need xcrun tool)
      clang libssl-dev dpkg-dev fakeroot debhelper llvm-dev uuid-dev libblocksruntime-dev libc6-dev-i386 gcc-multilib build-essential flex tcsh bison automake autogen libtool libdb-dev \
# for git clone
      ca-certificates git; \
# clang 4.0 is not in buster/sid
    echo 'deb http://deb.debian.org/debian stretch main' >> /etc/apt/sources.list; \
    apt-get update; \
    apt-get install --yes --no-install-recommends clang-4.0; \
    mkdir /applib/; \
    cd /applib/; \
    git clone --depth 1 https://github.com/darwin-on-arm/darwin-sdk; \
    cd darwin-sdk; \
    dpkg-buildpackage -us -uc; \
    dpkg -i ../darwin-sdk*.deb; \   
    apt-get install --yes --no-install-recommends \
# for npm install
      npm \
# for cocoapods
      ruby ruby-dev make gcc curl unzip libc6-dev locales locales-all; \
# install cocoapods
    gem install cocoapods; \
# set utf-8 locale for cocoapods
    update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8; \
    rm -rf /var/lib/apt/lists/*; \
    useradd -ms /bin/bash user;

USER user

COPY . /app/hamagen-react-native/

RUN set -ex; \
    cd /app/hamagen-react-native/; \
    npm install --production --ignore-scripts --no-optional;

Bulid by: podman build --rm -t magen_pod_install . Run by: podman run --rm -ti magen_pod_install Then run commands:

cd /app/hamagen-react-native/ios/;
export LANG=en_US.UTF-8;
pod install

Errors (after Installing glog (0.3.5)):

checking whether the C compiler works... no
xcrun: error: unable to read configuration cache. (No such file or directory)
xcrun: error: unable to read configuration cache. (No such file or directory)
/home/user/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-1f3da/missing: Unknown `--is-lightweight' option
Try `/home/user/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-1f3da/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/home/user/Library/Caches/CocoaPods/Pods/External/glog/2263bd123499e5b93b5efe24871be317-1f3da':
configure: error: C compiler cannot create executables
See `config.log' for more details

Because line:

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"`

Running commands: xcrun -find -sdk iphoneos cc & xcrun -sdk iphoneos --show-sdk-path will return: (when run under user) xcrun: error: unable to read configuration cache. (No such file or directory) will return: (when run under root)

 `xcrun -sdk iphoneos --show-sdk-path`

xcrun: error: unable to validate path '/opt/Developer/SDKs/iphoneos.sdk' (No such file or directory)
xcrun: error: '/opt/Developer/SDKs/iphoneos.sdk' is not a valid sdk path.

`xcrun -find -sdk iphoneos cc`

xcrun: error: can't stat '-sdk' (No such file or directory)
xcrun: error: unable to locate command '-sdk' (No such file or directory)

I won't spend more time for trying to make this works, for everyone interested below might help:

maybe can be fixed by using code/files from below repos: https://github.com/darmie/ios-toolchain-based-on-clang-for-linux https://github.com/okanon/iPhoneOS.sdk

The xcrun tool which is built from code in repo: https://github.com/darwin-on-arm/darwin-sdk can be built using the Containerfile I created at: https://github.com/darwin-on-arm/darwin-sdk/issues/4

kaplanlior commented 4 years ago

Its a lot of work just to work around one command. See suggestion at #248 which does that as well.

emanuelb commented 4 years ago

Its a lot of work just to work around one command.

for workaround it's enough to pass --ignore-scripts for yarn/npm install, or just using alias/link to /bin/true.

The above is not for workaround, it's for making pod install work on linux (it's a required step in order to compile the ios app) for the android app it's sure not needed, the question is how to reproduce the ios app released? is it possible to do so from linux-os? having at least some visibility into what happen in the ios build process is good :)

kaplanlior commented 4 years ago

Fixed with #248