15

I have created a sample Framework in Swift, xcode 7.1. The framework is then built for Profiling, released version. Released framework then added(embedded) to an iOS test app.

The app builds fine, but when trying to archive it. An error occurs, stating "bitcode bundle could not be generated because '.../Test/FW.framework/FW' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build for architecture arm64"

The Framework and app projects are on default settings, Bitcode enabled for both.

To make sure Framework have bitcode, this command on Framework

"otool -l FW.framework/FW | grep __LLVM"

yields

segname __LLVM

segname __LLVM

segname __LLVM

segname __LLVM

What am I missing? I have included both projects here, you can download them and try archiving.

parveenkhtkr
  • 1,869
  • 1
  • 17
  • 33
  • seems the bitcode formats don't match. was the framework exported via archiving it? – Daij-Djan Nov 07 '15 at 09:19
  • No, just built it for Profiling, then found the FW.framework in "Release-iphoneos" along with a separate file "FW.framework.dSYM". – parveenkhtkr Nov 07 '15 at 09:21
  • How can I export it via archiving? When I archive the framework, it says build succeeded and nothing happens. Do I need to look for archived framework output file – parveenkhtkr Nov 07 '15 at 09:22
  • 2
    maybe building for archiving works too but to allow it to be put into an archive, set the build setting 'skip install to NO' – Daij-Djan Nov 07 '15 at 09:23
  • 1
    That did the trick, thanks! I was going insane over this. Please add the steps as answer, I will accept it. ( 'skip install to NO' on framework project, then archive, export with save built product and that Framework output file works with bitcode enabled) – parveenkhtkr Nov 07 '15 at 09:37

2 Answers2

37

xcode requires that bitcode for all embedded frameworks is generated during archiving.

Copying the release build of framework/dylib isn't enough

do
archive the framework and THEN use the archived version of the framework from then on.

to get xcode to archive a framework (normally it only archives apps), set the build setting 'skip install' to NO for the framework target!

Daij-Djan
  • 47,307
  • 15
  • 99
  • 129
  • It works, but not enough... Project now builds successfully with framework, but while uploading to iTunesConnect I receive an error... – saltwat5r Dec 16 '15 at 15:30
  • ` **An error occurred during validation** The archive did not contain as expected.` – saltwat5r Dec 16 '15 at 15:38
  • K. I'm lost. How do you produce it? Have you checked if it has module map at all? – Daij-Djan Dec 16 '15 at 15:57
  • The error occurred while uploading archive to iTunesConnect... [Additional error info screenshot](http://i64.tinypic.com/2v3ndcx.png) What do You mean with "checked if it has module map at all" ? – saltwat5r Dec 18 '15 at 09:33
  • The error says there is no ipa?! Can you export the archive as an ipa? – Daij-Djan Dec 18 '15 at 09:52
  • Unfortunately I can't export the archive as an ipa. There are also 2 alerts as in screenshots: [screenshots](http://imgur.com/a/Nycf4) – saltwat5r Dec 18 '15 at 10:27
  • Only working solution that I find is disabling bitcode. – saltwat5r Dec 18 '15 at 11:20
  • I've found workaround. In my framework target -> Build Settings, I've added User-Defined Setting called BITCODE_GENERATION_MODE with value "bitcode" as on [Screenshot](http://i.imgur.com/LlKjdPK.png). Finally after archiving, just use Fastlane tool called **Pilot** and archive is uploading to iTunesConnect successfully. – saltwat5r Dec 28 '15 at 13:16
  • 1
    Thanks, setting the SKIP INSTALL to NO worked since the framework has to have to BITCODE to NO for a store upload. Then can export the archive to framework and then copy / use that for the app. – ort11 Apr 27 '16 at 15:25
  • setting `enable bitcode` to `No`, in Build Settings, helped me. – Bohdan Savych Feb 07 '18 at 13:22
  • One more point, which wasn't explicitly stated, was to extract the .framework file from the .xcarchive. Embedding this .framework into my project allowed me to archive my project without generating the bitcode error. – ipje Oct 31 '18 at 18:06
  • Thank you so much man! It worked well with the archived version of framework. +1 for you – Vinoth Vino Apr 23 '19 at 13:09
35

You can make the following if you can build the framework (for example if you use your own framework)

enter image description here

This will allow your framework to provide the required bitcode.


Another alternative option may be applicable if you dont have watchOS and Apple TV (according to docs)

For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS and tvOS apps, bitcode is required.

this option require to set ENABLE_BITCODE for every target in buildSetting to NO, but as expected this forbid to use bitcode functionality.

More about bitcode here

hbk
  • 9,872
  • 9
  • 82
  • 110
  • I think this answer should also get some credit. With this approach, you do not have to run the framework through the archive process. – martin.code Dec 14 '16 at 16:47
  • this is a much better solution than the one that is the accepted answer. FYI to future people who might see this. – gikygik May 09 '17 at 14:51
  • This worked for me, Building as Archive Did not. on XCode 8.3 – Saumitra R. Bhave Sep 22 '17 at 14:55
  • Great answer. Worked for me, building as archive did not on XCode 9.0. – Sébastien Oct 09 '17 at 14:07
  • 1
    @Bem i have this issue : https://stackoverflow.com/questions/54437778/ios-mobilevlckit-archive-problems adding BITCODE_GENERATION_MODE helped in this case also? – ironRoei Jan 30 '19 at 10:13
  • @ironRoei I'm not really sure whether it will work in that case, but I suggest you to try it out. – Baran Emre Jan 30 '19 at 13:11
  • @gbk, I added BITCODE_GENERATION_MODE and it worked perfectly even with my ENABLE_BITCODE set to yes? Why dod you suggest i set it to NO ? Will i run into future problems ? – PhillipJacobs Dec 02 '19 at 09:04