Xcodegen: How to add .a files (static libraries)

Created on 8 Mar 2020  路  6Comments  路  Source: yonaskolb/XcodeGen

I have two files named libepos2.a and libeposeasyselect.a that I need to import them and link them into my project.

This is how I am adding them:

 - framework: MyProject/External/libs/libepos2.a
   embed: false
- framework: MyProject/External/libs/libeposeasyselect.a
   embed: false  

However, I found out that xcodegen is adding them to my project's Copy bundle resources phase:
Screen Shot 2020-03-08 at 12 31 54

which causes an issue when uploading a binary to the App Store:

ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'MyApp.app/libeposeasyselect.a' is not permitted. Your app can鈥檛 contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure."

The fix was by manually removing the two files (libepos2.a and libeposeasyselect.a) from the project's Copy bundle resources phase.

I think I am missing something in integrating static libraries inside my project.

Most helpful comment

Your first path would include them, since it will be recursive, so you need the exclude there instead. excludes uses glob rules, so you probably want something like:

    sources:
      - path: ProjectApp
        excludes:
          - "**/*.sh"
          - "**/*.a"

All 6 comments

You need to exclude those files from your sources, they are being found that way and the default for an unknown extension is to put it in Resources.

Hello @brentleyjones, I did the following but they still there?

    sources:
      - path: ProjectApp
        excludes:
          - "*.sh"
      - path: ProjectApp/External/libs
        excludes:
          - "*.a"

Also, what do you mean with:

put it in Resources

Your first path would include them, since it will be recursive, so you need the exclude there instead. excludes uses glob rules, so you probably want something like:

    sources:
      - path: ProjectApp
        excludes:
          - "**/*.sh"
          - "**/*.a"

the default for an unknown extension is to put it in Resources

By this I mean, if XcodeGen sees a file with an unknown extension, it will assume that it's a resource, and put it in the Copy Bundle Resources step.

@brentleyjones Many thanks, it is working now.

You're welcome!

Was this page helpful?
0 / 5 - 0 ratings