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
Related
I have very little experience in native iOS development but my current job is to wrap some specific native iOS framework to use it in React Native.
Preliminary data: common React Native tools generate an empty iOS library project and an example iOS app project that utilizes this library.
First I've tried to add the needed framework directly to the example app using CocoaPods - and it works fine, the framework became a part of linked libPods.a file, then if I add
#import MyTargetFramework;
to AppDelegate.m I can access different methods of the framework from it.
Next I switched to my iOS library project, applied the same setup (created a Podfile, added the same pod MyTargetFramework to it), then added the same #import MyTargetFramework to *.m file - but got a build error:
Module 'MyTargetFramework' not found
Also I've noticed that there is no libPods.a for iOS library project, all the pods are merged to a Pods.framework instead.
So my question is - what am I doing wrong? Why does it work for iOS app project, but not for iOS library project? How can I properly link my target framework to my own iOS library? I've already spent some time googling, but found nothing about app vs lib differences from this point.
I thought I understood what Always Embed Swift Standard Libraries was doing, but now i'm confused.
I pushed an update to a MacOS app to the App Store and a user said it was crashing for him on macOS High Sierra. After a very quick investigation, it seems the swift libraries were missing and one of my frameworks was written in swift (Main app was ObjC). I switched Always Embed Swift Standard Libraries to YES, re-uploaded a new build and everything was great with the world.
I have now uploaded a brand new iOS app to Testflight that is build for iOS 9.3+ and remembered about this issue so thought i'd test it out.
The Always Embed Swift Standard Libraries setting is set to NO which must have been the Xcode default. I downloaded the app through TestFlight on an iOS 9.3.2 device expecting it to crash on launch, but no, the app works perfectly fine.
How can a macOS app crash running on 1 major version behind of macOS but an iOS app can run perfectly fine on iOS that's 4 major versions behind?
Am I completely misunderstanding what this setting does?
When should we use Always Embed Swift Standard Libraries?
----- EDIT
I've just checked the .app contents and it seems it does have the swift libraries in it, which would explain why t didn't crash on iOS 9.3.2. So an additional question. Why would the swift libraries be there when Always Embed Swift Standard Libraries is set to NO?
I had to read the documentation several times, to get a clue what's going on:
Always Embed Swift Standard Libraries (ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES)
Always embed the Swift standard libraries in the target's products, even if the target does not contain any Swift code.
This means
if you set ALWAYS... to YES, the libraries will definitely be embedded.
if you set it to NO, they will not always be embedded - they might or might not be embedded, regarding of how clever the build system is able to decide that it needs them or nor (depending on the target version or so).
This is a common misinterpretation: The negation of always is not never, it is just not always (e.g. sometimes or so).
I got a new project to start, but I have confusion before start the project , Can we create a single app for both iOS and tvOS
My Project will be for iphone/ipad and TvOS and also working for both modes portrait and landscape.
I tried but getting links for starting new project with tvOS. I also getting something about adding new target for tvOS but not exactly very clearly I understand what I have to do?
Please help me to start this project?
Yes, you can create one project for iOS and tvOS application and share code between each other.
You need to create two targets, one for iOS and one for tvOS.
If you want to distinguish part of the code in one file you can use conditional compilation statements: #if os(iOS) or #if os(tvOS)
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.
I just upgraded from Xcode 6 Beta 2 to Xcode Beta 3 and am now getting the following warning when building my project:
ld: warning: relocatable dylibs (e.g. embedded frameworks) are only supported on iOS 8.0 and later (#rpath/libswift_stdlib_core.dylib)
It is a warning but seems to mean my current setup will not work on iOS 7.1, which is my deployment target. How can I track down which frameworks are embedded, and how can I fix this for iOS < 8.0?
This appears to be a bug of Beta 3. As pointed out by Apple Engineer on this post.
I have also been living with this warning when running apps on iOS 7.1 device.
You see and add them on the project page when you select the target: tab General->Embedded Binaries (and they then appear in Build Phases->Embed Frameworks).
Embedded frameworks for OSX were available in Xcode 5, but not for iOS.
WWDC session regarding new features in Xcode 6 specifically promised dynamic frameworks for iOS 8 (someone please add citation when developer center comes back online). So far, with all Xcode 6 betas, I have had no problems compiling and debugging an app with frameworks on iOS 7.
But since this wasn't promised, frameworks for iOS7 is something you cannot depend on (e.g. this may stop working in later betas; an app with embedded framework for iOS 7 may be rejected, etc.). That may explain why they added an explicit warning.
There's not much you can do if this feature turns out to be indeed unsupported, other than remove the frameworks from the target and use static libraries as we did with Xcode 5. Or go the iOS8-only route.
After using XCode 6.1.1 I am able to put the code on iOS 8+ iOS7.1.2 and iOS 6.1.3 Although the warning is still there but the app works absolutely fine on all the 3 OSs
======================
Lucky guy... My project keeps failing to compile after I referenced the PushKit framework.
The project is a new project created by Xcode with only 3 new functions for testing Push Notification.
The workaround is to put the PushKit framework as "embedded", but this is not a good solution since my working Xcode project will be generated from Unity3d. Making the changes manually will break the auto build process.
I had this error after adding a C++ framework (DeepBelief) to a project. Adding an empty .cpp file to the project fixed it.
I'm using Beta4, and found the answer on the DeepBelief github site:
XCode may be skipping the standard C++ library, and that's needed by
the DeepBelief.framework code. One workaround I've found is to include
an empty .mm or .cpp file in the project to trick XCode into treating
it as a C++
project.
Read this github post from ReactiveCocoa
The bug is still present in XCode6 GM and so XCode6 final release:
Well, I get the exact same issue in xcode6GM no matter whether I
create framework for swift OR objc :-[[[[[[[[[[[[[[[
According to Apple Extension Programming Guide:
You can make a containing app available to users running iOS 7 or earlier, but then must take precautions to safely link embedded frameworks when running in iOS 8 or later.
talking about app extensions, but if you read it, you can understand that this applies to embedded frameworks in general.
this is happening because one of your embedded binaries's deployment target is lower than your applications target. lower your embeded binaries's building target and be fine.
this was the error cause in xcode 6.1.1
i was using xcglogger with deployment target ios 8.0, and my application's deployment target 7.0. set the xcglogger's deployment target ios 7.0 and problem solved.
After using XCode 6.1.1 I am able to put the code on iOS 8+ iOS7.1.2 and iOS 6.1.3
Although the warning is still there but the app works absolutely fine on all the 3 OSs
Yes not able to submit the app for review.
Had to do by changing the modern frameworks to Static libs.