Ionic iOS build process failing

Hi Everyone

So I’m attempting to build out my test Ionic 5.4.15 app to iOS and I’m having a hell of a time getting it to work. The strange thing is that when I first tried doing this - before I presumably changed something on my system - it all worked fine and I could deploy to my iOS device. Now, however, I’m stuck. Running

ionic cap add ios 

on a fresh Ionic project fails at the

update ios

command.

✖ Updating iOS native dependencies with "pod install" (may take several minutes): 
✖ update ios: 
[error] Error running update: Analyzing dependencies
Downloading dependencies
Installing Capacitor (1.4.0)
Installing CapacitorCordova (1.4.0)
Generating Pods project

It appears that the cocoapods install, or something related to it, is causing the problem.

Running

pod install --verbose

in the /ios/app folder likewise fails, so it seems clear this is where the problem lies.

Initially when I encountered this issue I was receiving the error:

LoadError - cannot load such file -- rexml/document

and I solved that (or perhaps made worse) by installing rexml to my global folder with

sudo gem install -n /usr/local/bin rexml

Now when I run the pod install command I get a different error. To save breaking this down I’m going to paste the full verbose output here. I hope someone can shed some light on this. Cheers!

pod install --verbose
Preparing

Analyzing dependencies

Inspecting targets to integrate
Using ARCHS setting to build architectures of target Pods-App: (``)

Fetching external sources
-> Fetching podspec for Capacitor from ../../node_modules/@capacitor/ios
-> Fetching podspec for CapacitorCordova from ../../node_modules/@capacitor/ios

Resolving dependencies of Podfile
/Users/–user–/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.encode is obsolete
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local
because checking is only perfomed in repo update

Comparing resolved specification to the sandbox manifest
A Capacitor
A CapacitorCordova

Downloading dependencies

-> Installing Capacitor (1.4.0)

-> Installing CapacitorCordova (1.4.0)

  • Running pre install hooks

Generating Pods project

  • Creating Pods project
  • Installing files into Pods project
    • Adding source files
    • Adding frameworks
    • Adding libraries
    • Adding resources
    • Adding development pod helper files
    • Linking headers
  • Installing Pod Targets
    • Installing target Capacitor iOS 11.0
      • Generating module map file at Pods/Target Support Files/Capacitor/Capacitor.modulemap
      • Generating umbrella header at Pods/Target Support Files/Capacitor/Capacitor-umbrella.h
      • Generating Info.plist file at Pods/Target Support Files/Capacitor/Capacitor-Info.plist
      • Generating dummy source at Pods/Target Support Files/Capacitor/Capacitor-dummy.m
    • Installing target CapacitorCordova iOS 11.0
      • Generating module map file at Pods/Target Support Files/CapacitorCordova/CapacitorCordova.modulemap
      • Generating umbrella header at Pods/Target Support Files/CapacitorCordova/CapacitorCordova-umbrella.h
      • Generating Info.plist file at Pods/Target Support Files/CapacitorCordova/CapacitorCordova-Info.plist
      • Generating dummy source at Pods/Target Support Files/CapacitorCordova/CapacitorCordova-dummy.m
  • Installing Aggregate Targets
    • Installing target Pods-App iOS 11.0
      • Generating Info.plist file at Pods/Target Support Files/Pods-App/Pods-App-Info.plist
      • Generating module map file at Pods/Target Support Files/Pods-App/Pods-App.modulemap
      • Generating umbrella header at Pods/Target Support Files/Pods-App/Pods-App-umbrella.h
      • Generating dummy source at Pods/Target Support Files/Pods-App/Pods-App-dummy.m
  • Generating deterministic UUIDs
  • Stabilizing target UUIDs
  • Running post install hooks
  • Writing Xcode project file to Pods/Pods.xcodeproj
    /Users/–user–/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.encode is obsolete
    CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local
    because checking is only perfomed in repo update

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

— Command

/usr/local/bin/pod install --verbose

Report

  • What did you do?

  • What did you expect to happen?

  • What happened instead?

