Xcode 14 beta: How to fix errors in Widget Custom Intents? - ios

I opened the "Emoji Rangers App Xcode project created by Apple [click to download]" for the demo of WidgetKit and wanted to follow up with WWDC22 video.
However, while it worked fine in Xcode 12, when I opened this project in Xcode 13 beta, I got errors like this:
Method 'provideHeroOptionsCollection(for:)' with Objective-C selector 'provideHeroOptionsCollectionForDynamicCharacterSelection:withCompletion:' conflicts with method 'provideHeroOptionsCollection(for:with:)' with the same Objective-C selector; this is an error in Swift 6
Method 'confirm(intent:)' with Objective-C selector 'confirmDynamicCharacterSelection:completion:' conflicts with method 'confirm(intent:completion:)' with the same Objective-C selector; this is an error in Swift 6
Method 'handle(intent:)' with Objective-C selector 'handleDynamicCharacterSelection:completion:' conflicts with method 'handle(intent:completion:)' with the same Objective-C selector; this is an error in Swift 6
Please help me - how can I fix it?
BTW it's in the DynamicCharacterSelectionIntent.swift file, which says:
// This file was automatically generated and should not be edited.

You can use the Adding widgets to the Lock Screen and watch faces example project which extends the project you want.
However, while it worked fine in Xcode 12, when I opened this project in Xcode 13 beta, I got errors like this
You'll need Xcode 14 beta to run it. I don't really understand why would you use Xcode 13 beta these days – it was released a year ago.

Related

Swift warning in Xcode 14 : Method confirm(intent:) conflicts with method confirm(intent:completion:) with the same Objective-C selector

Testing the new widget for iOS 16 with Xcode 14, I'm facing an issue trying to port the iOS 14 widget with the new WidgetFamily like .accessoryInline or .accessoryRectangular.
After adding conditional macros to solve some errors in order to build for watchOS and iOS (cf Apple WWDC 22 video: https://developer.apple.com/videos/play/wwdc2022/10050/), Xcode display no red errors but yellow blocking warnings:
Method 'confirm(intent:)' with Objective-C selector
'confirmConfiguration:completion:' conflicts with method
'confirm(intent:completion:)' with the same Objective-C selector; this
is an error in Swift 6
Any idea how to solve it?
EDITED : Finally works without fix that, see answer below. But I'm still interesting to remove this warning.
Finally, it passed without fixing this warning. I remove the last errors around the extension bundle name (has to be prefixed with the watch app bundle and follow by ".xxxxxx" of your choice without any further dot). I also had a "4" (Apple Watch) value to "Targeted Device Families" in build settings (was previously "1,2" for iPhone, iPad).

iOS 13 - FileManager url(forPublishingUbiquitousItemAt:expiration:) not working anymore

I've developed an iOS app that uses the url(forPublishingUbiquitousItemAt:expiration:) method of Apple's FileManager class. Starting with the first Beta of iOS 13 this function stopped working and now it throws an error, stating "This code has been removed. You should switch off of this SPI". But I can't find anything related to this function neither in the release notes of iOS nor in the documentation for this function, and it even states there that it would be supported on Mac Catalyst 13.0+.
This also has nothing to do with Xcode 10 and 11, as it occurs when the app is built using either one of those versions.
Does anyone of you know more about that? It would be great to get new information on that.
Thanks,
Fabian.
This is fixed in iOS 13 beta 6. Updated today and this error magically disappeared!
Had my mind blown when I saw this error message.

xcode 8 beta - Error compiling to the real iOS device

I couldn't find any related topic so I am starting the new one.
I have macOS Sierra and latest xcode 8.
When I attach my iPhone to macbook and try to build even clean project in xcode I get following swift compiler errors:
Attempting to use the forward class 'UIViewController' as superclass of 'UIActivityViewController'
Attempting to use the forward class 'UIViewController' as superclass of 'UIAlertController'
And so on. Error count is 21 and is always same no matter what project I choose.
Someone have same problem? Any solution?
Thanks for any answer.

How to fix the ratingControl class in iOS Xcode app Food Tracker?

ratingControl class error
How do I fix the errors that happen with this line of code? I've tried everything. Thank you.
Your code uses Swift 2.2 syntax, which is available from Xcode 7.3.
See Xcode 7.3 release notes for more details https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html
The Objective-C selector of a Swift method can be determined directly with the #selector expression, for example:
let sel = #selector(insertSubview(_:aboveSubview:)) // sel has type Selector
So the answer to your question - you need to update your Xcode from 7.2 to 7.3 version, and the error will go away.
If you don't want to update Xcode - use an old selector syntax, for example:
selector: "ratingButtonTapped"

How to detect if I am accessing iOS6-only methods? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a way for XCode to warn about new API calls?
I'm building an app that will support iOS 4.3 through iOS 6.x. However, I unknowingly used a method that is marked __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0). This means that the selector does not exist in previous versions of iOS.
Of course, when I tested my code on an iOS 5.x device, the app crashed. I figured out what was going on, and inserted a respondsToSelector check, and default to the "iOS 4.x way" of doing things when it fails this check.
How can I prevent these bugs in the future? Is there a compile-time way to figure out that I am accessing iOS-6-only methods, so that I can add appropriate iOS feature-checks?
I don't want to accidentally ship a product that works fine on my iOS6 devices, only to have it fail on someone's iOS4.3 device, because the selector does not exist.
The answer here worked for me: https://stackoverflow.com/a/8919108/208989
Download this header: https://github.com/mattjgalloway/MJGFoundation/blob/master/Source/Utilities/MJGAvailability.h
And put the following at the top of your .pch file:
#define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_4_3
#import "MJGAvailability.h"

Resources