简体   繁体   中英

xcodebuild archive generates malformed xcarchive when adding custom build settings

I'm trying to generate an xcarchive using xcodebuild that I can later export as an .ipa using the new functionality added with Xcode 5.

This works perfectly fine:

xcodebuild -workspace 'MyWorkspace.xcworkspace' -scheme 'MyScheme' -configuration 'Release' -archivePath tmp.xcarchive archive
xcodebuild -exportArchive -exportFormat IPA -archivePath tmp.xcarchive -exportPath app.ipa -exportWithOriginalSigningIdentity

But as soon as I add custom build settings to the archive command:

-derivedDataPath build SYMROOT=build/build.sym DSTROOT=build/build.dst OBJROOT=build/build.obj SHARED_PRECOMPS_DIR=build/build.pch

The .xcarchive generated is empty, but there is no error.

Any ideas?

For me, this had to do with the Installation Directory Deployment Build Setting in Xcode: CMake somehow set this to "" , ie an empty string, when it should have been "/Applications" , the Xcode default. For me, setting it to anything else than "/Applications" caused the resulting archive to be empty and therefore 'malformed'.

So maybe your project somehow did not have Installation Directory set to "/Applications" , either because of CMake or something else.

To set this using CMake, add this to your target properties:

set_target_properties(${MODULE} PROPERTIES
     ...
     XCODE_ATTRIBUTE_INSTALL_PATH "/Applications"
     ...
)

For me this error happened when I had no space left on the drive where I tried to create the archive. But I could not tell that from the errors int he console

In my case the 'archivepath' directory/file path was incorrectly set in previous steps, and it was looking into a directory which did not have .xcarchive file. Worth checking manually the paths and if the archive file exists in the directory

就我而言,我在路径末尾错过了.xcarchive扩展。

xcodebuild -exportArchive -archivePath /<path_to_archive>/file.xcarchive ...

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