首次创建CocoaPod执行pod trunk push遇文件路径错误求助
Hey there! I've hit this exact snag when I first launched my own CocoaPod, so let's break down the most likely causes and how to fix them:
1. You're not in the right Terminal directory
This is the #1 reason for this error. If your DemoView.podspec lives inside a project folder (like ~/Code/DemoView/) but your Terminal is currently in your home folder or another unrelated directory, CocoaPods can't locate the file.
- Fix: Use the
cdcommand to navigate to the folder containing your podspec. For example:cd ~/Code/DemoView/ - Verify: Run
lsin Terminal—you should seeDemoView.podspeclisted in the output.
2. You misspelled the podspec filename
It's easy to mix up capitalization, add extra characters, or use the wrong file extension. For example:
Your file might be
demoview.podspec(all lowercase) instead ofDemoView.podspecOr you created a JSON-formatted podspec, so it's named
DemoView.podspec.jsonFix: Double-check the exact filename with
ls, then use that precise name in your push command. For example:pod trunk push demoview.podspec # OR pod trunk push DemoView.podspec.json
3. You haven't created the podspec file yet
If you skipped the initial step of generating the podspec template, the file simply doesn't exist.
- Fix: Generate a podspec template first (make sure you're in your project folder), fill in your pod's details (name, version, source path, author info, etc.), then push:
# Generate the template file pod spec create DemoView # Edit the file to match your pod's configuration # Then execute the push command pod trunk push DemoView.podspec
4. Rare case: File permissions are blocking access
Occasionally, your user account might lack read access to the podspec file.
- Fix: Check permissions with
ls -l DemoView.podspec—you should seer(read) permissions for your user. If not, run:chmod +r DemoView.podspec
Once you've fixed one of these issues, re-run your pod trunk push command and it should find the file without a problem!
内容的提问来源于stack exchange,提问作者Caleb

