Bhaskar
Bhaskar

Reputation: 91

Xcode 8: Archive build fails (for nested frameworks) with link errors. Regular build compiles successfully

EDIT Seems like the issue has been drilled down to the fact that it builds in debug mode but not in release mode. Still trying to understand why it builds in one and not the other

ORIGINAL ISSUE

I have a Xcode workspace with the following structure.

Workspace:

  1. UIProject
  2. FrameworkA
  3. FrameworkB

FrameworkB is nested in FrameworkA so FrameworkA is dependent on FrameworkB. Both are custom frameworks that I have created.

It builds and compiles fine. When I try to archive it, I get the following error:

Undefined symbols for architecture armv7:
  "ADI4ONS.Connection4ONS.connectionStat.getter : Swift.Bool", referenced from:
      type metadata for AircraftServices.connection in Connection.o
  "ADI4ONS.Connection4ONS.connectionStat.setter : Swift.Bool", referenced from:
      type metadata for AircraftServices.connection in Connection.o
  "ADI4ONS.Connection4ONS.connectionStat.materializeForSet : Swift.Bool", referenced from:
      type metadata for AircraftServices.connection in Connection.o
  "ADI4ONS.Connection4ONS.connectionString.getter : Swift.String", referenced from:
      type metadata for AircraftServices.connection in Connection.o
  "ADI4ONS.Connection4ONS.connectionString.setter : Swift.String", referenced from:
      type metadata for AircraftServices.connection in Connection.o
  "ADI4ONS.Connection4ONS.connectionString.materializeForSet : Swift.String", referenced from:
      type metadata for AircraftServices.connection in Connection.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Where ADI4ONS is frameworkB and AircraftServices is FrameworkA. Any help is welcomed.

Project/Target Configuration

  1. Bitcode is enabled
  2. Build Active Architecture only is set to NO ( tried 'Yes as well )
  3. Xcode 8 with swift 3.0

Experiments Tried Some of the things I've tried

  1. Tried setting Archive to Debug ( instead of the default Release in edit schema ) : NO LUCK

  2. Created a separate workspace for the UIProject and imported the frameworks binary into that . Archives successfully : WORKS GREAT ( but not what I want )

Upvotes: 4

Views: 1678

Answers (1)

Bhaskar
Bhaskar

Reputation: 91

Alright, After a ton of research and experimentation, here's my result.

So I figured out the parameter that was causing issues in Release mode build. It is the “Swift Compiler – Code Generation: Optimization Level”. It has three values

  1. None [-Onone]
    • Default value for debug
    • Also works for my release.
  2. Fast, Single-File Optimization [-O] -Works in Release
    • Most likely the value I’m going to set
  3. Fast , Whole Module Optimization [-O -whole–module-optimization]
    • Default value for release
    • This causes the break

I was trying to research more into the WMO but didn’t dig too deep into it. Seems like it was introduced in Xcode 7 .

Also my frameworks were both in Swift .

Upvotes: 3

Related Questions