본문 바로가기

React Native

[Error] iOS build 에러 - Undefined symbol: _swift_stdlib_isStackAllocationSafe

Showing All Messages
Undefined symbol: _swift_stdlib_isStackAllocationSafe

 

오랜만에 이전에 진행했던 프로젝트를 업데이트 할 일이 생겨서 배포를 진행하려하는데 난데없이 iOS 빌드과정에서 에러가 발생하였습니다. 신기한건 xcode cli 에서 빌드하면 이상 없이 되는데 xcode에서 빌드하려고만 하면 이 애러가 발생하였습니다.

 

원인

xcode에서 라이브러리를 찾는 경로에 대한 설정 문제인 듯 합니다.

 

해결 방법

1. react native 버전 업데이트 하기

해당 문제는 react-native 0.67+ 버전에서 해결 되었다고 합니다. 지금 제 프로젝트 버전이 0.63.5 이기 때문에 근본적인 해결을 위해선 버전을 올려야 겟지만... 시간 관계상 저는 다른 방법으로 해결하였습니다. 버전을 올리실 분들은 아래 링크를 통해 업데이트를 진행하시면 되겠습니다.

 

https://react-native-community.github.io/upgrade-helper/

 

Upgrade React Native applications

 

react-native-community.github.io

 

 

2. pod 파일 및 Library search paths 수정

먼저 react-native-purchases 페키지를 최신버전으로 업데이트 합니다.

npm i react-native-purchases

 

다음으로 podfile에 아래 내용을 추가 해 줍니다.

 
 post_install do |installer|
 	# post_install 이 이미 있다면 그 안에 아래 두 줄을 추가해 주시고
    # 없다면 post_install 부분 전체를 target 'packagename' 안에 추가 해 줍니다.
    react_native_post_install(installer)
    fix_library_search_paths(installer)
  end


# podfile 마지막에 아래 내용들을 추가 해 줍시다.
def fix_library_search_paths(installer)
  def fix_config(config)
    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
    if lib_search_paths
      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
        # since the libraries there are only built for x86_64 and i386.
        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
        lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
        end
      end
    end
  end

  projects = installer.aggregate_targets
    .map{ |t| t.user_project }
    .uniq{ |p| p.path }
    .push(installer.pods_project)

  projects.each do |project|
    project.build_configurations.each do |config|
      fix_config(config)
    end
    project.native_targets.each do |target|
      target.build_configurations.each do |config|
        fix_config(config)
      end
    end
    project.save()
  end
end

 

다음으로 xcode에 들어 가셔서

project -> Build Settings에서 Library Search Paths를 검색 하신 후

$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)

을 삭제 하신 후

$(SDKROOT)/usr/lib/swift

를 추가 해주시면 됩니다.

 

 

마지막으로 build clean 후 다시 build 해 주시면 끝입니다!!

 

 

참고 자료:https://stackoverflow.com/questions/71597475/symbols-not-found-for-architecture-arm64-xcode

'React Native' 카테고리의 다른 글

[에러]run android kotlin 관련 에러  (0) 2023.05.23
react-native 시작하기  (1) 2023.05.08