I’m working on an Ionic React Project
running on top of Capacitor
. I added Android platform and everything went smoothly. Now that I’m trying to make my app work in iOS (first time working with iOS), after adding ios platform and open my project in XCode, I ran into some issues.
See the errors:
Podfile content:
Any help would be really appreciated. Thank you!
7
Answers
For anyone interested, I deleted ios folder and added iOS platform again. After that, instead of running '
pod install
' (I got errors via this command), I used these commands:in regular terminal, outside the Project directory:
then inside iOS folder
After these commands, all capacitor pods/plugins got installed successfully. I opened the app using this command:
ionic cap open ios
and got an error:No module Capacitor found
, but anyway I ignored this error and ran/build the app inside XCode. The emulator got opened successfully and the app ran smoothly.If capacitor is a Pod I am assuming it since you have attached your podfile,
Then add Capacitor pod with version to the podfile
And run
pod install
It should be available,Otherwise if it a external framework make sure to add it to the project and copy it under
Target-> BuildPhases-> Link Binary With Libraries Option
The problem with editing your Podfile directly within the iOS bundle in Xcode is that every time you build your bundle, you risk losing the changes you have made to the Podfile.
Capacitor should build it for you automatically when you run
ionic cap add ios
orionic cap build ios
.If it doesn’t, you could try deleting the iOS bundle in your IDE (e.g. VS Code) and then add it again using the CLI.
Obviously a Podfile will differ from project to project, but one generated with Ionic/Capacitor generally looks like this:
I faced the same problem today. After doing some research I finally made my project work on iOS! I am using Angular version 9.
I could not run the XCode project since ionic would not create the required podfile.
I simply created the iOS app with npx first and then used ionic to run a live reload of my app.
The commands are the following:
npm install @capacitor/ios
npx cap add ios
ng build
(creates the www directory)npx cap open ios
ionic capacitor run ios --livereload --external
(Sources: npx and ionic)
I already had an IOS folder generated, so I deleted it and ran the following commands:
npx cap add ios
ionic build ios or ng build
npx cap sync ios
only if is necessarynpx cap open ios
If you’re trying to use multiple schemes within your capacitor project, I resolved this by adding this to my project’s Podfile:
It’s in the docs here
In my case I was opening .xcodeproj instead of xcworkspace in xcode.
Once I opened the . xcworkspace file, app built successfully.
Difference between the two is explained well here:
https://stackoverflow.com/a/21631534/4868839