Cordova command-line build fails in /tmp on Mac

前端 未结 3 1950
遥遥无期
遥遥无期 2021-02-09 10:17

I get a linker error building a brand-new PhoneGap app from the command line. It creates a bunch of files, and if I open the created .xcodeproj in Xcode, it builds

相关标签:
3条回答
  • 2021-02-09 10:44

    I finally discovered the answer using the cordova command-line tools. Cordova has a -d flag which is way more verbose than PhoneGap's -V flag. The linker was failing with a bunch of errors like

    duplicate symbol _OBJC_METACLASS_$_CDVTimer in:
        /private/tmp/buildtest-ios/platforms/ios/build/emulator/libCordova.a(CDVTimer.o)
        /tmp/buildtest-ios/platforms/ios/build/emulator/libCordova.a(CDVTimer.o)
    

    Note that /tmp on Mac is a symlink to /private/tmp, so these are pointing to the same file. No wonder they're duplicate symbols! So why is it trying to include the same file twice?

    I tried creating a new test project in an empty folder /private/my-new-tmp2/buildtest-ios. Building it failed with the same error. So apparently something is weird with Cordova's iOS projects and the Ld linker in the /private directory on Mac OS X 10.9, and I'm the only person who's ever tried this. (As I said, building for Android works fine.)

    In case someone else ever runs into the same problem, the solution is to build the project in /Users/me/some/directory rather than anywhere in /tmp or /private. Problem solved.

    0 讨论(0)
  • 2021-02-09 10:59

    This may be because your framework references are corrupted or point to nowhere. In the left of XCode under 'Frameworks' and 'Resources' try re-adding anything you added yourself. Chances are with Cordova its a plugin SDK you are using that has been updated or deleted.

    0 讨论(0)
  • 2021-02-09 11:03

    I had a similar issue while placing my project under /var/www/PROJECT on mac. I was getting the duplicate errors along with "../cordova/build: Command failed with exit code 65".

    I was getting the duplicate errors because /var/www/ is also /private/var/www/

    Solution was to move my project as described above to /Users/username/some-other-dir/...

    I then ran phonegap run ios and all worked!

    0 讨论(0)
提交回复
热议问题