> For the complete documentation index, see [llms.txt](https://docs.proudnet.com/proudnet.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.proudnet.com/proudnet.cn/proudnet/2.setting/mac-xcode.md).

# Mac Xcode

> ProudNet iOS 版本
>
> * 開發語言: C/C++
> * Library 和 Sample: 從 XCode8 版本構建

***

## 1.  前期工作

以下是如何將 ProudNet 程式庫包含在您的 XCode 專案中。

1-1. 將以下文件複製到您的 Mac。

<figure><img src="/files/o90nLTy8e0g0do6iLzFO" alt=""><figcaption><p>複製的檔案和路徑</p></figcaption></figure>

> * ProudNet\Sample\Chat\ChatCommon
> * ProudNet\Sample\Chat\ChatIOS
> * ProudNet\lib\IOS\LLVM(或者 GNU)
> * ProudNetProudNet\utill\PIDL.exe

1-2. 安裝適用於 Mac 的 Mono。

{% hint style="success" %}
**參考**

[**安裝**](https://www.mono-project.com/docs/getting-started/install/mac/) [**Mono** ](https://www.mono-project.com/docs/getting-started/install/mac/)
{% endhint %}

1-3.  開啟 <mark style="color:orange;">Sample\ChatIOS</mark> 中的 <mark style="color:orange;">ChatIOS.xcodeproj</mark>。

1-4.  將 <mark style="color:orange;">Include.xcodeproj</mark> 加入專案。

<figure><img src="/files/hGNbUJ0j8N0ROsjMbccL" alt=""><figcaption></figcaption></figure>

1-5. 修改<mark style="color:orange;">BuildPhases</mark>的Run Script內容。

1-6. 在 <mark style="color:orange;">Build Settings > Other Linker Flags</mark> 中修改 Debug 和 Relese。

<figure><img src="/files/ihdgG6t4mMpr50DmzyZs" alt=""><figcaption></figcaption></figure>

變更為 <mark style="color:orange;">libProudNetClient.a</mark> 實際所在的路徑，並在 LLVM 和 GNU 之間進行選擇。 如果目錄結構如上，內容將與螢幕截圖中的內容相同。

1-7. 為了檢查，建置ChatIOS後，您可以在Windows上執行ChatServer來檢查ChatIOS是否已連線。

{% hint style="danger" %}
**Xcode中使用ProudNet的注意事項**\
※ 新增<mark style="color:orange;">libiconv.dylib</mark>，Xcode預設提供的庫。\
※ 由於它不能在m檔中使用，因此必須將副檔名更改為mm檔。\
※ 請將<mark style="color:orange;">#include \<new></mark> 新增至所有mm檔案。 在Xcode中，STL不能在頭檔中聲明。
{% endhint %}

## 2. 解決故障

### - 新增 ProudNet 程式庫時出現連結錯誤

如果新增 ProudNet Library 時出現連結錯誤，請新增以下選項。

<figure><img src="/files/l7UHktcPv8QZ7VuMEDKc" alt=""><figcaption></figcaption></figure>

### -  使用 <mark style="color:orange;">-all\_load -Objc</mark> 選項時與重複符號相關的連結錯誤

如果使用 <mark style="color:orange;">-all\_load -Objc</mark> 選項時發生 <mark style="color:orange;">COCOs2d-x</mark>（與重複符號相關的連結錯誤），請在<mark style="color:orange;">Other Linker Flags</mark>中使用 <mark style="color:orange;">-force\_load</mark> 而不是 <mark style="color:orange;">-all\_load -Objc</mark>。

<figure><img src="/files/caxS0lo0F8Ib5HJcVMeI" alt=""><figcaption><p>使用 -force_load 選項的範例</p></figcaption></figure>

若要符合路徑，請調整 <mark style="color:orange;">PIDL.exe</mark> 的路徑。\
如果目錄結構如上，則將其變更為 <mark style="color:orange;">mono ../../util/PIDL.exe ../ChatCommon/\* -outdir ./ChatIOS/</mark>。

***

## :arrow\_left: [<mark style="color:blue;">返回</mark>](https://docs.proudnet.com/proudnet.cn/proudnet/2.setting/pages/YF7Z3CPCxDI0T1hoMsHR#2.-pidl)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.proudnet.com/proudnet.cn/proudnet/2.setting/mac-xcode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
