From what I googled, I could not find solution.
UrhoSharp GIT, is solution built with VS2015.
I created new Xamarin mobile platform solution.
Copied the relevant files over from sample UrhoSharp project.
Then ran the Windows(UWP) propject. it crashes.
(I did it this way as there were too many issues with building the sample project that was created in VS2015)
protected Sample(ApplicationOptions options) : base(options) { }
Throws an exception.
System.Exception
HResult=0x80131500
Message=Implementation assembly (iOS, Android or Desktop) is not referenced
Source=UrhoSharp
at Urho.UrhoPlatformInitializer.DefaultInit()
Try to update to latest UrhoSharp package (1.9.67 at this moment), clean and rebuild the whole solution. It helped in my case.
Related
I developed a Xamarin Cross Platform application that is working perfectly on Windows but when I try to recompile for Android I get the following error:
Can not resolve reference: `Windows.Foundation.UniversalApiContract
I use the Windows.Foundation.UniversalApiContract reference because of the Windows.Storage class (generate files in internal memory).
I understand that I may have to change the recording method on Android but I can't even get to that stage...
How do I resolve this situation?
Just as ToolmakerSteve said, Windows namespace relies on features that exist only in Windows. The reference should not be in the main .Net Standard library but in the UWP Application.
First, you can move the code to the Windows folder or set the #if Windows around it.
Second, you can write the code for each platform. I found the answer you can refer to Can not resolve reference: Windows.Foundation.UniversalApiContract in Android Application.
I am working on a project that uses Adobe's DNG SDK 1.6 library, and it is supposed to work on Windows and MacOS.
The library has instructions on how to build it for both platforms, but I had to figure out an error that came up on Windows with Visual Studio. I am not very experienced with big C++ projects so it was not trivial but I got it working. Most of my own code will be done in C# .Net Core, calling the native libraries using a wrapper class with P/Invoke.
Now for Mac that's a different story, I have a MacOS 11 VM, installed Xcode 12.5.1 and followed the steps provided, as expected, it does not work. Bare in mind this is my first time touching Xcode and MacOS.
The project I am trying to build is dng_validate, and it depends on two libraries built by these projects: XMPFiles64 and XMPCore64.
The library projects build without any hiccups, each one of them creating a ".a" file in the folder: dng_sdk_1_6/xmp/toolkit/public/libraries/macintosh/intel_64_libcpp/Debug, they are named libXMPFilesStaticDebug.a and libXMPCoreStaticDebug.a respectively.
When I try to build the dng_validate project, I get the following error:
Library not found for -lXMPFilesStaticDebug
Because of the the error starting with an "l" instead of "lib", under both libraries project settings, I changed the "Executable Prefix" setting to "l" instead of "lib". Rebuilt both of them and made sure the file names changed as expected. But the error persists when trying to build the main project.
Under dng_validate's project settings, there is a setting called "Library Search Paths" and it does point to the proper aforementioned folder using a relative path. I even changed it to an absolute path to see if that would make it work.
I am really lost here, does anyone have an idea of what might be causing it?
Well... After asking on other forums and almost hiring a freelancer to fix this for me, I tried another shot in the dark of renaming the library files and it worked.
I changed the extensions of libXMPFilesStaticDebug.a and libXMPCoreStaticDebug.a from ".a" to ".dylib" and it just compiled and blew my mind with it.
I am building a Xamarin forms project and I use PCLAppConfig in the platform specific projects to get the app config file from the common project. This has been working until recently. Following an upgrade to Visual Studio(15.9.2) and the iOS OS(High Sierra 10.13.6) it stopped working for the iOS project (I have a feeling those changes are masking the real reason). I get the below error:
System.IO.FileNotFoundException: path: /private/var/containers/Bundle/Application/0AC8F626-E2BD-4432-AC13-C761A1C95E1C/DemoApp.iOS.app/DemoApp.iOS.exe.config
To me it looks like it cannot find app.config
My main project still has an app.config and in the iOS specific project I can see an App.config (with a linked file symbol). Should the iOS specific project linked config have different casing?
the code
global::Xamarin.Forms.Forms.Init();
ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
LoadApplication(new App());
also tried
Assembly assembly = typeof(App).GetTypeInfo().Assembly;
ConfigurationManager.AppSettings = new ConfigurationManager(assembly.GetManifestResourceStream("DemoApp.App.config"))
LoadApplication(new App());
Edit - further info
I have looked through the code base and in this case
PCLAppConfig.FileSystemStream.PortableStream.Current
is equivalent to
System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
hopefully that will help with getting an answer
Ran into the same issue.
Was fixed in 1.0.1.
I have a Xamarin.Forms Shared project.
I need to add a reference to System.Net.Http and after some research I found out it should be done via the regular right click -> select assembly (at every regular project), done that.
But now, if I go to any class on my shared project and try to use that DLL I can't (see image)
What am I doing wrong?
I've added the reference to every other project (iOS, Android and WinPhone) but can't access it on my Shared Project classes.
EDIT
After much try-and-error I figured it out...
I have 3 projects (iOS, Android AND WP8.1).
I was able to add System.Net.Http to iOS and Android projects but when I tried to do that at the WP project I got a message saying all needed DLLs were already in the SDK (how presumptuous!).
Anyway, I decided to unload WP project and it worked =/
So the problem now is: How can I add that DLL to the WP project, since I want to support it, but I NEED System.Net.Http?
Thanks.
You can not add a reference to a project type of SharedProject. Instead you have to add this reference to the project you referenced the SharedProject to.
Consider the following:
You have a solution with a console project and a - lets call it core project - as a SharedProject.
Your console project references core. If you now want to use System.Net.WebClient you have to add the reference to System.Net to the console project.
Well, I figured it out.
The way I solved it was by unloading the WP project and reloading it. Perfect, it worked =)
After reloading the project I checked the .NET for Windows Phone reference and System.Net.Http is indeed there. Maybe this was just a cache thing, I don't know.
All I know is unloading the project and reloading it did the trick.
I am on Mac.
I have a bunch of C source code (.c and .h).
I have a static library (.a).
I want to use that .a library from within Unity.
I looked into Unity's documentation for plug-ins (http://unity3d.com/support/documentation/Manual/Plugins.html), which says for PC and Mac stand alones, .bundle files seem to be the only solution. All example plugin-in projects that Unity give have .bundle plugins.
But I have seen prime31 plugins using .a library in Unity!
Anyone has a clue how they did that?
Here is all that I can tell from analyzing prime31 plugin:
(1) they put their .a library in Unity's Editor folder
(2) they have a C# script which contains lots of [DllImport ("__Internal")]
I tried to do the same:
(1) I wrote a simple hello_world.c in Xcode and built a .a library. I put the libhelloworld.a in Asset/Editor
(2) I then wrote a C# script that looks like this:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class testlib : MonoBehaviour {
[DllImport ("libhelloworld")]
static public extern System.String helloworld();
}
(3) Then I wrote a test script:
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
// Use this for initialization
void Start () {
print(testlib.helloworld());
}
}
(4) By doing so I get a runtime error:
DllNotFoundException: libhelloworld
test.Start () (at Assets/Script/test.cs:8)
Many, many thanks!
PS: In case some of you wonder why I have the source code but not the bundle. I am trying to build a bundle from those .c and .h but hasn't succeeded yet. The source code was compiled with make tools, but I don't know anything else that could build a bundle except for Xcode. So I guess I have to use Xcode to build my bundle. My problem is when I tried to build it with Xcode I get millions of errors saying that I have duplicate main entries. I checked the source code and found that it does have duplicate main()s because the source code has lots of utilities that come with it. I tried deleting those utilities but the same error doesn't go away...
I am planning to ask this question somewhere else because this does not seem very Unity-related. But if someone here happens to know the answer, please don't hesitate -- let me know!
Okay I got an email from the prime31 people. It's impossible to do that.
Unity does not build an Xcode project for OSX, so you can't link a static library. Unity does build an Xcode project for iOS, that's how the prime31 developers could use the .a library(in Xcode, not in Unity)
To sum up, to use unmanaged code in Unity on MacOS, the only correct way is to build a bundle from your source code and then import it to Unity. Just like their documentation said!
I think I will try to build a bundle from source code or try to build a bundle from the .a library that I am now able to build, though Mac OS documentation says it's pointless:
Note: Some Xcode targets (such as shell tools and static libraries) do
not result in the creation of a bundle or package. This is normal and
there is no need to create bundles specifically for these target
types. The resulting binaries generated for those targets are intended
to be used as is.
I may post another question and if that question got answered, I will include a link here...
Alright I am coming back to edit:
Finally I built a bundle from a .a static library and was able to call functions of the library from Unity. Here is how I did: How to organize C source file previously compiled by GCC Make and build them into an Xcode bundle? I have a Duplicate Symbol _main Error
I am using my own library for an iOS project and it works fine. I don't use Unity3D's mechanism of copying from plugins folder but set it up completely in XCode. In the above HelloWorld example try [DllImport("__Internal")].
Follow the links in my previous answer How to use an xcode game on unity3d look at my blog posting, it deals exactly with this problem.