I have an iOS app using the GoogleMobileAds Swift package and I would like to add a tvOS destination to my target. I added that through the supported destinations:
Because GoogleMobileAds does not support tvOS, I would like to remove the library link when I build for tvOS. Under my target's "Build Phases" tab I opened up the "Link Binary With Libraries" and set the GoogleMobileAds library to be filtered for iOS only
My understanding is this prevents the linking of the library when built for tvOS. However, that doesn't seem to be the case? When I try building I get the following error:
While building for tvOS Simulator, no library for this platform was found in '/Users/{myHomeDir}/Library/Developer/Xcode/DerivedData/{myPackageName}-bubgtznikupuivcjetnfyqxleoiu/SourcePackages/artifacts/swift-package-manager-google-mobile-ads/GoogleMobileAds.xcframework'.
Building for iOS works just fine. Also, in my code, I've wrapped any imports to the library around platform conditionals as such:
#if os(iOS)
import GoogleMobileAds
#endif
I've tried everything I can think of and can't seem to figure this one out! How can I build for tvOS without having to create a new target? I thought that was the whole idea of the conditional platforms.
EDIT - I've tried switching to
#if canImport(GoogleMobileAds)
but the same error still appears.
Apple's advice is this:
#if canImport(GoogleMobileAds)
import GoogleMobileAds
#endif
As documented here: https://developer.apple.com/documentation/xcode/configuring-a-multiplatform-app-target
Related
I have an issue: I have built-in frameworks via "Frameworks, Libraries, and Embedded Content" that work only on real devices, while their source code is not available and I can't create version for simulator. However, I need to run the project on the simulator, and the functionality that is associated with the frameworks is disabled for the simulator with:
#if targetEnvironment(simulator)
#else
import MyFramework
import MyFramework1
#endif
However, when we try to start the project in simulator mode, I get an error -
Building for iOS Simulator, but the linked and embedded framework
'Framework' was built for iOS.
At Build Phases -> Link Binary With Libraries for my target I selected optional status for MyFramework and MyFramework1
Any suggestion how to fix run for simulator without these frameworks are welcome!
I've found useful fix for my case. This fix is based on this. I just excluded the folder for the simulator (Any iOS Simulator SDK) where the frameworks are physically located. I've added path like this "$(SRCROOT)/my_project/my_libs/*"
Can I use a .xcframework inside a .framework?
When I try this the framework target builds fine, but when I use this framework in an iOS app target, it gives build error
For eg:
MyApp is iOS app target
MyFramework is a framework (embedded in MyApp)
MyXcFramework is a xcframework (embedded in MyFramework)
A sample swift file inside MyFramework contains
import Foundation
import MyXcFramework
and builds successfully
But when MyFramework is added to MyAapp i get the following error
import Foundation
import MyXcFramework <- No such module MyXcFramework
Can anyone help what I am doing wrong?
It seems like you are trying to use the xcframework without adding it to the app. If you want to use your xcframework in your app too you have to add that xcframework in your app target, you can avoid embedding xcframework in the framework and only embed for the app itself.
According to the documentation, it is not allowed in iOS. Apps with Dependencies Between Frameworks
An umbrella framework is a framework bundle that contains other frameworks. While it is possible to create umbrella frameworks for macOS apps, doing so is unnecessary for most developers and is not recommended. Umbrella frameworks are not supported on iOS, watchOS, or tvOS.
I had a framework, that had subframework, everything compiled sucessfuly, I shared the app with Diawi link. QA approved the build. When I tried to upload the build I had following error.
I’m working on a React native project for iOS and tvOS. I’ve started with the version for iOS but I would like to extend the Xcode project/workspace to also build for tvOS. React (Native) code (logic) and state management will be fairly the same for both targets. There are just some UI adjustments but that’s not going to be a big deal.
The problem I’m having now is building the app. For iOS need to link libraries that are not available (nor do I need them) on for the tvOS target. For example the: Orientation. I’ve automatically linked this library to use for for iOS, but this is now causing the app not to build for tvOS, since orientation is not available on that platform. The library doesn’t show up in the list of linked libraries for the tvOS target, but for some reason while building the app Xcode tries to add it and then breaks the build.
Hopefully you guys can help me with this issue, I feel like I’m overlooking something.
I've made a screenshot of the error that I get while building:
You can add your conditional compilation like,
#if TARGET_OS_IOS
extern UIInterfaceOrientationMask ORIENTATION;
#endif
The above example is using Objective C code
I am unable to import CoreNFC in a swift project. Getting this error No such module CoreNFC.
I also added the framework to Linked Frameworks and Libraries.
According to a post on the Apple Developer forums, you can only build for a real device or the Generic iOS device as there is no x86 version of CoreNFC.
Once you switch to one of these, you do not need to add CoreNFC to Linked Frameworks and Libraries, just #import it:
#import CoreNFC;
Has anyone successfully added the Parse tvOS SDK to an existing iOS project with a separate tvOS target?
The iOS app already uses the Parse SDK.
I added a tvOS target to my project, added the Bolts, Parse, SystemConfiguration, and libsqlite3.tbd (got Parse & Bolts here: https://github.com/parseplatform/parse-sdk-ios-osx/releases/tag/1.11.0)
I can compile and run that target on the AppleTV simulator, but I get tons of warnings like this:
URGENT: building for tvOS simulator, but linking in object file
(<path>Parse.framework/Parse(PFObject.o)) built for iOS.
Note: This will be an error in the future
Also, calling PFUser.logInWithUsernameInBackground just hangs.
Not sure if what I'm trying to do just isn't possible of if I'm doing something stupid. Would be great to get this to work as there's lots of sharable code between the projects.
Figured it out. I removed the iOS framework's path from the tvOS target's Framework Search Paths in build settings. The location of the iOS framework appeared first in the list of paths, which I guess hijacked the framework since the iOS/tvOS frameworks have the same name.
Sometimes you just have to take a break and then double check your assumptions.