Any idea why Apple changed the documents directory path in Xcode 6? I read pinkstone's post but curious to know whether there is an explanation for the change.
The simulator architecture was rewritten on top of a new framework called CoreSimulator.framework. As part of that, you now have a library of devices that you can create or delete for your testing rather than just having one path of data that is used for all devices.
Related
I have read Using Android Assets. My problem is a bit different because I want to create a folder called assets in the "shared project" as follows. Android and iOS projects are removed for the sake of simplicity. Only UWP is left for demonstration purposes.
I have already created a folder named assets and save a file secret.txt in it. However, I don't know which Build Action value should I attach to this secret.txt. The secret file is not a real secret.
Any comments and suggestions are always welcome!
Set files as EmbeddedResources and manipulate them as described here:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/files?tabs=windows#embedding-in-shared-projects
How do you setup google firebase dynamic links, deep linking, in a xamarin forms app?
This is how I setup Firebase Dynamic Links in Android project of my Xamarin Forms App, so most of this will apply directly to android. I will work on finishing and documenting the iOS implementation in the future.
Disclaimer: I'm not an expert, any or all of this could be wrong. It's just what worked for me and my basic understanding. Please let me know if there are any errors and let's improve our collective intelligence of the Xamarin Community
If you don't already know what Dynamic Links are, watch the 2 min video, it's a great overview. https://firebase.google.com/docs/dynamic-links/
The Setup
Setup is broken up into 2 parts.
Part 1 - Configure the Dynamic Links in the Firebase Console (Easy)
Part 2 - Configure your app to be able to receive and process the Deep Links (Not as Easy)
Part 1 - Configure the Dynamic Links in the Firebase Console (Easy)
1- Setup a free firebase account at https://firebase.google.com/
2- Create a project.
3- Create a new dynamic link, the tab is at the bottom of the 'Grow' section.
It will generate a static domain name for you based off of your project name. Ex. 'https://myproject.page.link'
Short Link url is what users will click on to navigate to your appstore or launch your app.
Deep Link url is what actually gets sent into your app for you to work with. Ex 'https://myproject.com/MainPage'
iOS behavior. Currently set mine to open the link in a url browser, as my app is not connected to it yet.
Android behavior Very Important but not as hard as my explanation makes it look.
Here is where you register your app with firebase. The package name should be easy, use the same one as defined in your
apps Android properties. Ex 'com.mycompany.appname'
Adding the signing certs SHA-1 and SHA-256 are required for Dynamic Links, which is what we are doing here.
Microsoft has a great guide on this, better than I can explain. here
Download the google-services.json file - You will need it later. Also, you will need the one that has incorporated the SHA cert details in it.
Ignore the instructions for adding the firebase SDK, we will add these to our project later using Nuget packages.
When this is all done your app should be selectable in a dropdown for the android behavior.
Finally, add any extra tags to your dynamic link url if you want, its optional.
And that's it! Now you should have a working short link. When used on an android device it should already be able to determine if the app is already installed or not, and then either direct the user to the play store or open the app. However, it won't do anything with that deep link url that you set. That brings us to the next part.
Part 2 - Configure your app to be able to receive and process the Deep Links (Not as Easy)
1- Versions, might be important.
2- Nuget Packages - Hopefully this goes smoother for you than it did for me.
3- The Code
3a- Intent Filters
3b- Handling the Deep Link
1- Versions.
I was having a lot of issues trying to get dynamic/deep linking to work. So I went back and updated everything to the newest versions available at the time.
Visual Studio Professional 2017 - 15.7.5
.NET Framework 4.7.03056
Xamarin 4.10.10.2
Xamarin.Android SDK 8.3.3.2
Android SDK Manager - Got the latest. Android 8.1 API 27 and Android 8.0 API 26 (Targeting 8.1 might be required)
Android Properties -
-Application - Compile using Android Version(Target Framework): Android 8.1 Oreo
-Android Manifest: Target Android Version: Use Compile SDK Version(haven't tried targetting 8.1 directly, might work). My min target is still Android 4.4 API 19 Kit Kat
2- Nuget Packages. These are just for the Android project. MyApp.Android
You shouldn't have to add anything into the .NET Standard Project, just make sure the Xamarin.Forms Versions match
Below is what I did
Update:
Xamarin.Forms - updated to 3.0.0.482510
Install:
This is where it immediately got annoying for me. Issues here are what lead me to go back and update my Android API Levels to the most recent, 8.1
Xamarin.Firebase.Dynamic.Links by Xamarin Inc v60.1142.1 is what you want to install.
The other dependencies should automatically install. In my case, they did not.
Dependency MonoAndroid,Version=v8.0 is important here. That should be the SDK API version that your app is set to compile against.
However, the other dependencies like Xamarin.GooglePlayServices.Basement (= 60.1142.1) have nested dependencies of their own that require MonoAndroid,Version=v8.1
So if you run into issues installing the Dynamic Links Package, thats where I would recommend looking first.
For my purposes, the nested dependencies were not automatically getting installed, so I went down through each of them and their lists and did them all manually. Even the ones that said not to do manually. It's only 20 or so, but my guess would be if I had my project SDK's set to 8.1 before all of this that it would have gone smoothly.
The CODE
Intent Filters
These are defined in your AndroidManifest.xml file
What do they do? They listen for instructions while your app starts.
When an app start matches a pre-defined filter(short link), they it stores your intended action or data on the Intent Class. That is where we pull the deep link from.
For us, this is what let's the android app receive and begin to process the deep link url that you set all the way back in Part 1.
The firebase dynamic link docs have a good breakdown and example of what to do. here
The android developer docs have a good example and breakdown of this also. here
NOTE Focus on whats between the activity tags. I've just included the other tags to show general structure, in case you haven't edited these before.
That is about the minimum of what you need.
The highlighted line should match the Short Dynamic Link you setup in the established in the Firebase Console.
I'd recommend using a Wildcard like I did in the path prefix.
That way you can make new Dynamic Links and your app can handle them without having to release new versions.
Handling the Deep Link
At this point if your app is launched by the short link, you should be able to catch the deep link during the android startup process and handle it how you want.
All I will cover here is a basic example of how to get the Deep Link as a string.
I pass mine to the main app project (.NET Standard Library) using a simple dependency service.
You can use it however you want though, there's actions it can take in either the App or the App.Android project.
The important thing is getting the deep link.
The firebase docs have good examples, but written in java or whatever language native android uses. here
I'll be showing mostly the same, just in C# examples
Get The Intent.
What is the intent you want to get? The deep link you are sending into your app Ex. "https://mycoolapp.com/mainpage"
You want to get it in the MainActivity. Below is an extremely simplified example, but it's just about that easy. Now you should be able to do what you want with that link inside of your app.
TIPS
Be careful if you have something that interrupts your startup procedures.
My Application uses a splash screen. Part of that is a line of code that creates a new Intent, overwriting the one sent in from the dynamic link
So I have my DeepLinkHandler fire off before that operation, and store the deep link in a static string.
Once it's in a static string I can use a dependency service from the Main App(.NET Standard Library) to call the GetDynamicLinkString method and return the deep link as a string.
How to Test Using an Emulator and Debugger
I have a simple settings page on my app. I added a field that would print the deep link, if it has one.
Fire off the emulator like normal using the debugger. The deep link field should be empty.
With the emulator still running, minimize the app.
Open a browser and enter in the short link url.
This should re-launch your app, but this time the deep link field has the url that you set on the firebase console.
Hope this is able to save someone some headaches.
-Tim
I have recently started getting the error ResolveLibraryProjectImports: PathTooLongException on my xamarin android project within xamarin.forms. When I look up online all solutions say to relocate the project. Is there any way to change the project properties or a way to remap that can help me avoid relocating the entire project?
Update:
Due the the bounty and since the question has come up below, here is why I am looking for an alternate solution to relocating:
Directory hierarchies are there for a reason. If not everyone would have the whole bunch of folders the root. They are designed to allow us to organize everything. Same is my case. I have organized all folders based cloud, codes, frameworks etc. Of all the frameworks I have worked with, I have never had relocate a project because of an internal requirement of the project. So, I do not see a reason I need to move a project out of all these folders (which also means out of cloud) and throw them in some location apart from the rest of the projects, just because the project asks for it.
I faced the same Issue before, here is what I have found :
Windows has a Maximum Path Length Limitation. You could see it in Windows Naming Files, Paths, and Namespaces :
Maximum Path Length Limitation In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.) This is the reason why you have the issue.
You could shorten the directory path to your project to solve this problem, another solution is use the long path tool. But as PierceBoggan said :
the easiest way to avoid this issue is to move your source to the C:/ drive (or another location with fewer characters in the path).
Update :
The issue was fixed in Xamarin.Android 8.0.2.1, and this version is included in the Visual Studio 2017 version 15.4.2 release. You could read this document :
https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.0/#Issues_Fixed
I faced this issue too. Updating VS 2017 to 15.4.0 fixed it for me. Moving it closer to C:\ didn't change anything.
I had this problem even when moving my project to root of drive. However after updating Visual Studio to the newest version(15.7.0) the option to change archive output directory has been added to IDE:
Tools --> Options--> Android Settings : Archives Location
By setting this location to a directory as close to drive root as possible(such as D:\Archives), this error will go away.
Literally every new Xamarin Forms project that I try and build hits the MAXPATH error on the Android project the first time (because my default Projects Github folder path is already long).
I have a simple and routine fix that for me works for me 100% of the time because the culprit in my case is the intermediate or [obj] folder.
Try this: Open the .csproj file in notepad. Make sure it's the .csproj for the Android project. Under the first <PropertyGroup> tag add this element:
`<BaseIntermediateOutputPath>C:/Intermediate/Android/YourProjectName</BaseIntermediateOutputPath>`
Now just reload the project and try building again. Hope this helps!
I have created a Core Data application in iPhone Simulator. Now when I am testing it on a device, my SQLite database is empty. I have some preloaded settings which I want to deploy when the application is installed.
How can I achieve that?
I have seen a few questions on Stack Overflow, but they don't exactly answer my question.
If you have an existing sqlite-store file you just add it to the app bundle just like you would any resource e.g. images, audio, etc.
If it is read only, you just use the NSBundle commands to supple a path to it inside the readonly app bundle. If you want it writable, you copy the store file from inside the app bundle to one of the writable app directories e.g. Documents or Library, and then open it there as you normally would.
I created an application in XCode 4 that uses Core Plot.
I installed Core plot as an aditional SDK following the instructions from here:http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications (Install SDK)
The instructions for "static Library" haven't been updated yet fro XCode 4.
I can run the app in the simulator, install it on my iPhone and everything works just ok. I was even able to send it to beta testers using several services like TestFlight. For this, I had to generate an archive and then "share" by generating the .ipa file. No single problem here.
Now, when I try to validate/submit the app I got this error:
I'm selecting the "distribution" configuration, then product -> archive, then in the Organizer I try "validate" or "submit", but I always get this same result.
I also made sure that the "skip install" is set to NO. This part is confusion, Apple says it should be YES and many posts here say it should be NO. If I set it to YES, the app is not even archived.
At this point I'm not even sure if the issue is the "skip install" flag or core plot. I found this question: http://code.google.com/p/core-plot/issues/detail?id=280, so I think my issue may be related.
If I open the archive file, this is what is inside:
Any ideas/suggestions will be truly appreciated.
I had the same issue for both TestFlight and App Store.
The solution for me was to archive the app, and in the organizer select "Don't sign" when you try to validate/submit or share (in the case of TestFlight).
Hope this helps.