Use CocoaPods on Windows: pod install and iOS App Builds
Keep your Podfile as it is. Run pod install on Windows and build the generated workspace.
Last updated
To use CocoaPods on Windows, you don't install Ruby yourself: the KXBuild toolchain ships Ruby and CocoaPods, so after doctor pod runs in any terminal and pod init, pod install and pod update work as usual. Your Podfile and project need no changes, whether the project is Swift or Objective-C. Build the .xcworkspace that pod install creates, install it on your iPhone over USB, debug with breakpoints and get an .ipa from a Release build.
How do I set up CocoaPods on Windows and add it to a project?
1. Run doctor
Doctor checks CocoaPods and installs it if it's missing.
In the title bar of the KXBuild view, open the ··· menu and run Doctor (fix environment).
> kxbuild doctorWhen it finishes, open a new terminal. If this prints a version number, you're ready.
> pod --version2. Create a project
For a new project, use the template that comes with a Podfile. It runs pod install after creating the project, so you can skip to step 4.
Run KXBuild: New Project from the Command Palette and pick the "iOS App (Swift, CocoaPods)" template.
> kxbuild project create -t app_swift_cocoapods -n MyApp -o D:\projectsIf an existing project has no Podfile yet, create one in the folder containing the .xcodeproj. If it already has one, go to the next step.
> pod initHow do I write the Podfile, and which file do I open after pod install?
3. Add dependencies
List the libraries each target needs in the Podfile. The version syntax is in the appendix at the end of this page.
platform :ios, '15.0'
use_frameworks!
target 'MyApp' do
pod 'Alamofire', '~> 5.9'
pod 'SDWebImage'
endThen install from the folder containing the Podfile. This downloads the dependencies and creates the Pods folder, Podfile.lock and MyApp.xcworkspace.
> pod installFrom now on, build and debug the .xcworkspace. The .xcodeproj can't find the libraries in Pods. Run pod install again every time you change the Podfile. Commit Podfile.lock to version control so everyone on the team installs the same versions.
How do I code and debug a CocoaPods project on an iPhone?
4. Write code
In VS Code, open the folder containing the Podfile with File > Open Folder…, and set the startup project to the .xcworkspace in the KXBuild view.
Your source files get completion, go to definition and error checking, and libraries in Pods get completion and go to definition after the first build. If completion misbehaves, see Code completion and indexing.
5. Debug
Select it in the KXBuild view and press F5. KXBuild builds, installs and stops at your breakpoints. You can set breakpoints in your own code and in any Pods library that ships its source.
Build the workspace, install it on the phone and launch it:
> kxbuild run .\MyApp.xcworkspaceBefore you connect a phone for the first time, install and open Apple Devices from the Microsoft Store to get the USB driver on Windows. On iOS 16 and later, also turn on Developer Mode in Settings > Privacy & Security. If the device list stays empty, try another cable or USB port, then unlock the phone and look for the trust prompt. See connect an iPhone to Windows.
How do I build a CocoaPods app as an .ipa for the App Store?
6. Release
Build with the Release configuration to get build\MyApp.ipa in the project folder. To upload it to App Store Connect, see publish to the App Store from Windows.
Run KXBuild: Build for App Store (.ipa) from the Command Palette or the project's context menu.
Build the workspace that pod install created.
> kxbuild build .\MyApp.xcworkspace -c Release --export app-storeHow do I upgrade CocoaPods dependencies?
pod install only installs the versions recorded in Podfile.lock and never upgrades libraries you already have. To upgrade, first see which libraries have newer versions, then update all of them or just the ones you name.
> pod outdated> pod update Alamofirepod update without a library name upgrades every library within the ranges your Podfile allows. If a version that was just released can't be found, add --repo-update to refresh the local spec index first.
How do I fix common CocoaPods errors?
| Problem | Fix |
|---|---|
| The build can't find headers or modules from Pods | You're building the .xcodeproj. Build the .xcworkspace instead. If you just changed the Podfile, run pod install first |
| The sandbox is not in sync with the Podfile.lock | Podfile.lock changed when you pulled. Run pod install |
| Dependencies are in a bad state and you want to start over | Delete the Pods folder and run pod install again. If that doesn't help, clear the cache with pod cache clean --all |
| The pod command isn't found | Run doctor, then open a new terminal |
Every fix in the table runs in your local terminal and touches nothing but the Podfile and the Pods it produces. When you use CocoaPods on Windows, commit or ignore the Pods folder the way your team already does, and always commit Podfile.lock. For Swift projects that also use Swift Package Manager, see develop Swift iOS apps on Windows. For Flutter plugins that need pod install, see build Flutter iOS apps on Windows.
Which pod commands and Podfile version rules do I need?
| Command | What it does |
|---|---|
| pod init | Creates a Podfile for the project in the current folder |
| pod install | Installs dependencies from the Podfile and Podfile.lock and creates the .xcworkspace |
| pod update [name] | Upgrades all libraries or the named one, and updates Podfile.lock |
| pod outdated | Lists libraries that have newer versions |
| pod repo update | Refreshes the local spec index |
| pod search keyword | Searches for available libraries |
| pod cache clean --all | Clears the download cache |
| pod deintegrate | Removes CocoaPods from the project |
| Podfile entry | Meaning |
|---|---|
| pod 'Alamofire' | Latest version |
| pod 'Alamofire', '5.9.1' | Exactly this version |
| pod 'Alamofire', '~> 5.9' | 5.9 or later, below 6.0 |
| pod 'Alamofire', '>= 5.0' | 5.0 or later |
| pod 'MyKit', :path => '../MyKit' | A library in a local folder |
| pod 'MyKit', :git => 'https://…/MyKit.git', :tag => '1.0.0' | A specific version from a Git repository |
Next steps
Objective-C
Open your existing Xcode project and build. No changes needed.
Swift
Open an Xcode project and build, with SPM dependencies resolved automatically. Pure Swift packages can be converted to an app to produce an .ipa.
Don't see your framework?
kxbuild is a general-purpose build toolchain, so if your framework produces an Xcode project, KXBuild can build it. The list above covers common cases only. Tell us about your setup.