Build ios --release fails with error code 65


#1

I was not able to build my ios app with

sudo ionic cordova build ios --release --minifyjs --optimizejs --minifycss

Also only using --release for example does not work. I get this error:

:heavy_multiplication_x: Running command - failed!
[ERROR] An error occurred while running cordova build ios --release (exit code

    1):
    
    (truncated) ... d/emulator/libCordova.a(CDVLogger.o)
    duplicate symbol _OBJC_METACLASS_$_CDVLogger in:
         
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech 
    Support.build/Release-iphonesimulator/Sitech 
    Support.build/Objects-normal/x86_64/CDVLogger.o
         
    /Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
    ld: 2 duplicate symbols for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see 
    invocation)
    
    Ld 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/i386/Sitech\ Support normal i386
         cd /Users/cas/Documents/sitechappV2/sitechApp/platforms/ios
         export IPHONEOS_DEPLOYMENT_TARGET=9.0
         export 
    PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
         
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 
    -arch i386 -isysroot 
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk 
    -L/Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator 
    -F/Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator 
    -filelist 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/i386/Sitech\ Support.LinkFileList -Xlinker 
    -rpath -Xlinker @executable_path/Frameworks 
    -mios-simulator-version-min=9.0 -dead_strip -Xlinker -object_path_lto 
    -Xlinker 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/i386/Sitech\ Support_lto.o -Xlinker 
    -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime 
    -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator 
    -Xlinker -add_ast_path -Xlinker 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/i386/Sitech_Support.swiftmodule -ObjC 
    -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ Support.build/Sitech\ 
    Support.app.xcent 
    /Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator/libCordova.a 
    -framework MediaPlayer -framework AVFoundation -framework JavaScriptCore 
    -Xlinker -dependency_info -Xlinker 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/i386/Sitech\ Support_dependency_info.dat -o 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/i386/Sitech\ Support
    duplicate symbol _OBJC_CLASS_$_CDVLogger in:
         
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech 
    Support.build/Release-iphonesimulator/Sitech 
    Support.build/Objects-normal/i386/CDVLogger.o
         
    /Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
    duplicate symbol _OBJC_METACLASS_$_CDVLogger in:
         
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech 
    Support.build/Release-iphonesimulator/Sitech 
    Support.build/Objects-normal/i386/CDVLogger.o
         
    /Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator/libCordova.a(CDVLogger.o)
    ld: 2 duplicate symbols for architecture i386
    
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	Ld 
    /var/root/Library/Developer/Xcode/DerivedData/Sitech_Support-ciaapkfmwnuajwfhlpxsmqnblovk/Build/Intermediates/Sitech\ 
    Support.build/Release-iphonesimulator/Sitech\ 
    Support.build/Objects-normal/x86_64/Sitech\ Support normal x86_64
    (1 failure)
    Error: Error code 65 for command: xcodebuild with args: 
    -xcconfig,/Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/cordova/build-release.xcconfig,-workspace,Sitech 
    Support.xcworkspace,-scheme,Sitech 
    Support,-configuration,Release,-sdk,iphonesimulator,-destination,platform=iOS 
    Simulator,name=iPhone 
    SE,build,CONFIGURATION_BUILD_DIR=/Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/cas/Documents/sitechappV2/sitechApp/platforms/ios/build/sharedpch

Does someone know how to fix this? When using

ionic cordova platform remove ios
ionic cordova platform add ios

I will get an xcode project, but this one is not optimized for the build and thus slower.