앱에서 Firebase Analytics를 이용할는데 인앱결제를 통한 수익에 sandbox환경에서 테스트한 금액까지 포함되어 나오는 문제가 있었다.
[GA4]Automatically collected events 문서를 보면 Analytics ignores events that are flagged as invalid or sandbox. 샌드박스 환경에서는 이벤트가 무시된다고 적힌것 같은데 왜 되는지 모르겠지만... stackoverflow에 비슷한 고민을 가진 사람의 질문을 찾을 수 있었다!
다양한 환경 지원 문서를 참고해서 xcode에서 target을 분리해 각각 다른 firebase 프로젝트를 붙여서 해결해 주었다.
A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. Projects can contain one or more targets, each of which produces one product.
target은 하나의 product로 해당 제품을 빌드하는 데 필요한 입력(소스 파일 및 해당 소스 파일을 처리하기 위한 지침)을 빌드 시스템에 구성한다.
xcode에서 TARGETS에 있는 target을 Duplicate 시켜준다.


target의 이름을 바꾸기 위해 Manage Schemes에 들어가서 이름을 바꿔준다.


target을 만들면 자동으로 info.plist도 만들어 질텐데 이것또한 이름을 바꿔주고, 생성한 target의 Build Settings -> Packaging에서 본인이 변경한 이름으로 변경해 준다.
Apple 프로젝트에 Firebase 추가는 여기를 참고

GoogleService-Info.plist를 다운받아서 폴더를 나눠 넣어 주었다.
추가한 target의 bundleId값을 변경하면 인앱결제 상품을 가져올때 오류가 생긴다. bundleId값은 변경하지 않기..
참고
https://dongminyoon.tistory.com/41
https://vandijk.tistory.com/15