Recent Posts
Recent Comments
Link
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Archives
Today
Total
관리 메뉴

공부 마렵다

React-Native 설치~ 본문

토이 프로젝트/영화 캘린더

React-Native 설치~

Nidust 2020. 7. 25. 00:21

참고로 나는 MacBook 을 사용한다.

 

조금 찾아보니까 설치도 간단하네

npm 설치 먼저 하고 아래와 같이 react-native-cli 설치 진행하면 된다

$ npm install -g react-native-cli

 

설치 완료되면 원하는 경로가서 아래와 같이 프로젝트 생성하면 끝! (HelloWorld는 그냥 프로젝트 이름이다)

$ react-native init HelloWorld

음... 근데 프로젝트 생성하다가 에러가 나네..?

? CocoaPods (https://cocoapods.org/) is not installed. CocoaPods is necessary fo
r the iOS project to run correctly. Do you want to install it? Yes, with Homebre
w
(node:13830) UnhandledPromiseRejectionWarning: Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./HelloWorld/ios && pod install".
CocoaPods documentation: https://cocoapods.org/
    at runPodInstall (/Users/jaeseok-pc/Desktop/HelloWorld/node_modules/@react-native-community/cli/build/tools/installPods.js:99:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:13830) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:13830) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
gimjaeseog-ui-MacBook-Pro:desktop jaeseok-pc$ cd HelloWorld/ios
gimjaeseog-ui-MacBook-Pro:ios jaeseok-pc$ pod install
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory

iOS프로젝트 사용할려면 CocoaPods이 필요한거 같은데

설치해준다고 하길래 Homebrew로 선택하니까 에러나네...

수동으로 깔아야 겠다

 

아래 명령어로 설치 진행했다

sudo gem install cocoapods

 

근데 이것도 에러나네

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200416-2584-hct4l8.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

 

구글링해서 찾아보니까 해결법을 찾기는 했다.. 근데 이해는 잘 못해서 아래 링크 건다

내가 이해하기로는 버전에 맞는 ruby를 찾지 못해서 발생한 이슈라고 이해했다.

https://stackoverflow.com/questions/60481623/errors-when-installing-cocoapods-with-gem

 

Errors when installing cocoapods with gem

I am using macOS Mojave and when I try to install cocoapods using gem I am getting the following error. Building native extensions. This could take a while... ERROR: Error installing cocoapo...

stackoverflow.com

 

그래서 해결법은 아래와 같다.

$ sudo xcodebuild -license accept
$ sudo xcode-select --switch /Library/Developer/CommandLineTools
$ ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'
$ sudo gem install -n /usr/local/bin cocoapods
$ sudo gem install cocoapods --pre

pod 명령어 쳐보니까 잘된다.. 드디어!!

이제 프로젝트 경로가서 다시 셋팅해보자

$ cd ./HelloWorld/ios
$ pod install

 

 

이번에도 안된다. 휴우.... 슬슬 힘들어질라고 하네 젠장

에러는 아래와 같다

[!] /bin/bash -c 
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="armv7"
    fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

./configure --host arm-apple-darwin

# Fix build for tvOS
cat << EOF >> src/config.h
/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif
/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif
/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot 
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/jaeseok-pc/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/jaeseok-pc/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/jaeseok-pc/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details

구글링 해보니까 Xcode 인식을 못해서 그런거라고 한다

아래 명령어 추가해서 다시 해보자

$ sudo xcode-select --switch /Applications/Xcode.app
$ pod install

 

호우호우~~ 드디어 잘된다!!!

이제 실행할 일만 남았다.


실행은 프로젝트 루트 경로에 가서 진행해야되고 아래 명령어만 사용해주면 된다

그럼 IOS 시뮬레이터가 켜질것이다

$ react-native run-ios

서버가 꺼져있으면 자동으로 실행을 해주는데 시뮬레이터의 앱을 켰을 때 에러가 발생한다.

 

웹사이트에서 접속을 해봤을 때는 정상적으로 되는 것으로 보아서는

시뮬레이터나 설정 문제인것 같다

'토이 프로젝트 > 영화 캘린더' 카테고리의 다른 글

뭘로 만들지?  (0) 2020.07.24
프로젝트를 시작하며..  (0) 2020.07.24
Comments