8

I have a fairly old project with a minimum deployment target set to iOS 8.4. For technical reasons bitcode must be enabled. The project builds and runs fine. When trying to export an archived build however, things go wrong. I am using Xcode 8.2.1.

When I create a test build (signed with Enterprise certificate) with the option Rebuild from bitcode enabled, the export fails at the stage when it is compiling bitcode.

Screenshot bitcode setting

Screenshot export error

Here is the relevant part of the log:

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.ios.a" "-o" "/private/var/folders/qy/cgq_nq7x2tx1j3z__7f4yx100000gn/T/<redacted target name>WX9bPu/<redacted target name>.armv7.out" 
    -= Output =-
    Undefined symbols for architecture armv7:
      "_llvm_gcov_init", referenced from:
          __hidden#2_ in 001.o
          __hidden#3_ in 001.o
          __hidden#4_ in 001.o
          __hidden#5_ in 001.o
          __hidden#6_ in 001.o
          __hidden#7_ in 001.o
          __hidden#8_ in 001.o
          ...
      "_llvm_gcda_end_file", referenced from:
          __hidden#0_ in 001.o
          __hidden#0_ in 002.o
          __hidden#0_ in 003.o
          __hidden#0_ in 004.o
          __hidden#0_ in 005.o
          __hidden#0_ in 006.o
          __hidden#0_ in 007.o
          ...
      "_llvm_gcda_emit_function", referenced from:
          __hidden#0_ in 001.o
          __hidden#0_ in 002.o
          __hidden#0_ in 004.o
          __hidden#0_ in 005.o
          __hidden#0_ in 006.o
          __hidden#0_ in 007.o
          __hidden#0_ in 008.o
          ...
      "_llvm_gcda_emit_arcs", referenced from:
          __hidden#0_ in 001.o
          __hidden#0_ in 002.o
          __hidden#0_ in 004.o
          __hidden#0_ in 005.o
          __hidden#0_ in 006.o
          __hidden#0_ in 007.o
          __hidden#0_ in 008.o
          ...
      "_llvm_gcda_start_file", referenced from:
          __hidden#0_ in 001.o
          __hidden#0_ in 002.o
          __hidden#0_ in 003.o
          __hidden#0_ in 004.o
          __hidden#0_ in 005.o
          __hidden#0_ in 006.o
          __hidden#0_ in 007.o
          ...
      "_llvm_gcda_summary_info", referenced from:
          __hidden#0_ in 001.o
          __hidden#0_ in 002.o
          __hidden#0_ in 003.o
          __hidden#0_ in 004.o
          __hidden#0_ in 005.o
          __hidden#0_ in 006.o
          __hidden#0_ in 007.o
          ...
    ld: symbol(s) not found for architecture armv7
    Exited with 1
    
    
    error: Failed to compile bundle: /var/folders/qy/cgq_nq7x2tx1j3z__7f4yx100000gn/T/<redacted target name>WX9bPu/<redacted target name>.armv7.xar
    

Stderr:
>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:202:in `run'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1987:in `block in CompileOrStripBitcodeInBundle'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1944:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:1944:in `CompileOrStripBitcodeInBundle'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2119:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2687:in `<main>'";
            info =             {
            };
            level = ERROR;
            type = exception;
        }
    );
    thinnableAssetCatalogs =     (
        "/var/folders/qy/cgq_nq7x2tx1j3z__7f4yx100000gn/T/XcodeDistPipeline.hn6/Root/Payload/<redacted target name>.app/Assets.car"
    );
}
2017-03-31 12:21:37 +0000 [MT] Exporting using IDEDistributionPackageExportStep
2017-03-31 12:21:58 +0000 [MT] Canceled distribution assistant

When I disable Rebuild from bitcode, the export is successful and the resulting build runs fine. I'm afraid this will give problems when the build will be submitted to iTunes Connect however.

Does anyone have a clue why this error occurs and how to fix this? I'm a bit at a loss here.


Edit:

To clarify: yes, bitcode is enabled at the target level. Here are the linked libraries:

Screenshot of linked libraries

These are the dependencies:

# Reporting
pod 'Fabric'
pod 'Crashlytics'
pod 'GoogleAnalytics'
pod 'CocoaLumberjack', '~> 1.6.2'

# Networking
pod 'AFNetworking', '~> 2.6.3'
pod 'RestKit', '~> 0.27'
pod 'Reachability'

# Other
pod 'UIColor-Utilities', '~> 1.0.1'
pod 'ViewDeck', '~> 2.4'
pod 'SDWebImage', '~> 3.7.0'
pod 'AMRatingControl', '~> 1.3.0'
Community
  • 1
  • 1
Kymer
  • 1,094
  • 7
  • 19
  • I am also getting same. is it fixed for you? – Gajendra Rawat Mar 31 '17 at 14:23
  • No not yet. If I get it resolved I'll post it as an answer to my question. Let me know if you find some relevant info. – Kymer Apr 03 '17 at 15:59
  • Is bitcode activated at the target level? Do you have any static libraries in your project? – Nicolas Braun Apr 03 '17 at 22:07
  • In my case I am using project (iOS + tvOS (3 target for each)) & few 3rd party Libraries using cocoa pod. I am getting this error "iTunes Store operation failed. Invalid Mach-O Format. The Mach-O in bundle “Project.app/Frameworks/SOCKit.framework" isn’t consistent with the Mach-O in the main bundle. The main bundle Mach-O contains arm64(machine code), while the nested bundle Mach-O contains arm64(bitcode). Verify that all of the targets for a platform have a consistent value for the ENABLE_BITCODE build setting." – Gajendra Rawat Apr 04 '17 at 07:29
  • @NicolasBraun: Yes, bitcode is enabled at the target level. See my edited post to see the list of linked libraries. Could it be a compatibility issue with one of the (old) dependencies? – Kymer Apr 05 '17 at 06:55
  • Do you archive the project with an AdHoc / AppStore Provisioning Profile? – Sven Driemecker Apr 06 '17 at 13:32

2 Answers2

1

After some trial and error and by the helpful suggestions by Sven Drielecker (and others) the issue has ben fixed.

The GCC_INSTRUMENT_PROGRAM_FLOW_ARCS build setting was set to YES for both debug and release builds. Turning it off for release has fixed the issue.

Kymer
  • 1,094
  • 7
  • 19
0

I tried to reproduce your problem but without success. Just by the naming of the missing symbols these seem to have some relation to code coverage stuff. You could try to disable everything thats related to code coverage in your project and then re-archive and -export it again:

Scheme settings:

enter image description here

Target build settings: enter image description here

Sven Driemecker
  • 3,241
  • 1
  • 18
  • 22
  • Hey Sven, sorry for getting back to you so late. I have tried your suggestion but the export unfortunately fails at the same step with the same error. – Kymer Apr 20 '17 at 18:59