Xamarin Studio Starter: Why am I getting native library reference error on build without native libraries? - xamarin.android

I've been playing around with the Starter Edition of Xamarin Studio to determine if it will meet my needs. I understand (so I thought) the limitations of this edition; 32K compiled IL limit, no native libraries, etc. Now, I understand native libraries to be C/C++ libraries, or even native Java libraries. This does not seem to be the case.
I have a solution in Xamarin Studio with 2 projects. One is an Android Class Library, the other is an Android Application. When I reference the class library from the application project and build, I get the following error.
Your app references native libraries. This functionality requires Indie Edition or higher.
I beg to differ! Every .cs file in the referenced Android class library project is simple .NET code. What am I missing? I can successfully run the Tasky Android_Starter solution without issue, and it is made up of 2 projects like mine.

I had to delete the Resources folder and manually edit the Android class library project file in order to get this working. I looked at the Tasky sample's project file as a reference.
After deleting the auto-included Resources folder from the project, edit the .csproj file in a text editor to remove the following XML elements:
Project\ProjectGroup\AndroidResgenFile
Project\ProjectGroup\AndroidResgenClass
With those things taken care of, I no longer get the error. I'm guessing, Xamarin Studio thought I was referencing another Android application instead of a class library. Not sure why the default project template includes things to break such a flow, but perhaps I'm not "doing" right" either. Go figure.

Deleting the Resources folder and manually editing the csproj file didn't work for me. I had to create a new C# Library project instead of creating an Android Library Project and import my .cs files into that. After that it compiled and ran fine.

Related

How to construct a Swift Package that links to a local (not system) library?

I must have read over a dozen posts on possible techniques to link a local library into my Swift Package. Specifically, my package depends on libturbojpeg.a, which most users won't have installed anywhere. Even if they did install it (there is a DMG), I'd have to go through hoops to make sure I was linking in the correct version. I finally found a post in the Swift Forums that basically says you can't do it now.
It appears that the only way to link it now is using .linkerSettings(LinkerSetting.unsafeFlags(..., but if you use that your package can't be managed by Xcode (see above link, and I even tried it and verified it cannot be used).
Is there some kind of workaround that allows me to distribute my Swift Package with the library?
In my Package, I created a directory "Libraries" and added my library there.
I discovered that Xcode 11 places included Swift Packages in a specific location in the Derived Folders directory. This means that it is possible to tell Xcode where to find it during the link phase.
My Package has these instructions in it for users:
1) Add the Package using Xcode->File->Packages with the URL of https://github.com/dhoerl/
2) Open the app's Project Build Phases, and from the Package shown in the left file pane, drag the Libraries/.a file into the link phase. It will appear just above the that should already be there
3) In Application Build settings, under library search paths, add:
"$(BUILD_DIR)/../../SourcePackages/checkouts//Libraries"
Build and run! Voíla - works like a charm!
Note: obviously this is somewhat fragile, Xcode 12 could change how packages are managed, but its possible by then that the Swift Package Manager will support linking of local libraries (its mentioned in the above link.)

Android binding library Failed resolution of: L....../R$layout

