# Release Problems

Vấn đề khi build release dự án Unity

# Build iOS thành công nhưng không có file .xcworkspace

#### Vấn đề

- Khi tích hợp đầy đủ các SDK, cocapods, build iOS trên Unity báo success nhưng không có file .xcworkspace để archive

#### Nguyên nhân

- Do lỗi các mạng quảng cáo không tương thích với phiên bản iOS tối thiểu
- Do các mạng quả cáo không tương thích với Mediation SDK
- ...

#### Giải pháp

1. <span style="white-space: pre-wrap;">Sử dụng terminal cd tới folder build iOS (VD: </span>`<span class="editor-theme-code">cd /Users/admin/Unity/Gang2022/Builds/558/iOS</span>`)
2. <span style="white-space: pre-wrap;">Chạy lệnh </span>`<span class="editor-theme-code">pod install</span>`<span style="white-space: pre-wrap;"> để build lại file .xcworkspace</span>
3. Đọc, kiểm tra lỗi và tiếp tục xử lý
    - <span style="white-space: pre-wrap;">Lỗi </span>`<span class="editor-theme-code">AppLovinMediationGoogleAdapter</span>`<span style="white-space: pre-wrap;"> không tương thích với </span>`<span class="editor-theme-code">Google-Mobile-Ads-SDK</span>`<span style="white-space: pre-wrap;"> =&gt; </span>****Sửa phiên bản** `<strong class="editor-theme-bold editor-theme-code">Google-Mobile-Ads-SDK</strong>` **trong file** `<strong class="editor-theme-bold editor-theme-code">Podfile</strong>`**
    
    ```bash
    [!] CocoaPods could not find compatible versions for pod "Google-Mobile-Ads-SDK":
      In Podfile:
        AppLovinMediationGoogleAdapter (= 12.5.0.0) was resolved to 12.5.0.0, which depends on
          Google-Mobile-Ads-SDK (= 12.5.0)
    
        Google-Mobile-Ads-SDK (~> 11.13.0)
    
    Specs satisfying the `Google-Mobile-Ads-SDK (~> 11.13.0), Google-Mobile-Ads-SDK (= 12.5.0)` dependency were found, but they required a higher minimum deployment target.
    ```
    
    
    - <span style="white-space: pre-wrap;">Lỗi </span>`<span class="editor-theme-code">AppLovinMediationMyTargetAdapter</span>`<span style="white-space: pre-wrap;"> yêu cầu </span>****phiên bản iOS tối thiểu****<span style="white-space: pre-wrap;"> cao hơn =&gt; </span>****trong** `<strong class="editor-theme-bold editor-theme-code">Podfile</strong>` **sửa dòng** `<strong class="editor-theme-bold editor-theme-code">platform :ios, 'iOS_version'</strong>`**<span style="white-space: pre-wrap;"> hoặc</span> ****thay đổi** `<strong class="editor-theme-bold editor-theme-code">Target minimum iOS Version</strong>` **trong Player Settings****
    
    ```bash
    [!] CocoaPods could not find compatible versions for pod "AppLovinMediationMyTargetAdapter":
    
      In Podfile:
        AppLovinMediationMyTargetAdapter (= 5.30.0.0)
    
    
    Specs satisfying the `AppLovinMediationMyTargetAdapter (= 5.30.0.0)` dependency were found, but they required a higher minimum deployment target.
    ```
4. Nếu không còn lỗi và đã có file .xcworkspace thì có thể thực hiện archive trên file .xcworkspace này

#### Lưu ý

- <span style="white-space: pre-wrap;">Dùng lệnh </span>`<span class="editor-theme-code">pod install --repo-update</span>`<span style="white-space: pre-wrap;"> để install đồng thời update tất cả các pod trong </span>`<span class="editor-theme-code">Podfile</span>`
- Dọn dẹp cache

```bash
pod cache clean --all
rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -f Podfile.lock
```

# Tích hợp FacebookSDK - Open SSL not found

#### Vấn đề

[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2025-07/scaled-1680-/8animage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2025-07/8animage.png)

[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2025-07/scaled-1680-/zVwimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2025-07/zVwimage.png)

#### Nguyên nhân

Do chưa cài đặt môi trường SSL và Java

#### Giải pháp

