Xcode 9 and Xcode 10 Giving Different Results, Even with Same Swift Version

Xcode 9 and Xcode 10 giving different results, even with same swift version

That is an undocumented way to get a sequence of all enumeration values,
and worked only by chance with earlier Swift versions. It relies on the
hash values of the enumeration values being consecutive integers,
starting at zero.

That definitely does not work anymore with Swift 4.2 (even if running
in Swift 4 compatibility mode) because hash values are now always
randomized, see SE-0206 Hashable Enhancements:

To make hash values less predictable, the standard hash function uses a per-execution random seed by default.

You can verify that with

print(NumberEnum.one.hashValue)
print(NumberEnum.two.hashValue)

which does not print 0 and 1 with Xcode 10, but some
other values which also vary with each program run.

For a proper Swift 4.2/Xcode 10 solution, see How to enumerate an enum with String type?:

extension NumberEnum: CaseIterable  { }
print(Array(NumberEnum.allCases).count) // 4

Why get wrong hashValue from Enum from Xcode 10? Is it Apple's bug?

Thanks for all guys's answer. As rmaddy's said the document as below:
Sample Image

So do not use hashValue during a future execution.

What versions of Swift are supported by what versions of Xcode?

Since I've been gathering data and doing tests, I'll post my results as an updated chart in this answer:

A chart depicting the different versions of Swift as compared to their respective versions of Xcode. Last updated 2020-02-25

Awhile ago, I found out that newer versions of Xcode do not, in fact, support migrating from all older versions of Swift. I did explicitly test that Xcodes 10.2 through 11 don't support Swift 3.x and earlier, so I colored those white. I've not yet had time to test Xcode 8.3 through 10.1, but I suspect they will migrate 3.x but not 2.x or earlier; that's why there's a big "Unknown" block at the top.



Sources

  • Manual testing with this test code: https://github.com/BenLeggiero/Swift-Version-Checker
  • Xcode Release Notes
  • Swift Release Notes

Crashlytics and Xcode 10

I fixed the problem by going into Build Settings, changing Debug Information Format from "DWARF" to "DWARF with dSYM File" and building the project again.

Xcode 9 Autocomplete Not Working 100% - Partially Working

Deleting the DERIVED DATA folder seemed to fix my issue. Thanks to this post: swift println() not showing autocomplete options while writting code

CoreML model yields different results between coremltools and Xcode

Your Core ML output on device: [0.000139, 0.000219, 0.003607]

Your output from coremltools: [0.00021577, 0.00031877, 0.0035404]

Note that these are very small numbers. When Core ML runs your model on the GPU (and possibly on the Neural Engine, not sure) it uses 16-bit floating point. These have much smaller precision than 32-bit floating point.

Note how 0.000139 and 0.00021577 are not the same number but they are both around 1e-4. This is below the precision limit of 16-bit floats. But 0.003607 and 0.0035404 are almost the same number, because they're about 10x larger and therefore don't lose as much precision.

Try running your Core ML model on the device using the CPU (you can pass an option for this when instantiating your model). You'll probably see that you now get results that are much closer (and probably identical) to the coremltools version, because Core ML on the CPU uses 32-bit floats.

Conclusion: from what you've shown so far, it looks like your model is working as expected, taking into consideration you will lose precision due to the computations happening with 16-bit floating points.



Related Topics



Leave a reply



Submit