chore: add IDE Dart library generator - #18
Merged
Conversation
Android Studio에서 lib/main.dart를 비롯한 모든 파일의 import가 빨간 줄로 뜨는 문제가 있었다. 원인은 .idea/libraries/ 디렉터리가 통째로 사라진 것. .idea/TechPicks.iml은 Dart SDK, Dart Packages, Flutter Plugins 세 라이브러리를 참조하는데 정의 파일이 없으니 전부 미해결로 남았다. 원래 Dart·Flutter 플러그인이 자동 생성하는 파일이지만, 손상되거나 브랜치를 옮겨 다니는 사이 사라지면 IDE가 스스로 복구하지 못하는 경우가 있다. 이 스크립트가 세 파일을 다시 만든다. - Dart_SDK.xml: flutter 실행 파일 위치에서 번들 SDK 경로를 역산해 등록 - Dart_Packages.xml: .dart_tool/package_config.json 이 유일한 근거 - Flutter_Plugins.xml: .flutter-plugins-dependencies 의 네이티브 플러그인 package: 임포트 없이 dart:io 와 dart:convert 만 쓰므로 패키지 해석이 깨진 상태에서도 `dart tool/gen_idea_libs.dart` 로 실행된다. 정작 고쳐야 할 상황이 그 상황이라서 그렇게 만들었다. .idea/ 자체는 gitignore 대상이라 스크립트만 커밋된다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Android Studio에서
lib/main.dart를 포함한 모든 파일의 import가 빨간 줄로 떴다. 처음엔 분석 서버 캐시 문제로 보고 재시작을 안내했는데 아니었다.실제 원인은
.idea/libraries/디렉터리가 통째로 없어진 것이었다..idea/TechPicks.iml은Dart SDK,Dart Packages,Flutter Plugins세 라이브러리를 참조하는데 정의 파일이 하나도 없으니 전부 미해결로 남았다. 모듈 콘텐츠 루트가.idea/자신을 가리키던 문제까지 겹쳐 있었다.이 스크립트가 세 파일을 다시 만든다.
Dart_SDK.xml—which flutter로 번들 SDK 경로를 역산해 공개 라이브러리만 등록한다. 밑줄로 시작하는 내부 디렉터리와dev_compiler는 뺀다.Dart_Packages.xml—.dart_tool/package_config.json이 유일한 근거다. 실제로 존재하는 디렉터리만 넣는다.Flutter_Plugins.xml—.flutter-plugins-dependencies에서 네이티브 플러그인 경로를 모은다.package:임포트 없이dart:io와dart:convert만 쓴다. 패키지 해석이 깨진 상태에서도dart tool/gen_idea_libs.dart로 돌아가야 하는데, 정작 이걸 쓸 상황이 바로 그 상황이라서다.로컬 확인 결과 SDK 하나, 패키지 156개, 네이티브 플러그인 62개가 등록됐고 XML 유효성도 통과했다.
.idea/자체는 gitignore 대상이라 스크립트만 커밋되고 결과물은 각자 로컬에 남는다. 실행 전flutter pub get으로package_config.json이 현재 브랜치 pubspec과 맞는지 확인해야 하고, 실행 후엔 IDE를 완전히 닫았다 열어야 한다. 열려 있으면 종료할 때 IntelliJ가.idea를 덮어쓴다.