Stack

   CocoaPods : 1.8.4
        Ruby : ruby 2.8.0dev (2020-01-16T06:36:38Z master fce54a5404) [x86_64-darwin19]
    RubyGems : 3.1.2
        Host : Mac OS X 10.15.2 (19C57)
       Xcode : 11.3.1 (11C504)
         Git : git version 2.21.1 (Apple Git-122.3)
Ruby lib dir : /Users/--user--/.rvm/rubies/ruby-head/lib
Repositories : master - git - https://github.com/CocoaPods/Specs.git @ 47ca3d28aeb876cb0d4eecc799a05ad19afa0d15
               trunk - CDN - https://cdn.cocoapods.org/

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0

Podfile

platform :ios, '11.0'
use_frameworks!

# workaround to avoid Xcode 10 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
  # Automatic Capacitor Pod dependencies, do not delete
  pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
  pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
  
  # Do not delete
end

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

Error

ArgumentError - wrong number of arguments (given 2, expected 1)
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/nanaimo-0.2.6/lib/nanaimo/writer.rb:35:in `initialize'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/nanaimo-0.2.6/lib/nanaimo/writer/pbxproj.rb:13:in `initialize'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/xcodeproj-1.14.0/lib/xcodeproj/project.rb:364:in `new'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/xcodeproj-1.14.0/lib/xcodeproj/project.rb:364:in `block in save'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/atomos-0.1.3/lib/atomos.rb:21:in `block in atomic_write'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/2.8.0/tempfile.rb:291:in `open'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/atomos-0.1.3/lib/atomos.rb:17:in `atomic_write'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/xcodeproj-1.14.0/lib/xcodeproj/project.rb:363:in `save'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:56:in `block (2 levels) in write!'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:145:in `message'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:42:in `block in write!'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:41:in `each'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:41:in `write!'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:326:in `block in create_and_save_projects'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:64:in `section'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:303:in `create_and_save_projects'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:294:in `generate_pods_project'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:173:in `integrate'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:162:in `install!'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:52:in `run'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Users/--user--/.rvm/rubies/ruby-head/lib/ruby/gems/2.8.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
/usr/local/bin/ruby_executable_hooks:24:in `eval'
/usr/local/bin/ruby_executable_hooks:24:in `<main>'

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

Hi @snouto!
Welcome to the community!
I suppose that your local installation may be not correct.
So first, remove the iOS platform from the app and try again.
Uninstall the cocoapods from your mac, and start a fresh installation.
Take care about using “sudo”, use only if it’s necessary.
Hope it helps to solve the problem.

1 Like

…and, by the way, it’s never necessary.

1 Like

Thanks, I think I’ve tried all that already to no avail. I also removed Ionic and reinstalled but still the problem persisted.

I’ll give it another go.

p.s. I’m aware sudo can be risky but I was willing to try anything to get this problem resolved.

[EDIT]
I’ve now completely removed Cocoapods, rebooted my machine, then reinstalled Cocoapods and reissued the nix cap add ios command, but the same error is being printed. This is killing me :frowning:

I’ve finally managed to get the iOS build working. For anyone else experiencing this issue, here’s what fixed it for me:

  1. Downgraded Ruby from 2.8.0dev to 2.6.3 using rvm (if you don’t have rvm install it first 'natch):
rvm install "ruby-2.6.3"
  1. Use the new ruby version. Note that in my case this is only active in the same terminal window. As soon as a new window opens, it reverts to the default:
rvm use 2.6.3
  1. This by itself did not fix the issue. So I also downgraded my version of gems from 3.1.2 to 3.0.3 Be sure to do this when using ruby 2.6.3 or it’ll fail:
gem update --system 3.0.3
  1. Still the problem was not resolved, because now cocoapods couldn’t be found. So I also reinstalled cocoapods:
sudo gem uninstall cocoapods
Gem 'cocoapods' is not installed

sudo gem install -n /usr/local/bin cocoapods
  1. Once that was complete I then removed my existing iOS build folder and recreated it:
npx cap add ios
  1. Sit back and pray to Jebus

  2. Great success!

✔ Updating iOS native dependencies with "pod install" (may take several minutes) in 4.14s
✔ update ios in 4.15s

Some of these steps may not have been needed, or could have perhaps been done in a different order, but after days of noodle scratching I’m now finally able to get a build to my device.

Good luck everyone!