##### OpenSSL not found

1. Download and install OpenSSL.  
    [Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions](http://slproweb.com/products/Win32OpenSSL.html)  
    Win32 OpenSSL v#.#.# (not Light)  
    OR Win64 OpenSSL v#.#.# (not Light)
2. Add the OpenSSL directory to your path.  
    <span style="white-space: pre-wrap;">Go to: </span>`<span class="editor-theme-code">Control Panel</span>`<span style="white-space: pre-wrap;"> → </span>`<span class="editor-theme-code">System</span>`<span style="white-space: pre-wrap;"> → </span>`<span class="editor-theme-code">Advanced system settings</span>`<span style="white-space: pre-wrap;"> → </span>`<span class="editor-theme-code">Environment Variables</span>`  
    <span style="white-space: pre-wrap;">Select the Variable </span>`<span class="editor-theme-code">Path</span>`<span style="white-space: pre-wrap;"> in the “System variables” window and click Edit.</span>
3. <span style="white-space: pre-wrap;">Add the path to your OpenSSL bin folder to the end of the “Variable value” text. e.g. I added </span>`<span class="editor-theme-code">;C:\Program Files\OpenSSL-Win64\bin</span>`<span style="white-space: pre-wrap;"> to the end of the value text.</span>  
    <span style="white-space: pre-wrap;">→ Take note, do not forget to add semi-colon </span>`<span class="editor-theme-code">;</span>`<span style="white-space: pre-wrap;"> before the </span>`<span class="editor-theme-code">C:/</span>`
4. Restart computer.

##### Keytool not found

1. 

# Lỗi Undefined symbol khi build iOS

### <span style="white-space: pre-wrap;">Vấn đề </span>

Khi build iOS vẫn thành công. Có file .xcworkspace nhưng khi Archive lại gặp rất nhiều lỗi Undefined symbol như hình dưới.

[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/scaled-1680-/image.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/image.png)

### Nguyên nhân

Do các thư viện GoogleMobileAds, YandexMobileAds.... chưa được nhúng vào project.

### Giải pháp

#### Thêm thủ công vào .xcworkspace

<span style="white-space: pre-wrap;">Trong của sổ làm việc của XCode chọn project Unity-iPhone &gt; Targets Unity-iPhone &gt; General &gt; </span>**Frameworks, Libraries, and Embedded Content**

Nhấn + để thêm các thư viện còn thiếu. Ở trường hợp trên là GoogleMobileAds.xcframework và YandexMobileAds.xcframework.

[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/scaled-1680-/IMvimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/IMvimage.png)

#### Cách khác (không biết gọi là gì =)))))

Với XCode 26.5 khi thêm thủ công file .xcframework có thể sẽ gặp lỗi sau  
[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/scaled-1680-/jMmimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/jMmimage.png)

Lỗi này xảy ra với file YandexMobileAds.xcframework được tải trên internet.

<span style="white-space: pre-wrap;">Với trường hợp này chúng ta sẽ không thêm thủ công GoogleMobileAds.xcframework và YandexMobileAds.xcframework nữa. Giữ </span>**Frameworks, Libraries, and Embedded Content**<span style="white-space: pre-wrap;"> như ban đầu.</span>

<span style="white-space: pre-wrap;">Trên thanh menu bên trái của Xcode, mở folder Project &gt; Unity-iPhone &gt; Frameworks. </span>  
\- Nếu bạn thấy GoogleMobileAds và YandexMobileAds màu đỏ như hình thì chuột phải &gt; Delete &gt; Remove Reference  
\- Nếu không thì thôi :)))))  
[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/scaled-1680-/gvcimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/gvcimage.png)

Giờ sang phần Target &gt; Build Settings &gt; tìm "Framework Search Paths" &gt; Nháy đúp vào &lt;Multiple value&gt; và thêm 2 dòng lệnh sau  
<span style="white-space: pre-wrap;">- </span>`<span class="editor-theme-code">$(SRCROOT)/Pods/YandexMobileAds</span>`  
<span style="white-space: pre-wrap;">- </span>`<span class="editor-theme-code">$(SRCROOT)/Pods/Google-Mobile-Ads-SDK</span>`  
Đây là biến môi trường tự động trỏ đúng vào thư mục project của bạn.  
<span style="white-space: pre-wrap;">Nhìn sang bên cạnh nếu thấy </span>**non-recursive** thì nhớ chuyển nó thành **recursive.** Để báo cho XCode biết cần phải đi tìm file .xcframework trong các thư mục con.  
[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/scaled-1680-/Ky1image.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/Ky1image.png)

