Our DNA is written in Objective-C
Jump

Radar: [Xcode] Enabling Extension-safe API check changes generated ObjC-Header

Normally you only need the “Allow app extension API only” for extension targets, to get warned if you are accessing API which is not available for extensions. I had enabled it for a framework to make sure I didn’t call forbidden API.

I found this issue at the same time as this other issue because my client complained about both problems: Not seeing any documentation via Quick Help as well as the generated header unnecessarily containing internal classes. This problem was already present in Xcode 8, as evidenced by somebody asking about it on Stack Overflow.

Filed as rdar://34790796 and on Open Radar. The mentioned sample is on my Radar Samples GitHub repo, titled InterfaceTest.

BSA Banner

Summary

For Swift-based frameworks/modules, Xcode generates an Objective-C header named Module-Swift.h. Ordinarily this only includes public classes. But if you turn on the “Allow app extension API only” setting, then also internal classes are included.

Steps to Reproduce

  1. Build the Module scheme of the provided sample app with Xcode 9
  2. Inspect the Module-Swift.h contained in the produced Module.framework
  3. You will see only the public classes CustomView and AncestorView
  4. Now turn on “Allow app extension API only” in the Module target build settings and build again
  5. Inspect the same header as in step 1.

Expected Results

  • The generated Objective-C header should be identical regardless of the state of this setting

Actual Results

  • With the setting off, only public classes are showing
  • With the setting on, you also see the internal class SwiftViewController

Version/Build

Xcode 9.0 (9A235)

Configuration

iMac or MacBook, with Xcode 9 and macOS 10.13


Categories: Bug Reports

2 Comments »

Trackbacks

  1. Radar: [Xcode] Enabling Extension-safe API check changes generated ObjC-Header – Techvibesnow

Leave a Comment

%d bloggers like this: