Questions tagged [swift4]

Use this tag only for questions directly related to changes in version 4 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc. for questions about developing on Apple platforms.

Swift 4 is the fourth version of the Swift language developed by Apple that was released in 2017. The language is open source and available on Github (see ).

The development of Swift 4 and its goals can be viewed on the Swift Programming Language Evolution repository on GitHub.

5684 questions
2
votes
0 answers

Segmentation fault in Swift compiler when converting to Swift 4 syntax

I have some Swift code that was written in Swift 3.2, and I just attempted to use the automatic syntax converter in Xcode 9.0 to update to Swift 4.0. It actually found nothing that needed to be converted, but during the code analysis when the…
CPR
  • 753
  • 8
  • 19
2
votes
0 answers

how to convert Range to NSRange in swift 4

This is my swift 3 code: extension String { func nsRange(from range: Range) -> NSRange { let lower = UTF16View.Index(range.lowerBound, within: utf16) let upper = UTF16View.Index(range.upperBound, within: utf16) …
chetan panchal
  • 181
  • 2
  • 11
2
votes
2 answers

How decode windowsCP1251 percent encoded String ? Swift 4 ios 11

How to decode String from percent encoded windowsCP1251? replacingPercentEscapes(using: String.Encoding.windowsCP1251) now is obsolete removingPercentEncoding uses utf8
user3672430
  • 106
  • 1
  • 5
2
votes
2 answers

'pod spec lint' fails after project conversion to Swift 4

After converting my cocoa framework project to Swift 4 the class UIFontDescriptorFamilyAttribute is now UIFontDescriptor.AttributeName.family, so I changed my code from: // Swift 3 UIFontDescriptor(fontAttributes:…
juliancadi
  • 987
  • 1
  • 8
  • 23
2
votes
2 answers

Getting user's location not working after Swift 4 update

I've just updated to the Xcode 9 and Swift 4 and it has broken at lot of my functions. One of which being how I get the user's location, zoom in on it on launch, detecting annotation selection and various other tasks. They don't work at all. My view…
Max Kortge
  • 527
  • 7
  • 23
2
votes
1 answer

UISearchBar and Two buttons in the Navigation Controller

I am trying to add two buttons and a SearchBar to my navigation controller but the alignment is not correct. I have tried almost everything such as changing the size of SearchBar, UIButton or changing the Y positioning but it didn't work. Any idea…
Persian
  • 294
  • 2
  • 10
2
votes
1 answer

Migrate my pod to Swift 4

I created my pod in Swift 3 and now I wanna migrate it to Swift 4. I've already done the code migration in the Example project (I chose to create an example when running pod lib create), but my podspec is still not passing validation. One of the…
Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75
2
votes
1 answer

Property @IBInspectable cannot be marked

how to fix this problem, after installing xcode 9 show me this "Property cannot be marked @IBInspectable because its type cannot be representing in Objective-c" /// The mode of the gradient. The default is `.Linear`. @IBInspectable open var mode:…
user4163161
2
votes
1 answer

Add Navigation Bar in UICollectionView in swift 4, iOS 11

After upgrading the iOS 11 and swift 4(Xcode 9), I got lots of UI problem. :( The most unsolvable problem is Navigation Problem. I put the Navigation Bar in UICollectionView Controller. Navigation bar height does not show properly and however I…
May Phyu
  • 895
  • 3
  • 23
  • 47
2
votes
1 answer

Xcode 9, iOS 11, XCUITest failure: Main Thread Checker Flurry Analytics

Running my suite of XCUITests using Xcode 9 running on iOS 11. Tests all run perfect in Xcode 8 (iOS10), but in Xcode 9 I get the following error: Main Thread Checker: UI API called on background thread [UIApplication statusBarOrientation]... ...…
Charlie S
  • 4,366
  • 6
  • 59
  • 97
2
votes
1 answer

Swift - UIViewControllerAnimatedTransitioning not transform as expected with Swift4

I just upgraded to XCode9 with Swift4 today. And I found that my UIViewControllerAnimatedTransitioning doesn't work as expected anymore. The effect of this animation is that the fromView will scale down to 0.95 and the toView will slide in from the…
Kimi Chiu
  • 2,103
  • 3
  • 22
  • 37
2
votes
1 answer

Swift 4 statically get value of model property name

When using Swift 3, I was defining my model like so class Model: NSObject { var prop1: String } When I wanted to access the static string value of the property name prop1, I would use let sad = #keyPath(Model.prop1) and it would give me…
Harry Bloom
  • 2,359
  • 25
  • 17
2
votes
2 answers

Convert Data to DispatchData in Swift 4

I am migrating a project to Swift 4 and I cannot figure out how I am supposed to use the new API:s to do this in Swift 4. The following code is the old Swift 3 way (from the middle of a function hence the guard): let formattedString = "A…
Alex
  • 731
  • 1
  • 11
  • 24
2
votes
1 answer

Combine SIL Instructions via Peephole Optimization in Swift 4

When I archive project for the App Store, I have an error Segmentation fault 11 1. While running pass #317780 SILFunctionTransform ""Combine SIL Instructions via Peephole Optimization"" on SILFunction…
Alexander Khitev
  • 6,417
  • 13
  • 59
  • 115
2
votes
2 answers

Segmentation fault when converting to Swift 4

I am in the process of updating a project to iOS 11/Swift 4. I have updated to Swift 3.2 and have a project that builds with one warning: "Conversion to Swift 4 available". So I click the warning and start the migration assistant with the option…
Alex
  • 731
  • 1
  • 11
  • 24