skip to Main Content

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:

enter image description here

enter image description here

Podfile content:

enter image description here

Any help would be really appreciated. Thank you!

7

Answers


  1. Chosen as BEST ANSWER

    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:

    sudo arch -x86_64 gem install ffi
    

    then inside iOS folder

    arch -x86_64 pod install
    

    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.


  2. 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

    Login or Signup to reply.
  3. 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 or ionic 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:

    platform :ios, '12.0'
    use_frameworks!
    
    # workaround to avoid Xcode caching of Pods that requires
    # Product -> Clean Build Folder after new Cordova plugins installed
    # Requires CocoaPods 1.6 or newer
    install! 'cocoapods', :disable_input_output_paths => true
    
    def capacitor_pods
      pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
      pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
      pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
      pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
      pod 'CapacitorGeolocation', :path => '../../node_modules/@capacitor/geolocation'
      pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
      pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
      pod 'CapacitorLocalNotifications', :path => '../../node_modules/@capacitor/local-notifications'
      pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network'
      pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
      pod 'CapacitorStorage', :path => '../../node_modules/@capacitor/storage'
      pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
    end
    
    target 'App' do
      capacitor_pods
      # Add your Pods here
    end
    
    Login or Signup to reply.
  4. 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:

    1. npm install @capacitor/ios
    2. npx cap add ios
    3. ng build (creates the www directory)
    4. npx cap open ios
    5. ionic capacitor run ios --livereload --external
    6. Run the app from XCode in order to get the app’s logs during runtime

    (Sources: npx and ionic)

    Login or Signup to reply.
  5. I already had an IOS folder generated, so I deleted it and ran the following commands:

    1. npx cap add ios

    2. ionic build ios or ng build

    3. npx cap sync ios only if is necessary

    4. npx cap open ios

    Login or Signup to reply.
  6. If you’re trying to use multiple schemes within your capacitor project, I resolved this by adding this to my project’s Podfile:

    target 'TARGETNAME' do
      capacitor_pods
      # Add your Pods here
    end
    

    It’s in the docs here

    Login or Signup to reply.
  7. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search