# 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
```