I am trying to create Xamarin support for my Android SDK (So potential clients can implement it as Xamarin Android app.
I was trying to avoid using AAR because I wanted resources to be available to the client, so the client can customize the layout. In android library it is usually very easy because one can create JAR file only from the java classes and leave the res folder as is with all the resources available for editing.
I was trying to do the Same with xamarin studio: I located the jar under jars and also added .so files under lib/jni. Then I copied the res folder content to Resources.
The result was:
In the Xamarin app (that uses the dll from the binding project) I could see the Resources. But! When I am running the java classes (I use those resources in the SDK code) I get an error:
java.lang.NoClassDefFoundError: Failed resolution of: L....../R$layout.
I didn't find any documentation on using resources outside the jar...
Is there another option maybe with Android resources that are defined inside AAR, to override them outside the AAR.
Thanks in advance for any answer/reference
The only main difference between a JAR and AAR is that AARs can include resources. If a client needs to customize the resources, you have a couple of ways.
A Xamarin.Android Class Library that can be customized, recompiled, and added to a project.
An Android Class Library that can be customized then packaged into an AAR to be bound by a binding project.
Finally you could always just instruct your clients to purposely override your library's resources as the application resource will be prioritized rather than the library.
https://developer.android.com/studio/write/add-resources.html#resource_merging

How to add unity project in a currently existing ios project?

I have searched a lot about this. But all the answers suggest that, it is possible to add new files into unity(xcode) project but vice versa is not possible. Actually, my target is to create sdk which will be used in a cordova plugin. What should I do?
To create an iOS sdk for unity you can create a library project in xCode and import the build to unity's Assets/Plugins/iOS folder. everything in here will automatically get included in xCode project generated by Unity.
And yes, it's very hard to include unity build in your own xcode project. There have been people begging for enlightenment to integrate Unity in another app but every time the threads are stranded beyond hope. Gibberish-gibberish... It's not possible.
It's extremely frustrating but it is possible. It requires a lot of changes to the build settings and compiler settings as well as customizing the launch of Unity components.
Best place to start is to import the Classes, Libraries, and Data folders (if applicable). Data as a folder reference and not a group. I'm also assuming your Unity project output is similar to what I've been given. We've modified our main.m file to be a C++ file (main.mm) and added in the Unity initialization code. We also updated the UnityAppController.mm file to not run startUnity on launch.
If this is still something you're working on please feel free to contact me on Twitter (#Ruprect) and I can help troubleshoot.
In this repo: https://github.com/jiulongw/swift-unity you can find how to integrate Unity Project into Xcode Swift Project.

Xcode - debugging library built outside project

I have a C library whose code resides in say /repos1/clib. I build that from the command line using the latest iOS sdk to create clib.a (including a debug build for the simulator) which I copy to an iOS project say in /repos2/proj.
I have been using this setup for several years. The old C library very occasionally might require some debugging and I was pleased by the fact that Xcode simply stepped into the library code that was outside the project (inside repos1) without having to do any setup - it just worked.
But this was up until a few Xcode versions ago. I am not sure exactly when it changed - perhaps when they moved from gcc to llvm? - since I very seldom needed to debug the C code, but for a while now I only get dissasembly when I try to debug the C library from the iOS project (including at least references to the C file name & line number). For the few times I need to debug it is very inconvenient (I create a temp project that includes the C code).
So, any idea why it worked before and doesn't now? Where should I look? Could it be the way I build the C library, maybe there was a flag in gcc I was using that does not have an equivalent in llvm (I can find and post the old build command I was using if it is relevant)? Is the issue in Xcode and there is a way to tell it where to look for the sources?
Thanks!
Edit: To make it clear, I can add the C library either as the source or as a subproject in Xcode, however for reasons that are out of scope this is not helpful for this specific project. So, can it work like it used to with older Xcode versions? If not, it would still be interesting to know why not.
The recommended approach is to create a library project in Xcode, one for iOS (there is a template for it), then when you get that to build add that project to your app, make sure the lib is a dependency and gets linked. There are many tutorials on the web how to do this.
Then as iOS evolves and new architectures (armv7s) arrive you simply update both projects.
I was struggling with the same issue.
I tried resetting in library/application project all options related to symbol stripping and copy application project to same truecrypt drive as library project but it didn't help.
In my case it appeared it was an app project issue. Same library could be debugged in another app project with source code so that was a clue.
I had more than one version of the same library in app project and set only target membership to choose which should be used. Not sure if that could affect my app project somehow.
Nevertheless after deleting all libraries and copying them to app project again I was able to debug libraries with access to source code.

Creating a distributable framework for iOS Applications

I am currently building a library which should be used internally in a few iOS projects but should also be distributed to customers accessing our services with the library. The Library itself consists purely of C++ code and I am basically able to create Apps with it on iOS which work fine. My problem is creating a single, easily distributable file that can be given out to customers which can easily install them, use the provided headers and don't need to have the headaches that I am currently facing when it comes to linking.
Our code depends on two other projects, namely boost and websocketpp. For boost there is the script on github which I took to generate a framework. For websocketpp, I imported it into XCode and used the scripts from this github project to build a framework. I added both frameworks to my (potential) framework as dependencies and used the same script to build one.
I have an app using my library as a sub-project working fine. Even including the framework into the project and running it on a device works fine. So far so good.
However, trying to create an archive of the App project lead to several questions and headaches.
My library did not seem to contain the code for all architectures. So I tried to archive the Framework projects, which after small modifications in the build scripts to use different locations to search for headers worked fine.
It does not seem to contain all binary code or references to local files (i.e. my specific location of boost). I gathered that from Linker errors that I still get that tell me that some boost calls could not be satisfied.
The second issue made me think that I am must be doing something fundamentally wrong and my intuition tells me that it can't be that difficult and "hackish" to create frameworks or libraries for others for iOS development.
As you probably have found out by now, I am not very experienced when it comes to iOS and I am wondering if I am missing something fundamentally. So, I am sure that this question is rather broad, so some more concrete questsions:
Is there a(nother) way to generate some kind of distributable (preferably a framework) which contains: my public headers, my binary code compiled for all platforms supported for iOS development, the binary code of dependencies?
Is the only way to do that by adding some handwritten scripts to the build process?
I have the feeling that the information I found is quite outdated since it's older than a year and mostly refers to Xcode 4.2 or 4.3 -- so has there anything changed in this regard recently?
For example one error I get is:
File is universal (2 slices) but does not contain a(n) armv7s slice: <file>
The <file> slice is the path to the file in the framework in the Products folder of a different XCode workspace (the library was build in a different workspace then the app). I dropped the framework folder into the project for this test from a completely different location.
What is going on here?
Why does it keep referencing to some internal XCode directory?
How do I properly export it?
Since I guess my setup is probably skrewed up and weird from all the different things I tried up to now: How does this setup look like in a ideal situation?
Yes, there are some questions regarding this on SO already, however, either I don't see or don't understand in those replies:
...how to handle depencies of my code to other third-party code properly.
...how to generate a distributable file.
Have you checked your project build phase under Compile Sources and Copy Files to see if you are including your framework source files in your build?
You may also try the C/C++ Library template under OSX -> Framework & Library.
Finally, there's also kstenerud’s iOS Universal Framework, which I found very useful. I wrote a few articles in my blog on using it.

Resources