NSLocalNetworkUsageDescription را به Info.plist خود اضافه کنید
اکیداً توصیه میکنیم پیام نشاندادهشده در درخواست شبکه محلی را با افزودن یک رشته مجوز ویژه برنامه در فایل Info.plist برنامه خود برای NSLocalNetworkUsageDescription ، مانند توصیف Cast Discovery و سایر سرویسهای کشف، مانند DIAL، سفارشی کنید.
پس از راه اندازی CocoaPods، راهنمای استفاده از CocoaPods را دنبال کنید تا Podfile خود را ایجاد کنید و پروژه خود را برای استفاده با Google Cast SDK آماده کنید.
در اینجا مثالی از نحوه افزودن google-cast-sdk CocoaPod به Podfile آورده شده است:
use_frameworks!
platform :ios, '14.0'
def target_pods
pod 'google-cast-sdk'
end
target 'CastVideos-objc' do
target_pods
end
target 'CastVideos-swift' do
target_pods
end
برای پروژه خود، باید محدوده ای را برای پادهای خود تعیین کنید تا از تغییرات شکسته غیرمنتظره همانطور که در راهنمای پادفایل توضیح داده شده است جلوگیری کنید.
در این قطعه، نسخه 4.8.3 و نسخه های تا نسخه اصلی بعدی (major.minor.patch) مجاز هستند:
pod 'google-cast-sdk', '~> 4.8.3'
برای مثال، «~> 1.6.7» شامل همه نسخهها از 1.6.7 به بالا است، اما شامل نسخه 2.0.0 نمیشود.
راه اندازی دستی
دستورالعمل های زیر برای افزودن Cast iOS SDK به پروژه خود بدون استفاده از CocoaPods است:
دانلودها
پس از دانلود کتابخانه مناسب زیر، مراحل راه اندازی را دنبال کنید تا چارچوب را به پروژه خود اضافه کنید.
SDK مناسب برای پروژه خود را دانلود و استخراج کنید.
کتابخانه پویا GoogleCastSDK را تنظیم کنید:
xcframework .xcframework خارج شده را به پروژه اصلی خود در ناوبری پروژه Xcode بکشید (اگر دارید به پروژه Pods نیستید). "در صورت نیاز همه موارد را کپی کنید" را علامت بزنید و به همه اهداف اضافه کنید.
در هدف Xcode خود، در زیر برگه General ، Embed and Sign for GoogleCast.xcframework را انتخاب کنید.
اگر کتابخانه ایستا را راه اندازی می کنید، این مراحل را علاوه بر مراحل قبلی دنبال کنید:
کتابخانه Protobuf را با حداقل نسخه 3.13 راه اندازی کنید.
اگر پروژه شما از CocoaPods استفاده می کند:
Podfile خود را باز کنید و google-cast-sdk در صورت وجود حذف کنید:
pod 'google-cast-sdk'
اگر کتابخانه Protobuf وجود ندارد اضافه کنید:
pod 'Protobuf', '3.13'
pod install در پوشه ریشه پروژه خود اجرا کنید.
اگر پروژه شما از CocoaPods استفاده نمی کند:
در صورت وجود، نسخه فعلی GoogleCastSDK را حذف کنید.
به دنبال دستورالعملهای موجود در مخزن Protobuf GitHub ، کتابخانه Protobuf نسخه 3.13 یا بالاتر را اضافه کنید.
در پروژه Xcode خود، پرچمها -ObjC -lc++ به Build Settings > Other Linker Flags اضافه کنید.
پوشه Resources را در دایرکتوری زیپ نشده پیدا کنید و GoogleCastCoreResources.bundle ، GoogleCastUIResources.bundle و MaterialDialogs.bundle را در پروژه خود در کنار GoogleCast.xcframework که قبلاً اضافه کرده اید، بکشید. "در صورت نیاز همه موارد را کپی کنید" را علامت بزنید و به همه اهداف اضافه کنید.
راه اندازی Mac Catalyst
برای برنامههایی که از Mac Catalyst پشتیبانی میکنند، از کتابخانه پویا Cast SDK استفاده کنید. فرآیند راه اندازی دستی را برای اضافه کردن چارچوب به پروژه خود دنبال کنید. سپس به طور مشروط Cast SDK را از هدف Mac حذف کنید، همانطور که در اسناد اپل ذکر شده است. کتابخانه های ایستا برای معماری iOS از قبل کامپایل شده اند، که باعث ایجاد خطای پیوند دهنده هنگام ساختن در برابر هدف مک می شود.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Cast framework supports iOS 14 and later and is available in static and dynamic frameworks with new XCFrameworks supporting Apple Silicon.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Cast is best integrated using CocoaPods, with manual setup as an alternative involving static or dynamic libraries.\u003c/p\u003e\n"],["\u003cp\u003eiOS 14 introduces local network permission changes requiring \u003ccode\u003eNSBonjourServices\u003c/code\u003e and \u003ccode\u003eNSLocalNetworkUsageDescription\u003c/code\u003e in your app's \u003ccode\u003eInfo.plist\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRe-release your app with Cast iOS SDK 4.8.3 to address iOS 14 network permission requirements for optimal functionality.\u003c/p\u003e\n"],["\u003cp\u003eXcode optimization level should be set to the default \u003ccode\u003e-Os\u003c/code\u003e, as \u003ccode\u003e-Ofast\u003c/code\u003e causes crashes with the Cast iOS SDK.\u003c/p\u003e\n"]]],[],null,["# Setup for Developing With the Cast Application Framework (CAF) for iOS\n\nThe Cast framework supports iOS 14 and later, and comes in both\nstatic and dynamic frameworks.\n\nSee the [Google Cast iOS API Reference](/cast/docs/reference/ios) for\ndescriptions of all classes and methods.\n| **Note:** New versions of the Cast iOS SDK XCFrameworks are now available, which support development on Apple Silicon computers.\n\nXcode setup\n-----------\n\n| **Warning:** Setting the `Apple Clang - Code Generation` `Optimization Level` flag to `-Ofast` for 'Fastest, Aggresive Optimizations' will cause apps using the Cast iOS SDK to crash due to incompatibilities with the optimizations. The SDK supports the default value `-Os` for 'Fastest, Smallest'.\n\n### iOS 14\n\n| **iOS 14 Warning** : Changes to iOS 14 local network access permissions have impacted the Google Cast iOS SDK in a number of ways. Please see the [iOS 14 Changes](/cast/docs/ios_sender/permissions_and_discovery#ios_14) document to see how your app is affected.\n\n1. **Add the Cast iOS SDK 4.8.3 to your project**\n\n\n If using CocoaPods, use `pod update` to add the 4.8.3 SDK to your project.\n\n\n Otherwise,\n [pull in the SDK manually](https://developers.google.com/cast/docs/ios_sender#manual_setup).\n | **Note** : If you built a custom device picker in your app, then you will need to explicitly call the `startDiscovery` method on the [`GCKDiscoveryManager`](/cast/docs/reference/ios/interface_g_c_k_discovery_manager) class to initiate device discovery. Automatic scanning was disabled by default beginning with the v4.5.0 release of the Cast SDK.\n2. **Add `NSBonjourServices` to your `Info.plist`**\n\n\n Specify `NSBonjourServices` in your `Info.plist` to\n allow local network discovery to succeed on iOS 14.\n\n\n You will need to add both `_googlecast._tcp` and\n `_\u003cyour-app-id\u003e._googlecast._tcp` as services for device\n discovery to work properly.\n\n\n The appID is your receiverID, which is the same ID that is defined in your\n `GCKDiscoveryCriteria`.\n\n\n Update the following example `NSBonjourServices` definition and\n replace \"ABCD1234\" with your appID. \n\n ```scdoc\n \u003ckey\u003eNSBonjourServices\u003c/key\u003e\n \u003carray\u003e\n \u003cstring\u003e_googlecast._tcp\u003c/string\u003e\n \u003cstring\u003e_ABCD1234._googlecast._tcp\u003c/string\u003e\n \u003c/array\u003e\n ```\n3. **Add `NSLocalNetworkUsageDescription` to your\n `Info.plist`**\n\n\n We strongly recommend that you customize the message shown in the Local\n Network prompt by adding an app-specific permission string in your app's\n `Info.plist` file for the\n `NSLocalNetworkUsageDescription` such as to describe Cast\n discovery and other discovery services, like DIAL. \n\n ```genshi\n \u003ckey\u003eNSLocalNetworkUsageDescription\u003c/key\u003e\n \u003cstring\u003e${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi\n network.\u003c/string\u003e\n ```\n\n\n This message will appear as part of the iOS Local Network Access dialog as\n shown in the mock.\n4. **Re-release your app to the Apple App Store**\n\n\n We recommend you also re-release your app using 4.8.3 as\n soon as possible.\n\n### iOS 13\n\n| **iOS 13 Warning** : Apple permissions changes to iOS 13 and Xcode 11 have impacted the Google Cast iOS SDK in a number of ways. Please see the [iOS 13 Changes](/cast/docs/ios_sender/permissions_and_discovery#ios_13) document to see how your app will be impacted.\n\n### iOS 12\n\n| **iOS 12 Warning** : If developing using Xcode 10, the \"Access WiFi Information\" capability is required in order to discover and connect to Cast devices.\n\nEnsure that the **Access WiFi Information** switch in the **Capabilities**\nsection of the target is set to \"On\".\n\nAdditionally, your provisioning profile will need to support the **Access WiFi\nInformation** capability. This can be added in the\n[Apple Developer Portal](https://developer.apple.com/account/).\n\n### CocoaPods setup\n\nThe recommended way of integrating Google Cast is using\n[CocoaPods](https://cocoapods.org/). For integration, use the\n[`google-cast-sdk`](https://cocoapods.org/pods/google-cast-sdk) CocoaPods.\n\nTo get started, follow the\n[getting started guide](https://guides.cocoapods.org/using/getting-started.html).\n\nOnce CocoaPods is set up, follow the\n[using CocoaPods guide](https://guides.cocoapods.org/using/using-cocoapods.html)\nto get your `Podfile` created and your project ready to use with the Google Cast\nSDK.\n\nHere's an example of how to add the `google-cast-sdk` CocoaPod to your\n`Podfile`: \n\n use_frameworks!\n\n platform :ios, '14.0'\n\n def target_pods\n pod 'google-cast-sdk'\n end\n\n target 'CastVideos-objc' do\n target_pods\n end\n target 'CastVideos-swift' do\n target_pods\n end\n\nFor your project, you should specify a range for your pods to prevent unexpected\nbreaking changes as detailed in the\n[podfile guide](https://guides.cocoapods.org/using/the-podfile.html).\n\nIn this snippet, version 4.8.3 and the versions up to the next\nmajor version (major.minor.patch) are allowed: \n\n pod 'google-cast-sdk', '~\u003e 4.8.3'\n\nFor example, '\\~\\\u003e 1.6.7' would include all versions from 1.6.7 and up to, but not\nincluding, version 2.0.0.\n\n### Manual setup\n\nThe following instructions are for adding the Cast iOS SDK to your project\nwithout using CocoaPods:\n| **Key Point:** Starting with version 4.3.1, CocoaPods uses static libraries to avoid duplicate symbol warnings caused by a shared Protobuf library dependency when using the Firebase and Cast SDKs together. Although this change will result in a larger download, the final app size will not increase.\n|\n| If the size difference is a concern for your situation, download the\n| dynamic library to get a size similar to pre-4.3.1 versions of the CocoaPods\n| library.\n\n#### Downloads\n\nAfter downloading the appropriate library below, follow the\n[setup steps](/cast/docs/ios_sender#setup_steps) to add the framework to your\nproject.\n\nCast iOS Sender SDK 4.8.3 libraries:\n\n\n[Static](https://dl.google.com/dl/chromecast/sdk/ios/GoogleCastSDK-ios-4.8.3_static.zip)\n[Dynamic](https://dl.google.com/dl/chromecast/sdk/ios/GoogleCastSDK-ios-4.8.3_dynamic.zip)\n\n#### Setup steps\n\nTo install the library:\n\n1. Download and extract the appropriate SDK for your project.\n2. Set up the dynamic GoogleCastSDK library:\n3. Drag the unzipped `.xcframework` into your main project in the Xcode project navigator (not into the Pods project if you have one). Check 'Copy all items if needed', and add to all targets.\n4. In your Xcode target, under the `General` tab, select `Embed\n and Sign` for `GoogleCast.xcframework`.\n\nIf you are setting up the **static** library, follow these steps in addition to\nthe previous steps:\n\n1. Set up the Protobuf library with minimum version v3.13.\n 1. If your project uses CocoaPods:\n 1. Open your `Podfile` and remove the `google-cast-sdk` if present: \n\n ```text\n pod 'google-cast-sdk'\n ```\n 2. Add the `Protobuf` library if not present: \n\n ```text\n pod 'Protobuf', '3.13'\n ```\n 3. Run `pod install` in the root folder of your project.\n 2. If your project is not using CocoaPods:\n 1. Remove the current version of `GoogleCastSDK` if present.\n 2. Add the Protobuf library v3.13 or greater, following the instructions found on the [Protobuf GitHub\n repo](https://github.com/protocolbuffers/protobuf).\n2. In your Xcode project, add the flags `-ObjC -lc++` to **Build Settings** \\\u003e **Other Linker Flags** .\n3. Locate the Resources folder in the unzipped directory and drag `GoogleCastCoreResources.bundle`, `GoogleCastUIResources.bundle` and `MaterialDialogs.bundle` into the your project next to the `GoogleCast.xcframework` you added previously. Check 'Copy all items if needed', and add to all targets.\n\n### Mac Catalyst setup\n\nFor Apps that support Mac Catalyst, use the dynamic library of the Cast SDK.\nFollow the [manual setup process](/cast/docs/ios_sender#manual_setup) to add the\nframework to your project. Then conditionally exclude the Cast SDK from the Mac\ntarget as mentioned in the\n[Apple documentation](https://developer.apple.com/documentation/xcode/creating_a_mac_version_of_your_ipad_app).\nStatic libraries are pre-compiled for iOS architecture, which causes a linker\nerror when building against the Mac target."]]