iOS build failed: Error code 65

I’m working on a PC but compiling for iOS using Macincloud (virtual mac in the cloud).
When I get a git clone of my project, I run:

npm install
ionic cordova platform add ios
ionic cordova build ios

The build fails with an Error Code 65 but not because I forgot to remove the console plugin. Here is the output I get:

    /Users/user908872/Library/Developer/Xcode/DerivedData/PauseFwd-bbdbrrvbgwunvvbtpmghpxrrqtec/Build/Intermediates.noindex/PauseFwd.build/Debug-iphonesimulator/PauseFwd.build/Objects-normal/x86_64/UNIJsonNode-7856D03DFA7AAA88.o
    /Users/user908872/Library/Developer/Xcode/DerivedData/PauseFwd-bbdbrrvbgwunvvbtpmghpxrrqtec/Build/Intermediates.noindex/PauseFwd.build/Debug-iphonesimulator/PauseFwd.build/Objects-normal/x86_64/UNIJsonNode-1989322D7A9BE1B1.o
duplicate symbol _OBJC_METACLASS_$_UNIJsonNode in:
    /Users/user908872/Library/Developer/Xcode/DerivedData/PauseFwd-bbdbrrvbgwunvvbtpmghpxrrqtec/Build/Intermediates.noindex/PauseFwd.build/Debug-iphonesimulator/PauseFwd.build/Objects-normal/x86_64/UNIJsonNode-7856D03DFA7AAA88.o
    /Users/user908872/Library/Developer/Xcode/DerivedData/PauseFwd-bbdbrrvbgwunvvbtpmghpxrrqtec/Build/Intermediates.noindex/PauseFwd.build/Debug-iphonesimulator/PauseFwd.build/Objects-normal/x86_64/UNIJsonNode-1989322D7A9BE1B1.o
ld: 258 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **


The following build commands failed:
	Ld build/emulator/PauseFwd.app/PauseFwd normal x86_64
(1 failure)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/user908872/Desktop/git/pf_mobile_2_0_13/platforms/ios/cordova/build-debug.xcconfig,-workspace,PauseFwd.xcworkspace,-scheme,PauseFwd,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone X,build,CONFIGURATION_BUILD_DIR=/Users/user908872/Desktop/git/pf_mobile_2_0_13/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/user908872/Desktop/git/pf_mobile_2_0_13/platforms/ios/build/sharedpch

[ERROR] An error occurred while running cordova build ios (exit code 1).

Here is my ionic info:

cli packages: (/Users/user908872/Desktop/git/pf_mobile_2_0_13/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2 
    ios-sim    : 6.1.2 
    Node       : v8.9.1
    npm        : 5.5.1 
    OS         : macOS High Sierra
    Xcode      : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

I’ve tried using ios@4.4.0 and I got it to build once. Now here is the strange part: I made a precious copy of my folder where the build worked. To test I deleted node modules, pluggins and the content of platforms. I run “npm install”, “ionic cordova platform add ios” and then build. Back to error code 65.

I’ve been at this for 3 days now and the build process feels random and moody. Same as me.

Any recommendations?

7 days later and not a single response. I don’t expect other programmer to be able to guess as to the problem but I would have hoped for some feedback from the Ionic team. I mean there is NO clue from the output build. It spits out a ton of garbage but nothing useful.

Here is my package.json:

"scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/animations": "4.1.3",
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@angular/platform-server": "4.1.3",
    "@ionic-native/core": "^3.12.1",
    "@ionic-native/facebook": "^4.3.1",
    "@ionic-native/launch-navigator": "^3.4.4",
    "@ionic-native/onesignal": "^4.5.3",
    "@ionic-native/splash-screen": "^4.5.3",
    "@ionic-native/status-bar": "^3.12.1",
    "@ionic/cli-plugin-cordova": "^1.4.1",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/storage": "^2.0.1",
    "cordova-android": "~6.3.0",
    "cordova-ios": "4.5.4",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-facebook4": "^1.9.1",
    "cordova-plugin-ionic": "^3.1.3",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.2.1",
    "cordova-plugin-whitelist": "^1.3.1",
    "firebase": "^3.3.0",
    "ionic-angular": "^3.5.0",
    "ionic-native": "^2.4.1",
    "ionic-plugin-deploy": "^0.6.7",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "onesignal-cordova-plugin": "^2.3.1",
    "rxjs": "^5.4.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.12",
    "typescript": "2.3.4"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "cordova": {
    "plugins": {
      "cordova-plugin-app-version": {},
      "cordova-plugin-device": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "ionic-plugin-deploy": {},
      "cordova-plugin-facebook4": {
        "APP_ID": "xxxxx",
        "APP_NAME": "xxxxxxx"
      },
      "cordova-plugin-ionic": {
        "APP_ID": "xxxxxx",
        "CHANNEL_NAME": "Production",
        "UPDATE_METHOD": "background",
        "MAX_STORE": "2",
        "WARN_DEBUG": "true",
        "UPDATE_API": "https://api.ionicjs.com"
      },
      "cordova-plugin-splashscreen": {},
      "onesignal-cordova-plugin": {}
    },
    "platforms": [
      "android",
      "ios"
    ]
  }

Here is the relevant portion of my config.xml

<engine name="android" spec="~6.3.0" />
    <engine name="ios" spec="4.5.4" />
    <plugin name="cordova-plugin-app-version" spec="^0.1.9" />
    <plugin name="cordova-plugin-device" spec="^1.1.4" />
    <plugin name="cordova-plugin-statusbar" spec="^2.2.1" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="ionic-plugin-deploy" spec="^0.6.7" />
    <plugin name="cordova-plugin-facebook4" spec="^1.9.1">
        <variable name="APP_ID" value="xxxxx" />
        <variable name="APP_NAME" value="xxxxxx" />
    </plugin>
    <plugin name="cordova-plugin-ionic" spec="^3.1.3">
        <variable name="APP_ID" value="xxxx" />
        <variable name="CHANNEL_NAME" value="Production" />
        <variable name="UPDATE_METHOD" value="background" />
        <variable name="MAX_STORE" value="2" />
        <variable name="WARN_DEBUG" value="true" />
        <variable name="UPDATE_API" value="https://api.ionicjs.com" />
    </plugin>
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="onesignal-cordova-plugin" spec="^2.3.1" />

I am aware that my version of @angular is a bit older but it runs fine and builds perfectly for android on my PC so it should build fine on Mac.

I found the problem with all the grace of a child who finally connects with a pinata. I started a new project on my virtual mac and made sure it built. Then I opened the old project and copied in every dependency and plugin which was not part of the new project. When I built, it failed. Good. Then I started removing half the plugings that remained. As long as it failed, I just kept removing.

The culprit was ionic-plugin-deploy which is a deprecated plugin.

When Ionic Pro came out, I installed the new cordova-plugin-ionic to use the new deploy method but I never thought that a deprecated plugin could cause the build to crash.

So the solution in this case:

ionic cordova plugin remove ionic-plugin-deploy

For those of you who are getting a similar problem, try the above mentioned solution of adding all your plugins to a blank project and removing each until you get a successful build.

2 Likes

@loki9182 Man, You saved me …!