1

I am attempting to submit a cocoapod written in Swift that contains the following code method intended to prevent execution of specific code when targeting a simulator:

func isDevice() -> Bool {
    #if (arch(i386) || arch(x86_64)) && os(iOS)
        return false
    #endif

    return true
}

While XCode finds this acceptable, and I can suppress the warning from pod lib lint with the --allow-warnings flag, attempting to submit the pod will still fail.

This code produces the warning warning: code after 'return' will never be executed.

CodeBender
  • 35,668
  • 12
  • 125
  • 132

1 Answers1

2

The mistake I made was that while the source of this answer is solid, I did not properly implement the conditional check.

Below is the proper way to do it to avoid issues with the Cocoapod validation:

func isDevice() -> Bool {
        #if (arch(i386) || arch(x86_64)) && os(iOS)
            return false
        #else
            return true
        #endif
    }

By placing the check inside the #if...#endif, I was able to avoid the warning.

Community
  • 1
  • 1
CodeBender
  • 35,668
  • 12
  • 125
  • 132