简体   繁体   中英

“Editor placeholder in source file” Swift Compile Error in CAPBridge.swift

I am creating an app with Ionic/Angular/Capacitor. My app has been compiling and building fine for a while. I was able to build and run the app on the Xcode simulation as well as my iPhone. However, I had a recent pop up for an Xcode update that I subconsciously click OK on without paying much attention about what I did. What a stupid thing to do,.: Now, I am getting a Capacitor Buildtime error of "Swift Compiler Error - Editor placeholder in source file - CAPBridge.swift in this area of the code:

public func modulePrint(_ plugin: CAPPlugin, _ items: Any...) {
    let output = items.map { "\($0)" }.joined(separator: " ")
    CAPLog.print("⚡️ ", plugin.pluginId ?? <#default value#>, "-", output)
  }

On the Xcode editor, the "<#default value#>” part of the code was replaced with a gray box and the “default value” text in it with the error message “Editor placeholder in source file”. I am not a Swift programmer and was not able to find any reason why this error would comes up now, or a way to fix it. I've posted the same question on the Capacitor Forum. However, I am hoping that someone would recognize the "<#default value#> syntax or know of any recent changes in Xcode that would cause such error.

There is one more observation. To make sure, I did a Clean before trying to run the app on the Xcode simulator again. When I do a Product -> Clean Build Folder, I got a different Swift Compiler Error after the Clean finished. I got "No such module 'Cordova'" in CAPBridge.swift. This error will go away and be replaced by the "Editor placeholder in source file" error. BTW, I am using Capacitor and not Cordova and have never done a Clean in the past while things were all running fine. So, I am not sure if the "No such module 'Cordova'" error has always been there from a Clean operation.

The following is the output from running ionic info to show my current running environment:

Ionic:

   Ionic CLI                     : 6.12.0 (/Users/francistse/.nvm/versions/node/v10.16.3/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.0.0
   @angular-devkit/build-angular : 0.803.25
   @angular-devkit/schematics    : 8.3.25
   @angular/cli                  : 8.3.25
   @ionic/angular-toolkit        : 2.1.2

Capacitor:

   Capacitor CLI   : 2.4.2
   @capacitor/core : 2.4.2

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : none
   Cordova Plugins   : no whitelisted plugins (1 plugins total)

Utility:

   cordova-res (update available: 0.15.2) : 0.15.1
   native-run                             : not installed

System:

   NodeJS : v10.16.3 (/Users/francistse/.nvm/versions/node/v10.16.3/bin/node)
   npm    : 6.14.5
   OS     : macOS Catalina
   Xcode  : Xcode 12.2 Build version 12B5025f

You can resolve the compiler error by replacing <#default value#> with "n/a" .

Uninstall @capacitor/ios and reinstall it to get the original code, then run sync

npm uninstall @capacitor/ios
npm install @capacitor/ios
npx cap sync ios

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM