[ionic] BUILD FAILED Error code 65 for command: xcodebuild with args…

使用指令:ionic cordova build ios

得到 Error:

ld: 165 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/myIonicAirWatch2.app/myIonicAirWatch2 normal x86_64

(1 failure)

(node:10536) UnhandledPromiseRejectionWarning: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/max/Documents/cordova/myIonicAirWatch2/platforms/ios/cordova/build-debug.xcconfig,-workspace,myIonicAirWatch2.xcworkspace,-scheme,myIonicAirWatch2,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone X,build,CONFIGURATION_BUILD_DIR=/Users/max/Documents/cordova/myIonicAirWatch2/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/max/Documents/cordova/myIonicAirWatch2/platforms/ios/build/sharedpch

(node:10536) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:10536) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

 

ionic 官方文章:Deploying to a Device
https://ionicframework.com/docs/intro/deploying/


解法,先刪掉 ios 目錄:

  1. rm -rf node_modules/ platforms/ios/
  2. npm i
  3. ionic cordova build ios

如果,我是  npm i 取顯示錯誤:

$ rm -rf node_modules/ platforms/ios/

max$ npm i

npm ERR! code E404

npm ERR! 404 Not Found: com.airwatch.awsdkplugin@~1.2.0

npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/max/.npm/_logs/2018-01-09T10_37_53_852Z-debug.log

 

應該是 airwatch-sdk-plugin 有檔案不見了,使用下面指令重新安裝:

$ npm i airwatch-sdk-plugin

npm WARN saveError ENOENT: no such file or directory, open ‘/Users/max/Documents/cordova/package.json’

npm WARN enoent ENOENT: no such file or directory, open ‘/Users/max/Documents/cordova/package.json’

npm WARN cordova No description

npm WARN cordova No repository field.

npm WARN cordova No README data

npm WARN cordova No license field.

+ [email protected]

added 1 package in 4.1s


這個指令很奇怪,好像會 cache, 發現在其他空的資料夾裡,也可以下,會下載一些檔案。如果有程式 lock 住的話,可能需要重開機再試一次,避免檔案被 lock 住,也有可能是 「權限」造成的,一般使用者和 root 使用者可以看到的scope 不同,所以使用 npm i 和 sudo npm i 結果會不同!

build 不成功,中間都有log 檔案,要看 log 檔裡寫什麼。


在 iOS 平台,如果有修改過 ionic 的 package name, 如果同步上有錯誤,請記得修改這3個檔案:
  • config.xml
  • /platforms/ios/ios.json
  • /plugins/ios.json

試了很久,還是試不出來,可能是中間有什麼設定檔被改壞掉,重新開一個專案:

ionic start myApp tabs

 

修改掉 config.xml 裡的 package id 。再加入我們有使用到plugin 例如:

ionic cordova plugin add airwatch-sdk-plugin

 

再重新 build iOS 一次:

ionic cordova build ios --prod

居然 build 成功了。

再把之前寫好的 /src/ 裡的檔案 copy 到新的專案裡,就搞定了。

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *