"UserNotificationsUI" is not available when building for UIKit for Mac error - ios

My app has Service & Content Extension Notifications targets for
supporting Rich Remote Notifications which work as expected on
iPad/iPhone iOS 13 & below
I have installed Xcode 11-beta & macOS Catalina 10.15-beta
On building with the new UIKitForMac I get the following error -
"UserNotificationsUI" is not available when building for UIKit for
Mac. You may need to restrict the platforms for which this framework
should be linked in the target editor.
First tried adding #if canImport() ... #endif around instances of UserNotificationsUI which didn't work
Then removed the Extension Targets which is also not working.
Anyone facing a similar issue?

A closed source Third party framework that I was using had UserNotificationsUI linked.
The build error was because UIKitForMac doesn't support Mobile specific frameworks like UserNotifications which is the correct behaviour.
Removing the Third Party dependency resolved the issue for me.

Related

How can I properly share the Amplify framework with my Main App and my App Extension for an iOS app?

I have an iOS app using AWS amplify for the backend. I am using Xcode 13 and SwiftUI.
I previously added the Amplify framework using Cocoapods however I was unable to get the framework to work with the extension.
So I recently switched to Swift Package Manager. I added the package to my main project. Then I went to my Share Extension and in General - Frameworks and Libraries and manually added the libraries.
After doing this the app builds and runs and both the main app and extension work fine and are able to use the libraries.
The problem is that I cannot archive and upload the app to the App Store. I get the following error:
CFBundleIdentifier Collision. There is more than one bundle with the
CFBundleIdentifier value 'com.amazonaws.AWSAuthCore' under the iOS
application 'MyAPP.app'. With error code
STATE_ERROR.VALIDATION_ERROR...
I went on many forums and spent many hours trying to fix this but to no avail. The suggestions are to click 'do not embed' for the libraries but that option is not available for me.
I wonder if there is anyway to resolve this?
Below are my General and Build Phases for the Share Extension:
Just remove explicit Amplify dependency from extension, ie. next section should be empty
Make sure (it should be automatically, but anyway)
Link Frameworks Automatically parameter (in Build Settings) is true
Runpath Search Path parameter is related to main bundle
So as targets from SPM are built in same location as product and extension and automatic framework linking is enabled the imported modules in extension will available and linked automatically and due to run paths are set the frameworks will be found in run-time as well.
Note: of course in main app target all should be included
Tested with Xcode 13.1 / iOS 15.1

AVFAudio Framework not present on macOS causes warning for iOS app (app should also be available on AS Macs)

My iOS app uses the AVFAudio framework to provide spoken feedback to the user while running. I would like this app to also run on Apple Silicon Macs (where the spoken feedback is not really necessary).
However, just importing the framework results in the following warning email after I upload to App Store Connect:
We identified one or more issues with a recent delivery for your app,
"App Name" 7.0 (24). Your delivery was successful, but you may wish to
correct the following issues in your next delivery:
ITMS-90863: Apple silicon Macs support issue - The app links with
libraries that are not present on Mac:
/System/Library/Frameworks/AVFAudio.framework/AVFAudio
I guess that this means the app will not be able to run on Macs.
How should I get this app to use the AVFAudio framework for iOS and still be available to run on macOS (AS Macs) with or without the framework on macOS?
Relevant code is:
import AVFoundation
class Speaker {
var speechSynth: AVSpeechSynthesizer
class func establishAudioSession() {
do {
try AVAudioSession.sharedInstance().setCategory(.playback, options: [.interruptSpokenAudioAndMixWithOthers, .duckOthers])
try AVAudioSession.sharedInstance().setMode(.voicePrompt)
try AVAudioSession.sharedInstance().setActive(true, options: [])
UPDATE / CLARIFICATION:
Note that my project does not include multiple targets. With multiple targets, this would be fairly straightforward. I am wondering if there is a way to achieve this by taking advantage of the newer AS Macs’ ability to run apps built for iOS without a separate target.
Is this possible when using this framework?
UPDATE 2:
I have submitted a support request to Apple for this now and their first suggestion was replacing
import AVFoundation
with
import AVFAudio
and then re-uploaded to App Store Connect, but after trying this, I get the same warning email back again. Will post an update (or hopefully an answer) when I hear back from them again.
I suppose your project has multiple targets defines (i.e. one for iOS and one for macOS). In the "General" tag of your target settings you can select which frameworks should be included under "Frameworks, Libraries and Embedded Content". Add your library for iOS, remove it for macOS.
If you share the same code you between apps you can also conditionally exclude some of it for macOS.
#if os(iOS)
// iOS only code
#endif
However, just importing the framework results in the following warning email after I upload to App Store Connect:
The problem probably isn't importing, but (as the message you got indicates), linking to AVFAudio, that's the problem. So solve that, you should select your app target in the Xcode project and go to the Build Phases tab. Look at the Link Binary with Libraries line and hit the disclosure button at the beginning of the line to reveal all the libraries that are linked into your app. Find AVFAudio and change the setting (there's a popup on the right side of the line) from Required to Optional. That'll let your app link to the framework if it's there, but still run if it's not.
But wait, you're not done yet... What do you think will happen if your app tries to actually use a framework that's not linked in (because it doesn't exist on the machine)? You'll get a crash, of course. To avoid that unhappy fate, you'll need to check for the existence of the framework before you use it. For example, you could do something like:
if NSClassFromString("AVAudioPlayer") != nil {
// do your AVFAudio stuff here
}
Further follow up from Apple support suggested the following:
Change back to import AVFoundation
Reduce the deployment targets from the latest and greatest back down to something less recent.
So I did both of these, changing the deployment targets from iOS 14.5 and macOS 11.3 to iOS 14.1 and macOS 11.0.
This has resolved (or worked around!) the issue.
I do want to deploy to the latest and greatest target for this particular app, so I don't consider it to be a complete solution as yet, but it will do as a work around for now. (I actually want to deploy to 15.0 when it's available to make use of the promised improvements to OSLogStore.)
So this sounds like a bug to me, and I have queried Apple for some further information on the issue, in particular, the ability to target more recent OS versions.

'GADURewardedInterstitialAd.h' file not found -error xcode-

Recently I tried to build my xcode project from Unity3D export, but after 400/500 tasks, a major error appear:
GADURewardedInterstitialAd.h file not found
I've tried:
restart xcode
re import GoogleMobileAds SDK IOS(latest update 8.7.0)
change admob version in Unity (5.4.0 or 6.0)
sure, cleaning the project (before launch "archive")
remove the "GoogleMobileAds.xcframework" from "Frameworks" folder and add it again
try the method "framework search paths" in Build Setting (UnityFramework)
try to YES (Enable Modules C & Objective-C)
try to modify architecture (why not)
try to add in OTHER LINKER FLAGS "-ObjC"
No luck, still the same error, any ideas to solve this? thanks.
My solution to various errors of this type was to import the GoogleMobileAds via CocoaPods and not manually. This is because first of all it does everything by itself, and then because it installs you in the project the version of the GMA of iOS supported by the unity plugin (or else sometimes you may find yourself with the version of the unity plugin that does not support the too recent version of the package for iOS)
I suggest you try initially with version 5.4.0 of the plugin, as 6.0.0 and 6.0.1 I saw on GMA's GitHub that some users encounter various errors on Xcode, then maybe if it works you can try with a plugin most recent. What version of Unity do you use? (I built with 2020.3)
I leave you the links of two of my videos that I made that explain (1) how to install/update CocoaPods, (2) how to import GMA via CocoaPods.
I want to say that I have no intention of advertising my content, I have a tiny channel with some videos to help those like me who have had various problems starting to program or use Unity, I do not monetize. You are obviously free to look for information on the internet regarding what was said before and not to watch the videos, which I repeat I have linked only to help.
(1)
Install/update CocoaPods ,
(2)
Import GMA using CocoaPods
In this other link (which leads to a documentation page of the GMA package for iOS), you can read the note from Google that suggests the use of CocoaPods:
Link

Integrate Flutter into CocoaTouch SDK?

I was able to follow the instructions on https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps to add Flutter as a dependency to a simple single view app and display a FlutterViewController, but did not have success trying the same process for a cocoa touch framework that depends on Flutter.
Is this currently possible? My hope was to be able to build a standalone iOS SDK that is powered by Flutter that other iOS apps could depend on with no direct dependency on Flutter.
Specifically when I tried the SDK approach, Flutter imports failed to resolve with errors relating to not being able to find the Flutter module imports:
[Xcode build error][1]][1]
error: no such module 'FlutterPluginRegistrant'
import FlutterPluginRegistrant
error: no such module 'Flutter'
import Flutter
Update:
These are the error logs I was seeing initially, but was able to get around them by vendoring the FlutterPluginRegistrant.framework and Flutter.framework with Cocoapods. With that my main app compiles fine when linked to my FlutterSDK framework that includes the flutter dependencies. The issue I'm running into now is with setting up FlutterViewController and it's FlutterEngine / FlutterDartProject to point to the correct paths within the framework for the flutterAssets / dartMain / packages urls. I'm not sure how to pull these in from the framework.
If you want to build a Framework that is essentially _just_ a Flutter module, where other iOS apps can use it without having to install/depend on Flutter SDK themselves, then yes, this can be done via one of the flutter/add-to-app options for iOS:
Option B - Embed frameworks in Xcode
also refer to the github/flutter/ios_using_prebuilt_module sample
On the other hand, if you are talking about integrating Flutter into an existing Framework, Flutter + Cocoa Touch, then no, this is currently not supported, but is being explored:
https://github.com/flutter/flutter/issues/39027
note that this would be termed “add-to-library” as opposed to "add-to-app"
also mentioned, flutter/add-to-app:
Packing a Flutter library into another sharable library or packing multiple Flutter libraries into an application isn’t supported.

No such module 'BMSPush' after SDK installation with cocoapods

I've initialized the Bluemix Push SDK for iOS following the online documentation: https://console.ng.bluemix.net/docs/services/mobilepush/t_enable_ios_notifications_install.html
Unfortunately, the "import BMSPush" statement in my AppDelegate.swift raises an error (No such module 'BMSPush').
When building my application (target: iOS 8.0), there are 13 issues raised on BMSPushClient.swift, as detailed in the following screenshot:
My configuration is as following:
XCode 7.0.1
Mac OS X 10.10.5
Cocoapods 0.39.0
Cocoapods reported the following versions of the installed dependencies:
Using BMSAnalyticsAPI (0.0.20)
Using BMSAnalyticsSpec (0.0.16)
Using BMSCore (0.0.44)
Using BMSPush (0.1.06)
Does anybody knows how to solve this issue ?
I solved the issue by updating the SDK source code (!), prefixing each ambiguous type with BMSAnalyticsSpec., for example replacing:
internal func sendAnalyticsData (logType:LogLevel, logStringData:String){
with:
internal func sendAnalyticsData (logType:BMSAnalyticsSpec.LogLevel, logStringData:String){
The real cause of this issue is due to a name change in the BMS Swift SDK. As you may know, the Swift SDK for Bluemix Mobile Services is still in the pre-release stage. Changes are constantly happening to improve the SDK before the official release.
In this case the project BMSAnalyticsSpec has been changed to BMSAnalyticsAPI which caused issues with the import statements in the BMSPushUtils and BMSPushCore files. The development team has updated the SDK to include the new BMSAnalyticsAPI import statements. I can let you know when it is available.
To fix this problem in your local environment, you could update the import statements in those two files with the new BMSAnalyticsAPI import statement. Again, the SDK should still be used as an experimental SDK until it is officially released.
UPDATE: The BMSPush SDK has been updated to include the name changes described above. Please complete a pod update in order to grab the latest version (0.1.07). This should solve the problem you described above.

Resources