> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# iOS and macOS getting started

> Xcode 프레임워크 링크, 마이크 권한, 백그라운드 오디오 구성을 포함한 PlayFab Party의 iOS 및 macOS 통합 요구 사항입니다.

이 문서는 iOS 또는 macOS 애플리케이션에 PlayFab Party를 통합하는 데 필요한 기본 사전 요구 사항과 요구 사항을 나열합니다. 플랫폼별 단계를 완료한 후 [Quickstart for PlayFab Party](/services/playfab/multiplayer/networking/quickstart)를 참조하여 PlayFab Party 시작을 완료하세요.

## 사전 요구 사항

이 자습서를 시작하기 전에 다음 사전 요구 사항이 충족되었는지 확인하세요.

1. [PlayFab 개발자 계정](https://developer.playfab.com)을 만들었습니다.
2. PlayFab 타이틀을 만들었으며, 타이틀이 PlayFab Party에 대해 허용 목록에 추가되었습니다.
3. Xcode 버전 10.2.1 이상이 설치되어 있습니다.
4. [PlayFab Party 플랫폼 리포지토리](https://github.com/PlayFab/PlayFabParty)에 액세스할 수 있습니다.
5. 배포용으로 앱에 서명하는 데 사용할 수 있는 Apple 개발자 계정을 만들었습니다.

참고: 테스트에 XCode 시뮬레이터를 사용할 계획이라면 애플리케이션을 64비트(\$(ARCHS\_STANDARD\_64\_BIT)) 아키텍처를 대상으로 해야 합니다. 32비트 시뮬레이터는 현재 지원되지 않습니다.

## 필요한 라이브러리 및 헤더 파일 포함

### 헤더

* [PlayFab Party 배포 리포지토리](https://github.com/PlayFab/PlayFabParty/releases)에서 다음 헤더 파일들을 포함해야 합니다.

### 프레임워크

* PlayFab Party 배포 패키지 내에서도 찾을 수 있는 다음 프레임워크에 애플리케이션을 링크해야 합니다.
  * iOS: PlayFabParty
  * macOS: PlayFabPartyMac

<Note>
  SSL 라이브러리는 [Open SSL version XXX](https://github.com/openssl/openssl/tree/OpenSSL_1_1_1-stable)로부터 빌드되었습니다. XXX 이상의 OpenSSL 버전을 사용하세요.
</Note>

헤더 포함

[Party 헤더](https://github.com/PlayFab/PlayFabParty/tree/master/include)

위의 lib 파일과 헤더 외에도, 앱에 필요한 PlayFab SDK 및 기타 플랫폼별 종속성에 대한 lib와 헤더도 필요합니다. 자세한 내용은 iOS 샘플의 프로젝트 파일 구성을 참조하세요.

## iOS 또는 macOS에서 PlayFab Party를 작동시키는 단계

핵심 Party 라이브러리는 C++로 작성되었으므로 Objective-C++ 코드에서 직접 액세스할 수 있습니다. 편의를 위해 Party 라이브러리 기능에 액세스하기 위한 간단한 Objective-C++ 래퍼 클래스를 만들었습니다. 상위 수준에서는 네트워크를 생성하고, 네트워크에 연결하고, 네트워크를 통해 메시지를 보내기 위한 Party API 메서드에 액세스할 수 있는 클래스를 원할 것입니다. iOS 데모 앱의 예시로 [SimpleClientClass](https://github.com/PlayFab/PlayFabParty/blob/docs/iOS/PartySample/app/inc/SimpleClient.h)가 나와 있습니다.

```obj-c theme={null}
//
//  SimpleClient.h
//  chatdemo_ios

#import <Foundation/Foundation.h>
#import "ChatEventHandler.h"

@interface SimpleClient : NSObject

@property (nonatomic) id<ChatEventHandler> chatEventHandler;

-(void) initialize;
-(void) setHandler:(id<ChatEventHandler>) messageHandler;
-(void) signInLocalUser;

-(void) createNetwork:(NSString*) networkId;
-(void) joinNetwork:(NSString*) networkId;
-(void) leaveNetwork;

-(void) sendTextAsVoice:(NSString*) text;
-(void) sendTextMessage:(NSString*) text;
-(void) setLanguageCode:(int) languageIndex;
-(NSArray *) getLanguageOptions;
-(int) getDefaultLanguageIndex;

-(NSString*) getSelectedUserName;

-(void) tick;

+(void) globalInitialize;
+(void) globalShutdown;

@end

```

위의 객체 브리지는 [NetworkManager.cpp](https://github.com/PlayFab/PlayFabParty/blob/docs/android/PartySampleNetworkCommon/lib/NetworkManager.cpp)를 호출하는 순수한 C++ 구현 파일에 의해 뒷받침되며, 이 파일은 다시 Party API를 호출합니다.

다음은 다양한 계층을 보여주는 예시 스니펫입니다.

SimpleClient Objective-C 인터페이스는 PlayFab Party를 초기화하는 메서드를 노출합니다.

```obj-c theme={null}
// In SimpleClient.h
-(void) createNetwork:(NSString*) networkId;
```

SimpleClient 구현에는 네트워크 매니저를 통해 Party API를 호출하는 C++ 객체에 대한 참조도 포함되어 있습니다.

```obj-c theme={null}
// In SimpleClient.mm

@interface SimpleClient ()

@end

@implementation SimpleClient

SimpleClientImpl* m_impl;
```

SimpleClientImpl은 아래 코드 스니펫에 표시된 것처럼 Party 네트워크 생성이라는 무거운 작업을 수행하는 C++ 클래스입니다.

```cpp theme={null}
void
SimpleClientImpl::CreateNetwork(
    std::string &networkId
    )
{
    if (g_isRunning && g_initializeCompleted)
    {
        Managers::Get<NetworkManager>()->Initialize(c_pfTitleId);
        m_messageHandler->OnStartLoading();
        Managers::Get<NetworkManager>()->CreateAndConnectToNetwork(
            networkId.c_str(),
            [this, networkId](std::string message)
            {
                this->SendSysLogToUI("create network: %s", message.c_str());
                Managers::Get<PlayFabManager>()->SetDescriptor(
                    networkId,
                    message, 
                    [this, message](void)
                    {
                        m_messageHandler->OnEndLoading();
                        this->SendSysLogToUI("set network descriptor %s", "successed");
                        std::string l_message = message;
                        m_messageHandler->OnNetworkCreated(l_message);
                    });
            },
            [this](PartyError error)
            {
                m_messageHandler->OnEndLoading();
                this->SendSysLogToUI("create network failed: %s", GetErrorMessage(error));
            });
    }
}
```

위의 코드 스니펫에서 SimpleClient는 NetworkManager::CreateAndConnectToNetwork()를 호출하며, 이 함수는 다시 [Party.h](https://github.com/PlayFab/PlayFabParty/blob/docs/include/Party.h)에 노출된 원시 Party API를 호출합니다.

```cpp theme={null}
void 
NetworkManager::CreateAndConnectToNetwork(
    const char *networkId, 
    std::function<void(std::string)> callback, 
    std::function<void(PartyError)> errorCallback
    )
{
    DEBUGLOG("NetworkManager::CreateAndConnectToNetwork()\n");

    // Set the maximum number of devices allowed in a network to 16 devices
    constexpr uint8_t c_maxSampleNetworkDeviceCount = 16;
    static_assert(c_maxSampleNetworkDeviceCount <= c_maxNetworkConfigurationMaxDeviceCount, "Must be less than or equal to c_maxNetworkConfigurationMaxDeviceCount.");

    // Initialize network configuration for Party Network.
    PartyNetworkConfiguration cfg = {};
    cfg.maxDeviceCount = c_maxSampleNetworkDeviceCount;
    cfg.maxDevicesPerUserCount = 1;
    cfg.maxEndpointsPerDeviceCount = 1;
    cfg.maxUserCount = c_maxSampleNetworkDeviceCount;
    cfg.maxUsersPerDeviceCount = 1;

    //Get the uid from the local chat control
    PartyString uid = nullptr;
    PartyError err = m_localUser->GetEntityId(&uid);

    if (PARTY_FAILED(err))
    {
        DEBUGLOG("GetUserIdentifier failed: %s\n", GetErrorMessage(err));
        errorCallback(err);
        return;
    }

    // Setup the network invitation configuration to use the network id as an invitation id and allow anyone to join.
    PartyInvitationConfiguration invitationConfiguration{
        networkId,                                  // invitation identifier
        PartyInvitationRevocability::Anyone,        // revokability
        0,                                          // authorized user count
        nullptr                                     // authorized user list
    };

    // Initialize an empty network descriptor to hold the result of the following call.
    PartyNetworkDescriptor networkDescriptor = {};

    // Create a new network descriptor
    err = PartyManager::GetSingleton().CreateNewNetwork(
        m_localUser,                                // Local User
        &cfg,                                       // Network Config
        0,                                          // Region List Count
        nullptr,                                    // Region List
        &invitationConfiguration,                   // Invitation configuration
        nullptr,                                    // Async Identifier
        &networkDescriptor,                         // OUT network descriptor
        nullptr                                     // applied initialinvitationidentifier.
    );

    if (PARTY_FAILED(err))
    {
        DEBUGLOG("CreateNewNetwork failed: %s\n", GetErrorMessage(err));
        errorCallback(err);
        return;
    }

    // Connect to the new network
    if (InternalConnectToNetwork(networkDescriptor, networkId, errorCallback))
    {
        m_state = NetworkManagerState::WaitingForNetwork;
        m_onnetworkcreated = callback;
        m_onnetworkcreatederror = errorCallback;
        m_onnetworkconnectedError = errorCallback;
    }
}
```

이와 유사한 방식으로 SimpleClient Objective-C 인터페이스의 각 메서드는 `SimpleClientImpl` 및 `NetworkManager`를 통해 Party API에 매핑됩니다.

## 참고

PlayFab Party가 음성 채팅에 사용될 것으로 예상되는 경우 애플리케이션에 마이크 액세스 권한이 부여되어야 합니다. 이를 위해 애플리케이션의 Info.plist 파일에 다음 속성이 추가되었는지 확인하세요.

```
<key>NSMicrophoneUsageDescription</key>
<string>The application requires access to the microphone for voice chat.</string>
```

## 다음 단계

Party 라이브러리를 iOS 또는 macOS 애플리케이션에 통합하기 위한 플랫폼별 단계를 완료한 후에는 [Quickstart for PlayFab Party](/services/playfab/multiplayer/networking/quickstart)를 참조하여 PlayFab Party 시작을 완료하세요.


## Related topics

- [PlayFab Services SDK](/ko/services/playfab/sdks/c/index.md)
- [SDK 수명 주기](/ko/services/playfab/sdks/c/lifecycle.md)
- [NodeJS 빠른 시작](/ko/services/playfab/sdks/nodejs/quickstart.md)
- [Linux getting started](/ko/services/playfab/multiplayer/networking/linux-specific-requirements.md)
- [Android getting started](/ko/services/playfab/multiplayer/networking/android-specific-requirements.md)
