Skip to content

revfactory/BluetoothChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

🔵 Bluetooth 오프라인 채팅 앱 (iOS)

인터넷 연결 없이 Bluetooth/Wi-Fi를 통해 근처 기기와 채팅할 수 있는 iOS 앱입니다.

📱 기능

  • ✅ 오프라인 P2P 채팅
  • ✅ Bluetooth 및 Wi-Fi Direct 지원
  • ✅ 자동 기기 검색
  • ✅ 다중 사용자 동시 연결 (최대 8명)
  • ✅ 암호화된 통신 (AES-256)
  • ✅ macOS 앱과 크로스 플랫폼 통신

🛠 Xcode 프로젝트 설정

1. 새 프로젝트 생성

  1. Xcode → File → New → Project
  2. iOS → App 선택
  3. 설정:
    • Product Name: BluetoothChat
    • Interface: SwiftUI
    • Language: Swift

2. 소스 파일 추가

BluetoothChat/
├── BluetoothChatApp.swift  (기존 파일 교체)
├── ContentView.swift       (기존 파일 교체)
├── ChatManager.swift       (새로 추가)
└── Message.swift           (새로 추가)

3. Info.plist 설정 (⚠️ 중요!)

TARGETS → BluetoothChat → Info 탭에서 다음 키 추가:

<key>NSLocalNetworkUsageDescription</key>
<string>주변 기기와 채팅하기 위해 로컬 네트워크 접근이 필요합니다.</string>

<key>NSBonjourServices</key>
<array>
    <string>_bt-chat-app._tcp</string>
    <string>_bt-chat-app._udp</string>
</array>

<key>NSBluetoothAlwaysUsageDescription</key>
<string>주변 기기와 Bluetooth로 통신하기 위해 필요합니다.</string>

<key>NSBluetoothPeripheralUsageDescription</key>
<string>주변 기기와 Bluetooth로 통신하기 위해 필요합니다.</string>

4. Signing & Capabilities

  1. TARGETS → BluetoothChat → Signing & Capabilities
  2. Team에 개발자 계정 선택
  3. Bundle Identifier 설정 (예: com.yourname.BluetoothChat)

📲 테스트 방법

실제 기기 2대 이상 권장 (시뮬레이터는 제한적)

  1. 두 iPhone에 앱 설치
  2. 양쪽에서 앱 실행 → 닉네임 입력 → "시작하기"
  3. 우측 상단 👥 버튼으로 주변 기기 확인
  4. 발견된 기기 탭하여 연결
  5. 채팅 시작!

🔧 트러블슈팅

기기를 찾을 수 없음

  • Bluetooth ON 확인
  • Wi-Fi ON 확인 (같은 네트워크 불필요)
  • 30m 이내 위치
  • "기기 검색" & "내 기기 공개" 활성화

권한 요청이 안 나타남

  • 앱 삭제 후 재설치

📁 프로젝트 구조

BluetoothChat/
├── BluetoothChatApp.swift   # @main 앱 진입점
├── Message.swift            # 메시지 데이터 모델
├── ChatManager.swift        # @Observable + Multipeer Connectivity
└── ContentView.swift        # SwiftUI 뷰
    ├── SetupView            # 닉네임 설정
    ├── ChatView             # 메인 채팅
    ├── MessageBubble        # 말풍선
    ├── MessageInputView     # 입력창
    └── PeerListView         # 기기 관리

🆕 Xcode 26 / Swift 6 변경사항

이 버전은 최신 API를 사용합니다:

변경 전 변경 후
@StateObject @State (with @Observable)
@ObservableObject @Observable macro
@Published 일반 프로퍼티
onChange(of:) { newValue in } onChange(of:) { }
.foregroundColor() .foregroundStyle()
.cornerRadius() .clipShape(RoundedRectangle())

📋 시스템 요구사항

  • iOS 17.0 이상
  • Xcode 26.0 이상
  • Swift 6.0 이상

🔗 macOS 앱과 연동

동일한 serviceType: "bt-chat-app"을 사용하므로 macOS 앱과 자동으로 연결됩니다!


Made with ❤️ using SwiftUI & Multipeer Connectivity

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages