Can I get the Unity3D engine version in Xcode and how to do a conditional compile based on the version? - ios

I'm working on a plugin in Unity3D for iOS. For some reason, I need to specify some code in the native code (.mm in Xcode) to be compiled under before Unity3D 4.1 and other be compiled after Unity3D 4.1(including). Maybe something like this:
#if UNITY_VERSION < UNITY_4_1
//Some code be compiled before Unity4.1
#else
//Some code for new version
#endif
I know there is a Platform Dependent Compilation in the Unity3D Editor, but how can I get the engine's version in Xcode and do a "Unity Engine version based condition compilation"? Any suggestion will be appreciated!
Edit: Maybe I can write two .mm files for different version and delete one of them in [PostProcessAttribute]. But I don't think it is a good idea...

It isn't exactly clear on what you are trying to do. Are you building your native code by injecting into the XCode project that Unity creates? Or are you building your native code to a library that is included by Unity during the build?
AFAIK there is no way for XCode to know ahead of time which version of Unity you are using without examing the install of Unity and figuring out a way to determine that.
If you doing the latter, i.e. building a native code library that is included into Unity's build. You would need two separate libraries in that case, and instruct the user to include whichever one is relevant.
If you are doing the former, i.e. injecting new native code into the XCode project that Unity created then Unity does export the #defines so you could then determine which version of Unity your native code needs to compile against.

Related

How to prebuilt libraries to be compatible with future swift versions

We are prebuilding some libraries (mainly with carthage) for some of our projects to reduce development times. These libraries are not updated very often, but we want to update our XCode versions pretty fast.
Now every time a new XCode brings a new swift version, we are seeing this incompatibility issue
File.swift:4:8: error: module compiled with Swift 5.3.2 cannot be imported by the Swift 5.4 compiler: /......./Debug-iphoneos/Alamofire.framework/Modules/Alamofire.swiftmodule/arm64-apple-ios.swiftmodule
How can I pre-build my dependencies in a way that a swift update wont affect it and I dont have to re-build the dependencies with every xcode update (I thought thats what ABI stability was for? How can I activate that?)
It sounds like you're misunderstanding what ABI stability enables. The main benefit is that it allows the OS to include only one version of the Swift standard library, and for all Swift binaries to share it. What you want is "module stability". From the docs on ABI stability:
ABI stability is about mixing versions of Swift at run time. What
about compile time? Right now, Swift uses an opaque archive format
called “swiftmodule” to describe the interface of a library, such as a
framework “MagicKit”, rather than manually-written header files.
However, the “swiftmodule” format is also tied to the current version
of the compiler, which means an app developer can’t import MagicKit if
MagicKit was built with a different version of Swift. That is, the app
developer and the library author have to be using the same version of
the compiler.
To remove this restriction, the library author needs a feature
currently being implemented called module stability. This involves
augmenting the opaque format with a textual summary of a module,
similar to what you see in Xcodeʼs “Generated Interface” view, so that
clients can use a module without having to care what compiler it was
built with.
This is not yet supported in any version of Swift.

How to avoid "libraries attached to project that were compiled with kotlin/native compiler" error?

I am working on a Kotlin Multiplatform Mobile project. Tried adding in libraries for KMM, but I am getting
There are __ third-party libraries attached to the project that were compiled with an older Kotlin/Native compiler and can't be read in IDE.
The android project builds without problem so I was wondering if whether this error is only a warning and doesn't not affect the application at all?
Is there anyway to avoid this issue? How can I know if a library could be used for Kotlin Native?
Kotlin/Native doesn't guarantee binary compatability between versions - although as of 1.4 minor versions are experimentally binary backwards compatible. e.g. 1.4.10 should be compatible with 1.4.20 in the same project.
The easiest way to avoid the error is to ensure you're using KMM libraries with the same kotlin version as the kotlin version your project uses. Same goes for the IDE plugin.
Generally kotlin libraries by Jetbrains stay very up to date, as well as bigger libraries like SqlDelight. But smaller third party libraries can fall behind.
This issue is being actively worked on.

Loading native C library from Objective-C in Flutter plugin

I have a native C library (.so) build in versions for android and iOS. I want them to be used in a flutter app I am building.
For android I use System.loadLibrary() in Java to load the file (wrapped in JNI) and it is included via the Gradle build system/CMake.
But how do I get the same for iOS in objective C ?
Seems like I can use dlopen() on the library and then dlsym() every single function to get their symbol into the app at runtime. Seems pretty dump but I guess it could work (when I at some point have convinced the buildsystem to include the lib into the actual package it builds.

Lexical or preprocessor issue in react native while building ios app <React/RCTUtils.h> not found

When I am trying to build my ios app in xcode, the build is failing due to lexical or preprocessor issue the error shows up like this
This was a problem specific to the react-native-device-info module.
For your specific case you may try v1.6.1 or higher (currently at 2.0 as of May 21, 2019) of the library and that should fix things for you.
For others interested more generally in the problem, this is a react-native library that uses native code, so it has an XCode project embedded within it for use in react-native after you run react-native link react-native-device-info. Unfortunately, the library was not including any directories in it's header search path, so it was of course unable to find the header files for the react-native objects it was using locally.
A library user proposed a change that fixed that problem for tvOS, and I extended the change to cover iOS as well, and now the library no longer generates errors like this for iOS or tvOS targets.
Perhaps someone with a similar issue may find the specific changes required for the fix useful in their projects

How to use compiled rtmp-dump for building iOS app

How can I use the compiled version of rtmpdump https://rtmpdump.mplayerhq.hu/ to make an iOS app ?
The compiled library i.e librtmp.a is available https://github.com/BigBadOwl/iPhone-Rtmpdump but the sample xcode project is quite old and not very useful. Can someone provide good sample project or tutorial ?

Resources