Tiếp tục, vẫn ở Build Settings, tìm "Other Linker Flags", nháy đúp vào và thêm lần lượt 4 dòng sau vào cuối.  
`<span class="editor-theme-code">-framework</span>`  
`<span class="editor-theme-code">YandexMobileAds</span>`  
`<span class="editor-theme-code">-framework</span>`  
`<span class="editor-theme-code">GoogleMobileAds</span>`  
[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/scaled-1680-/XBcimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/XBcimage.png)

Xong rồi, giờ build thôi :&gt;  
À quên, nhớ Clean Build Folder trước khi build nhé.

### Lưu ý

<span style="white-space: pre-wrap;">Framework được thêm vào nên có màu xanh (hoặc vàng) nhạt. Nếu màu đậm khả năng cao sẽ gặp lỗi </span>

[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/scaled-1680-/9gTimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/9gTimage.png)

<span style="white-space: pre-wrap;">Nếu gặp lỗi như trên có thể chọn </span>**framework từ một dự án khác**<span style="white-space: pre-wrap;"> đã Archive thành công để thêm vào.</span>

Nếu không có dự án cũ thì có thể tìm và tải file .xcframework trừ internet.

- <span style="white-space: pre-wrap;">Với GoogleMobileAds.xcframework có thể tham khảo </span>[link này](https://developers.google.com/admob/ios/download?hl=vi)<span style="white-space: pre-wrap;"> hoặc search google với từ khóa </span>**GoogleMobileAds.xcframework.**
- <span style="white-space: pre-wrap;">Với YandexMobileAds.xcframework có thể tham khảo </span>
    - [Link này](https://github.com/CocoaPods/Specs/tree/master/Specs/a/c/5/YandexMobileAds)<span style="white-space: pre-wrap;"> &gt; tìm phiên bản đang sử dụng &gt; tìm field source.http &gt; sử dụng link này để tải file zip có </span>**YandexMobileAds.xcframework.**  
        [![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/scaled-1680-/5dlimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2026-05/5dlimage.png)
    - <span style="white-space: pre-wrap;">search google với từ khóa </span>**YandexMobileAds.xcframework.**

# Tích hợp FacebookSDK - Lỗi khi Archive trong XCode

### Vấn đề

Dự án Unity có tích hợp FacebookSDK. Build iOS thành công nhưng khi Archive trong XCode lại gặp lỗi như hình.

[![image.png](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/scaled-1680-/NJFimage.png)](https://knowledge.thanhdv.com/uploads/images/gallery/2025-12/NJFimage.png)

### Nguyên nhân

Do xung đột phiên bản FacebookSDK trong Unity và trong XCode

Hoặc, do lỗi của phiên bản FacebookSDK

### Giải pháp

Kiểm tra xem phiên bản FacebookSDK trong Unity và trong Podfile (cùng thư mục với file .xcworkspace) có trùng nhau chưa. Nếu chưa hãy update lại FacebookSDK trong Unity rồi build lại.

Nếu đã trùng nhau nhưng vẫn gặp lỗi. Vấn đề khẳ năng cao là do phiên bản FacebookSDK. Tại đây có 2 cách giải quyết:

- <span style="white-space: pre-wrap;">Hạ xuống phiên bản FacebookSDK ổn định hơn. (Trong trường hợp này là </span>**17.0.1**, phiên bản gặp lỗi là **18.0.0**)
- Nếu tính năng bị lỗi là một tính năng mà bạn không sử dụng đến hãy xóa hoặc comment dòng code lỗi đó.
    - Tìm đến dòng code báo lỗi và comment lại trong XCode (vẫn phải thực hiện lại trong các lần build sau, trừ khi update FacebookSDK không gặp lỗi)
    - Trong Unity, FacebookSDK &gt; SDK &gt; Editor &gt; iOS &gt; Swift &gt; Comment các dòng code báo lỗi tương tự như trên (với cách này thì chỉ cần làm một lần)