Edit: Solved below, edited the question to help others googling for symptoms
ionic capacitor build ios
creates empty Xcode workspace
I am migrating my Ionic app from cordova to capacitor. Following the guides Here and Here
When attempting to build for ios, the Xcode workspace that capacitor outputs is empty
Image of Empty Xcode Workspace
I was able to reproduce it with the starter template, so I get the impression something is missing from my setup.
What might I be missing from my installation?
Thanks in advance.
Reproduction:
#from fresh with angular and capacitor
ionic start
<snip>
XXXX@XXXXs-Mac-mini test % ionic cap build ios
<snip>
> capacitor sync ios
[capacitor] ✔ Copying web assets from www to ios/App/App/public in 4.81ms
[capacitor] ✔ Creating capacitor.config.json in ios/App/App in 454.83μs
[capacitor] ✔ copy ios in 26.84ms
[capacitor] ✔ Updating iOS plugins in 1.98ms
[capacitor] [warn] Skipping pod install because CocoaPods is not installed
[capacitor] ✔ Updating iOS native dependencies with pod install in 2.29s
[capacitor] [info] Found 4 Capacitor plugins for ios:
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] ✔ update ios in 2.31s
[capacitor] [info] Sync finished in 2.485s
[INFO] Ready for use in your Native IDE!
To continue, build your project using Xcode!
> capacitor open ios
[capacitor] ✔ Opening the Xcode workspace... in 3.00s
.. Which opens an empty code window.
ionic serve
works fine, and I can build the android app on a windows machine.
If I try ionic cap run ios
, it errors out:
<snip>
> capacitor run ios --target XXXX-XXXX
[capacitor] ✔ Copying web assets from www to ios/App/App/public in 231.03ms
[capacitor] ✔ Creating capacitor.config.json in ios/App/App in 1.25ms
[capacitor] [info] Inlining sourcemaps
[capacitor] ✔ copy ios in 261.11ms
[capacitor] ✔ Updating iOS plugins in 2.36ms
[capacitor] [warn] Skipping pod install because CocoaPods is not installed
[capacitor] ✔ Updating iOS native dependencies with pod install in 696.90ms
[capacitor] [info] Found 4 Capacitor plugins for ios:
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] ✔ update ios in 716.42ms
[capacitor] ✖ Running xcodebuild - failed!
[capacitor] [error] Command line invocation:
[capacitor] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace App.xcworkspace -scheme App -configuration Debug -destination id=XXXX-XXXX -derivedDataPath /Users/XXXX/Documents/git_repos/test/ios/DerivedData/XXXX-XXXX
[capacitor]
[capacitor] User defaults from command line:
[capacitor] IDEDerivedDataPathOverride = /Users/XXXX/Documents/git_repos/test/ios/DerivedData/XXXX-XXXX
[capacitor] IDEPackageSupportUseBuiltinSCM = YES
[capacitor]
[capacitor] 2024-06-06 17:23:13.823 xcodebuild[20496:197702] Writing error result bundle to /var/folders/n0/5ynq2fzj05gcqq1bgvfbp0rc0000gn/T/ResultBundle_2024-06-06_17-23-0013.xcresult
[capacitor] xcodebuild: error: The workspace named "App" does not contain a scheme named "App". The "-list" option can be used to find the names of the schemes in the workspace.
[capacitor]
[ERROR] An error occurred while running subprocess capacitor.
capacitor run ios --target XXXX-XXXX exited with exit code 1.
Other info:
Code is running on a new Mac mini
Xcode v15.3
macOS Sonoma 14.5
ionic info
[WARN] Error loading @capacitor/android package.json: Error: Cannot find module '@capacitor/android/package.json'
Require stack:
- /Users/XXXX/.nvm/versions/node/v22.2.0/lib/node_modules/@ionic/cli/lib/project/index.js
- /Users/XXXX/.nvm/versions/node/v22.2.0/lib/node_modules/@ionic/cli/lib/index.js
- /Users/XXXX/.nvm/versions/node/v22.2.0/lib/node_modules/@ionic/cli/index.js
- /Users/XXXX/.nvm/versions/node/v22.2.0/lib/node_modules/@ionic/cli/bin/ionic
Ionic:
Ionic CLI : 7.2.0 (/Users/XXXX/.nvm/versions/node/v22.2.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 8.2.1
@angular-devkit/build-angular : 18.0.3
@angular-devkit/schematics : 18.0.3
@angular/cli : 18.0.3
@ionic/angular-toolkit : 11.0.1
Capacitor:
Capacitor CLI : 6.0.0
@capacitor/android : not installed
@capacitor/core : 6.0.0
@capacitor/ios : 6.0.0
Utility:
cordova-res : not installed globally
native-run : 2.0.1
System:
NodeJS : v22.2.0 (/Users/XXXX/.nvm/versions/node/v22.2.0/bin/node)
npm : 10.7.0
OS : macOS Unknown
I can open the App.xcodeproj (instead of App.xcworkspace), and attempting to build that project in xcode gives the error:
Unable to open base configuration reference file '.../test/ios/App/Pods/Target Support Files/Pods-App/Pods-App.debug.xconfig'
Again, Thanks in Advance
Missing Dependancies
While I was following the guides, I missed the Environment Setup step where the new dependencies were installed.
The clue was
[capacitor] [warn] Skipping pod install because CocoaPods is not installed
There is mention elsewhere that you don't need to have CocoaPods installed if you are managing the packaged by another method. So I didn't immediately pick up on it, thinking capacitor would handle it itself.
One would have thought capacitor would error out rather than creating an empty project, but here we are.
To install the dependancies:
#install Xcode cli tools and verify
xcode-select --install
xcode-select -p
#homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#add to path
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/asptech/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
#CocoaPods install and verify
brew install cocoapods
pod --version
After installing the dependencies, you may need to remove and re-add the ios platform.
#unlike cordova, capacitor does not have a remove command
rm -rf ./ios/
ionic cap add ios
ionic cap build ios