简体   繁体   中英

Cordova CLI "cordova build android" error "Does not appear to be an xcode project, no xcode project file in..."?

I am trying to locally compile my Cordova app from my Windows machine. I have been able to do this fine until I came back after the holiday and now when I run the cli "cordova build android" I get the response:

Does not appear to be an Xcode project, no Xcode project file in....

What does Xcode have to do with building an Android app? I am technically compiling for both but I do the iOS app on a mac (which runs fine).

Does anyone know what has happened?

For me, removing and re-adding the android platform would allow me to build or run the project once but then on any subsequent build or run attempts the issue would appear again.

I determined that the Android file platforms/android/app/src/main/res/xml/config.xml was getting overwritten during the build phase to an empty/default version of it, which made sense because from debug logging it appeared to be failing after this step:

Generating platform-specific config.xml from defaults for android at /Users/groot/Projects/software-verde/litter-quality-propane/platforms/android/app/src/main/res/xml/config.xml

Ultimately this led me to realize that the issue was pulling information in from my main config.xml and that it was these lines that I had previously added for iOS that were causing the problem:

    <config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
        <string>This app would like to access your photo library.</string>
    </config-file>
    <config-file parent="NSLocationAlwaysUsageDescription" platform="ios" target="*-Info.plist">
        <string>This app would like to access your location, even when the app is not in use.</string>
    </config-file>
    <config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
        <string>This app would like to access your location while the app is in use.</string>
    </config-file>

Since these config file changes are only relevant to iOS, the solution was to wrap it in a platform tag:

<platform name="ios">
    [...]
</platform>

I'm guessing this could happen with other tags like this that are iOS-specific but that are not explicitly wrapped in a platform tag. It seems that Cordova is still trying those changes to Android builds but then obviously isn't able to because it isn't an iOS project.

I had to remove the android platform again and try to remove a (none existing) ios platofmr. I then re-added the platform and it built correctly. But when I run "cordova emulate android" I still get the error.

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