Conversation
📝 WalkthroughWalkthroughXCBuildConfiguration에서 Config.xcconfig 파일 참조를 추가하고, Info.plist에 BASE_URL 값을 정의한 후, 이를 Environment 유틸리티를 통해 런타임에 접근하도록 구현했습니다. EndPoint에서 하드코딩된 빈 Base URL을 Environment.baseURL로 교체했습니다. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@Cherrish-iOS/Cherrish-iOS.xcodeproj/project.pbxproj`:
- Around line 152-153: The project currently points both Debug and Release build
configurations to the same Core/Config.xcconfig via
baseConfigurationReferenceRelativePath and baseConfigurationReferenceAnchor;
split this by creating Config-Debug.xcconfig and Config-Release.xcconfig (with
environment-specific BASE_URL values) and update the project.pbxproj entries
that use baseConfigurationReferenceRelativePath = Core/Config.xcconfig (and the
matching baseConfigurationReferenceAnchor occurrences) so that the Debug
configuration references Config-Debug.xcconfig and the Release configuration
references Config-Release.xcconfig; repeat the same change for the other
identical baseConfigurationReference entries in the file.
In `@Cherrish-iOS/Cherrish-iOS/Core/BaseURL.swift`:
- Around line 10-12: The Environment.baseURL currently force-casts
Bundle.main.infoDictionary?["BASE_URL"] as! String which can crash if the key is
missing or not a String; update Environment.baseURL to safely unwrap and
validate Bundle.main.infoDictionary?["BASE_URL"] (e.g., use guard let base = ...
as? String else { fatalError("Missing or invalid BASE_URL in Info.plist") } or
return a sensible default) so the lookup for "BASE_URL" fails with a clear error
message instead of a runtime cast exception.
In `@Cherrish-iOS/Cherrish-iOS/Info.plist`:
- Around line 5-6: Info.plist references the build variable $(BASE_URL) which
must be defined in Cherrish-iOS/Core/Config.xcconfig; create that file locally
(or add a checked-in template Config.xcconfig.example) and define BASE_URL (e.g.
BASE_URL = https://api.example.com), ensure the Xcode project’s
baseConfigurationReferenceRelativePath continues to point to
Core/Config.xcconfig, and update README with instructions to copy
Config.xcconfig from the example and set the local value so the project can
build for all developers.
| baseConfigurationReferenceAnchor = 51B5D31A2F0514390090B8B4 /* Cherrish-iOS */; | ||
| baseConfigurationReferenceRelativePath = Core/Config.xcconfig; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Debug와 Release에 동일한 Config 파일 사용 검토
현재 Debug와 Release 모두 동일한 Core/Config.xcconfig를 참조합니다. 개발 환경과 프로덕션 환경에서 다른 BASE_URL이 필요한 경우, 환경별로 분리된 설정 파일 사용을 권장합니다.
예시:
Config-Debug.xcconfig→ 개발 서버 URLConfig-Release.xcconfig→ 프로덕션 서버 URL
Also applies to: 217-218
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS.xcodeproj/project.pbxproj` around lines 152 - 153,
The project currently points both Debug and Release build configurations to the
same Core/Config.xcconfig via baseConfigurationReferenceRelativePath and
baseConfigurationReferenceAnchor; split this by creating Config-Debug.xcconfig
and Config-Release.xcconfig (with environment-specific BASE_URL values) and
update the project.pbxproj entries that use
baseConfigurationReferenceRelativePath = Core/Config.xcconfig (and the matching
baseConfigurationReferenceAnchor occurrences) so that the Debug configuration
references Config-Debug.xcconfig and the Release configuration references
Config-Release.xcconfig; repeat the same change for the other identical
baseConfigurationReference entries in the file.
| enum Environment { | ||
| static let baseURL: String = Bundle.main.infoDictionary?["BASE_URL"] as! String | ||
| } |
There was a problem hiding this comment.
Force cast 사용으로 인한 런타임 크래시 위험
as! String 강제 캐스팅은 BASE_URL이 누락되거나 타입이 맞지 않을 경우 앱 크래시를 유발합니다. 안전한 옵셔널 바인딩 또는 명시적 에러 처리를 권장합니다.
🔧 안전한 구현 제안
enum Environment {
- static let baseURL: String = Bundle.main.infoDictionary?["BASE_URL"] as! String
+ static let baseURL: String = {
+ guard let url = Bundle.main.infoDictionary?["BASE_URL"] as? String else {
+ fatalError("BASE_URL이 Info.plist에 정의되지 않았습니다. Config.xcconfig 설정을 확인하세요.")
+ }
+ return url
+ }()
}이 방식은 크래시 시 명확한 에러 메시지를 제공하여 디버깅을 용이하게 합니다.
🧰 Tools
🪛 SwiftLint (0.57.0)
[Error] 11-11: Force casts should be avoided
(force_cast)
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Core/BaseURL.swift` around lines 10 - 12, The
Environment.baseURL currently force-casts
Bundle.main.infoDictionary?["BASE_URL"] as! String which can crash if the key is
missing or not a String; update Environment.baseURL to safely unwrap and
validate Bundle.main.infoDictionary?["BASE_URL"] (e.g., use guard let base = ...
as? String else { fatalError("Missing or invalid BASE_URL in Info.plist") } or
return a sensible default) so the lookup for "BASE_URL" fails with a clear error
message instead of a runtime cast exception.
| <key>BASE_URL</key> | ||
| <string>$(BASE_URL)</string> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for Config.xcconfig file in the repository
echo "=== Searching for Config.xcconfig ==="
fd -t f "Config\.xcconfig" --exec sh -c 'echo "Found: {}" && cat "{}"' \;
# Also search for any .xcconfig files to get a broader view
echo ""
echo "=== All .xcconfig files in repository ==="
fd -t f "\.xcconfig$"Repository: TEAM-Cherrish/Cherrish-iOS
Length of output: 150
🏁 Script executed:
#!/bin/bash
# Check if .xcconfig files are gitignored
echo "=== Checking .gitignore for .xcconfig patterns ==="
if [ -f ".gitignore" ]; then
cat .gitignore | grep -i "xcconfig" || echo "No .xcconfig patterns found in .gitignore"
else
echo ".gitignore not found"
fi
echo ""
echo "=== Searching for BASE_URL definition in all files ==="
rg "BASE_URL" --type-list | head -5
rg "BASE_URL" -t swift -t plist -t xml 2>/dev/null | head -20
echo ""
echo "=== Checking for README or setup documentation ==="
fd -t f "(README|SETUP|CONFIG)" --exec sh -c 'echo "File: {}" && head -10 "{}"' \; 2>/dev/null | head -50Repository: TEAM-Cherrish/Cherrish-iOS
Length of output: 1142
🏁 Script executed:
#!/bin/bash
# Check for template or example .xcconfig files
echo "=== Searching for .xcconfig templates or examples ==="
fd -i "xcconfig|config" -t f | grep -E "(example|template|sample)" || echo "No template files found"
echo ""
echo "=== Searching all files for BASE_URL reference ==="
rg "BASE_URL" 2>/dev/null | head -20
echo ""
echo "=== Checking Info.plist files ==="
fd "Info\.plist" -t f --exec sh -c 'echo "File: {}" && cat "{}"' \;
echo ""
echo "=== Checking Xcode project structure ==="
fd "\.pbxproj" -t f | head -5Repository: TEAM-Cherrish/Cherrish-iOS
Length of output: 1125
🏁 Script executed:
#!/bin/bash
# Check pbxproj for BASE_URL or build configuration
echo "=== Checking pbxproj for BASE_URL or build settings ==="
rg "BASE_URL|xcconfig" "Cherrish-iOS/Cherrish-iOS.xcodeproj/project.pbxproj" 2>/dev/null | head -20
echo ""
echo "=== Checking for build scripts or setup documentation ==="
fd -t f "(Makefile|\.sh|\.yml|\.yaml)" --exec sh -c 'basename "{}" && head -5 "{}"' \; 2>/dev/null | head -50
echo ""
echo "=== Checking for any .swift files that reference xcconfig ==="
rg "xcconfig|CONFIG" --type swift 2>/dev/null | head -10
echo ""
echo "=== Full README.md to check for setup instructions ==="
cat README.md | head -100Repository: TEAM-Cherrish/Cherrish-iOS
Length of output: 3130
Config.xcconfig 파일 생성 필수
Info.plist에서 참조하는 $(BASE_URL) 변수는 Core/Config.xcconfig 파일에서 정의되어야 합니다. Xcode 프로젝트 설정(pbxproj)에 이 파일이 baseConfigurationReferenceRelativePath로 이미 지정되어 있으나, 파일이 .gitignore에 등록되어 있어 저장소에는 포함되지 않습니다.
각 개발자가 로컬에서 직접 Cherrish-iOS/Core/Config.xcconfig 파일을 생성하고 BASE_URL 값을 정의해야 프로젝트가 정상적으로 빌드됩니다. README에 이에 대한 설정 가이드를 추가하거나, Config.xcconfig.example 템플릿 파일을 제공하는 것을 권장합니다.
🤖 Prompt for AI Agents
In `@Cherrish-iOS/Cherrish-iOS/Info.plist` around lines 5 - 6, Info.plist
references the build variable $(BASE_URL) which must be defined in
Cherrish-iOS/Core/Config.xcconfig; create that file locally (or add a checked-in
template Config.xcconfig.example) and define BASE_URL (e.g. BASE_URL =
https://api.example.com), ensure the Xcode project’s
baseConfigurationReferenceRelativePath continues to point to
Core/Config.xcconfig, and update README with instructions to copy
Config.xcconfig from the example and set the local value so the project can
build for all developers.
sum130
left a comment
There was a problem hiding this comment.
ptsd 극복 추카추~~ thanksTo 영서~~~
Add/#84 Config 추가 및 BASEURL 설정
🔗 연결된 이슈
📄 작업 내용
📚 참고자료
아요 영사자 영서누나의
Config에 숨겨 숨겨