Search code examples
iosxcodevue.jsdependenciescapacitor

iOS app created with Capacitor is unable to start


I have a webapp created in Vue.js. By using Capacitor, it is ported to android where it was tested and works seamlessly. I also tried to set it up on iOS, but after successful building, it terminates immediately with a SIGABRT, and outputs the error that it could not load any of the Capacitor libraries in the build folder.

I have the following Podfile installed:

require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

platform :ios, '13.0'
use_frameworks!

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 'CapacitorCamera', :path => '../../node_modules/@capacitor/camera'
  pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
  pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
  pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
end

target 'App' do
  capacitor_pods
end

post_install do |installer|
  assertDeploymentTarget(installer)
end

The relative paths for the Capacitor folders are correct.

After that, I opened the project in Xcode and after some configurations, the app builds successfully, but as soon as I try to start and simulate it, it fails with the following error:

dyld[14090]: Library not loaded: @rpath/Capacitor.framework/Capacitor
  Referenced from: <56B96A3F-7B7F-374E-B1D5-D23A07AC84EE> /Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/App.debug.dylib
  Reason: tried: '/Users/martontoth/Library/Developer/Xcode/DerivedData/App-fswzvuauecnneohjcmrldgxdpzfz/Build/Products/Debug-iphonesimulator/Capacitor.framework/Capacitor' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/Capacitor.framework/Capacitor' (no such file), '/usr/lib/swift/Capacitor.framework/Capacitor' (no such file, not in dyld cache), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Frameworks/Capacitor.framework/Capacitor' (no such file), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Frameworks/Capacitor.framework/Capacitor' (no such file), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Capacitor.framework/Capacitor' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/Capacitor.framework/Capacitor' (no such file), '/usr/lib/swift/Capacitor.framework/Capacitor' (no such file, not in dyld cache), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Frameworks/Capacitor.framework/Capacitor' (no such file), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Frameworks/Capacitor.framework/Capacitor' (no such file), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Capacitor.framework/Capacitor' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/Capacitor.framework/Capacitor' (no such file), '/usr/lib/swift/Capacitor.framework/Capacitor' (no such file, not in dyld cache), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Frameworks/Capacitor.framework/Capacitor' (no such file), '/Users/martontoth/Library/Developer/CoreSimulator/Devices/2B165691-E1C2-4D0D-BAED-3022A689D026/data/Containers/Bundle/Application/7165A92D-5BDB-48A6-B46C-C783AD26D9A7/App.app/Frameworks/Capacitor.framework/Capacitor' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_22C150/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Capacitor.framework/Capacitor' (no such file)

In the target app's build settings I also added @executable_path/Frameworks to Runtime Search Paths. When I check the build folder, it does not have the Frameworks folder created at all.

What else am I missing to configure?


Solution

  • In my case, I was opening .xcodeproj instead of .xcworkspace in Xcode. Once I opened the .xcworkspace file, the app was built successfully.

    The difference between the two is explained well here: https://stackoverflow.com/a/21631534/4868839


    (optional) If you face build errors

    I managed to solve this issue by installing Cocoapods

    brew uninstall --cask cocoapods
    brew install cocoapods 
    brew link --overwrite cocoapods
    

    After reinstalling, go to the App folder and see if you can install it.

    pod install 
    

    If everything works open the App.xcworkspace and click on run.