1

I'm calling an Objective-C method in my swift 2.3 code in Xcode 8.2 (build target 8.0). It accepts an NS_ENUM as a parameter:

typedef NS_ENUM(NSUInteger, MLCMultipleChoiceSlideSubtype) {
  MLCMultipleChoiceSlideSubtypeQA,
  MLCMultipleChoiceSlideSubtypeFillInTheBlank,
  MLCMultipleChoiceSlideSubtypeUnknown
};

The .h file containing this enum and method is in my bridging-header.h file. This is the signature of the objc method:

+ (nullable instancetype)slideWithSubtype:(MLCMultipleChoiceSlideSubtype)subtype testSlide:(nonnull TestSlide *)slide distractorFinder:(nonnull MultipleChoiceDistractorFinder *)distractorFinder;

Then I call it from Swift 2.3 like this:

if let mcSlide = MultipleChoiceSlide(subtype: .QA, testSlide: slide, distractorFinder: distractorFinder) {
    return mcSlide
}

This works fine when I compile it for debug and run it. However, when I try to archive it and compile for release, I get this message:

  ... LessonConvertToMultipleChoiceOperation.swift:55:64: Static member 'QA' cannot be used on instance of type 'MLCMultipleChoiceSlideSubtype'

I have no idea why this only happens when I archive the build or what to do to fix it.


Edit: Based on answers to similar problems I saw elsewhere, I changed the archive build configuration from Release to Debug in my scheme, and now it archives. This doesn't seem like a good thing to do however. Will the archive contain my debug symbols by doing this?

  • It sounds like something being present on your system, but not properly in compile sources. I am not an expert on this matter at all though. – Sethmr Mar 31 '17 at 21:04
  • This is very difficult to answer without seeing the whole project. Look for differences between "Debug" and "Release" configurations. Maybe something that is needed is wrapped inside `#ifdef DEBUG`? guard? – Sulthan Apr 01 '17 at 07:14

1 Answers1

0

It turns out that I needed to call the method like this:

if let mcSlide = MultipleChoiceSlide.init(subtype: .QA, testSlide: slide, distractorFinder: distractorFinder) {
   return mcSlide
}

Although I'm not sure why adding .init helps.

Clue found here

Community
  • 1
  • 1