expo 로컬 인증서로 빌드해서 사용하기

Updated on

https://docs.expo.dev/app-signing/local-credentials/

expo 로 앱을 빌드할때, 로컬 인증서를 사용하고 싶을때가 있다.

이때 credentials.json 파일을 만들어서 하는 것인데.

문제는

Remember to add credentials.json and all of your credentials to .gitignore so you don't accidentally commit them to the repository and potentially leak your secrets.

라고 설명하고 있다.

왜냐면…

copyTemplateFiles.js

/**
 * Return true if the given platforms all have an internal `.gitignore` file.
 *
 * @param projectRoot
 * @param platforms
 */ function hasAllPlatformSpecificGitIgnores(projectRoot, platforms) {
    return platforms.reduce((p, platform)=>p && _fs().default.existsSync(_path().default.join(projectRoot, platform, ".gitignore")), true);
}

바로…

/tmp/root/eas-build-local-nodejs/f4e3e8cd-db17-4249-87f4-439842389153/build

해당 tmp 폴더로 프로젝트 파일들을 복사하는데… .gitignore 파일들은 복사가 안된다는거다…

그래서 이 문제를 해결하기 위해서는

.easignore 파일을 생성해야한다.

.idea
/android
/ios
expo-env.d.ts
!credentials.json
keystores

이렇게 !credentials.json 라는 꼼수를 통해서 해결해야만 했다.

그리고 마지막으로 eas.json 에서 credentialsSource 값을 local 로 변경해줘야 한다.

{
  "cli": {
    "version": ">= 15.0.13",
    "appVersionSource": "remote"
  },
  "build": {
    "local": {
      "env": {
        "EXPO_USE_FAST_RESOLVER": "true"
      },
      "credentialsSource": "local"
    },
    "development": {
      "extends": "local",
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "extends": "local",
      "distribution": "internal"
    },
    "production": {
      "extends": "local",
      "autoIncrement": true
    }
  },
  "submit": {
    "production": {}
  }
}

이렇게하면, eas build --platform android --local 로컬 빌드할때 인증서를 local 기반으로 빌드하게 된다.