Unity3D cloud builds iOS and xcode 7 - xcode

I'm working on Unity 5.1.1f1 and using Unity cloud build for iOS with xcode 7 option. My problem is I can't disable App transport Security for my server url, disable bitcode and enable "requires full screen" option on xcode 7. So, game always errors when build.
Any solution is appreciated
Thanks for advice!

This is how I did it. It disables BitCode and enable UIRequiresFullScreen.
Tested with XCode 7.3 and Unity 5.4.1p2 version.
Please upgrade to latest version of Unity
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
public class Postprocessor : AssetPostprocessor
{
#if UNITY_IOS
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
string target = proj.TargetGuidByName("Unity-iPhone");
proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");
File.WriteAllText(projPath, proj.WriteToString());
// Add url schema to plist file
string plistPath = path + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
PlistElementDict rootDict = plist.root;
rootDict.SetBoolean("UIRequiresFullScreen",true);
plist.WriteToFile(plistPath);
}
}
#endif
}

Related

Problem with building paths iOS v MacOs in Xamarin Forms app

I have this code:
var myDocuments = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "..", "Shared");
_rootPath = Path.Combine(myDocuments, "VisitsRota.MacOS");
_stylesPath = Path.Combine(_rootPath, "Styles");
_vrrDataFile = Path.Combine(_rootPath, "VisitsRotaData.xml");
// Read in the required data
vrrData = DeserializeFromXml<VisitsRotaData>(_vrrDataFile);
// Build list of month names. Should this property also have a private counterpart?
ListMonths = DateTimeFormatInfo.CurrentInfo.MonthNames.TakeWhile(m => m != String.Empty).ToList();
// Select the current month in the list
ListMonthsSelectedItem = DateTime.Now.ToString("MMMM");
string[] stylesArray = Directory.GetFiles(_stylesPath, "ElderlyInfirm-Schedule-*.xsl")
.Select(file => Path.GetFileName(file)).ToArray<string>();
On the Mac it runs as expect. But on the iOS simulator (which I am new to using) it raises an exception:
System.IO.DirectoryNotFoundException: Could not find a part of the
path
'/Users/xxxxxxx/Library/Developer/CoreSimulator/Devices/B812608B-8131-4386-B189-C646684A8965/data/Containers/Data/Application/EF23B73D-8D38-4F41-995E-FCAE13AE3035/Shared/VisitsRota.MacOS/Styles'.
How should I be able to replicate testing on my iOS build? if I use literal paths instead of Path.Combine etc. I do not have a problem.
I was able to resolve this. My related question / answer about resources helped.
In the comments to this question I was asked:
How are these files being deployed with your app?
That was the key!
I added a constructor to the AppDelegate class:
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public AppDelegate()
{
InstallApplicationFiles();
}
The linked Q & A has more info. By getting the app to copy the default files from the resources the issue of paths with the iOS simulator is resolved.

.NET Standard 2.0 - Windows Registry - works on Mac OS X - Unity

I have my project (originally developed on Unity - Windows) on API Compatibility Level set to .NET Standard 2.0, and in my project I have an external .dll class library compiled also as .NET Standard 2.0 in which is used Microsoft.Win32. I am saving some data to the Windows Registry.
Now I am adapting the project to work on Mac too, and I found that my external .dll with the Registry thing is working with no error on my Mac also.
I've been trying to find where could that data be stored, as Mac's OS X doesn't have a Windows like Registry?
Why and how is this working?
The code is used as a .dll plugin in Unity.
using Microsoft.Win32;
...
private RegistryKey key;
public StorageImpl()
{
key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath, true);
if (key == null)
{
key = Registry.CurrentUser.CreateSubKey(RegistryKeyPath);
}
}
public DateTime? StartDate
{
get
{
object value = key.GetValue(RegistryStartDate);
return value != null ? DateTime.FromBinary((long)value) : (DateTime?)null;
}
set
{
if (value != null)
{
key.SetValue(RegistryStartDate, value.Value.ToBinary(), RegistryValueKind.QWord);
}
else
{
key.DeleteValue(RegistryStartDate);
}
key.Flush();
}
}
I found where the data is being saved:
/Users/user/.mono/registry/CurrentUser/software/nameOfSoftware/values.xml
I had to search manually listing all folder content using terminal: ls -a

Font Size Disabling - Xamarin iOS

How could the font size be disabled is a Xamarin.iOS app/code? I had done this in Xamarin.Android app using the following code:
private void initFontScale()
{
Configuration configuration = Resources.Configuration;
configuration.FontScale = (float)1.45;
//0.85 small, 1 standard, 1.15 big,1.3 more bigger ,1.45 supper big
DisplayMetrics metrics = new DisplayMetrics();
WindowManager.DefaultDisplay.GetMetrics(metrics);
metrics.ScaledDensity = configuration.FontScale * metrics.Density;
BaseContext.Resources.UpdateConfiguration(configuration, metrics);
}
What would be the equivalent of doing this in an iOS Xamarin app? Any help would be greatly appreciated.
Use this in your App code behind before you initialise your pages:
Xamarin.Forms.Application.Current.On<iOS>().SetEnableAccessibilityScalingForNamedFontSizes(false);
You'll need to include these:
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

Open activity in Xamarin Droid UITest

I've started using the Xamarin UITest to verify the behaviour of my application. I wanted to make the tests logically separated (by that I mean, if one test fails the other one should not fail because of the first, they should be independent). My application has multiple activities and I could not find in the documentation how to open a specific Activity.
The closest I could find was:
[SetUp]
public void BeforeEachTest()
{
app = ConfigureApp.Android.LaunchableActivity("MyActivity").StartApp ();
}
But nothing happend. Can I do this? Is there a workaround?
Thanks
A very late response but thought i'd put it up for others to find. In order to launch the app using a specific activity UITest requires two pieces of information, the app name (or APK file path) and the activity name.
Calling StartApp() on the AndroidConfigurator will look as follows for an app that is already installed onto the device or emulator:
app = ConfigureApp
.Android
.InstalledApp("packagename")
.LaunchableActivity("activityname")
.StartApp();
Or as follow for an APK file:
app = ConfigureApp
.Android
.ApkFile("filename")
.LaunchableActivity("activityname")
.StartApp();
try this code:
if (platform == Platform.Android)
{
string currentFile = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
FileInfo fi = new FileInfo(currentFile);
string dir = fi.Directory.Parent.Parent.Parent.FullName;
var PathToAPK = Path.Combine(dir, "LetsGetNative.Droid", "bin", "Debug", "LetsGetNative.Droid.apk");
app = ConfigureApp.Android.ApkFile(PathToAPK).WaitTimes(new WaitTimes()).EnableLocalScreenshots().StartApp();
}
else
{
app = ConfigureApp.iOS.StartApp();
}

Selenium to record browser actions as video

I wrote a selenium code to run automation in webpage via Firefox
I need to record the browser actions like a visual
Is there any way to record the screen on firefox as a video using addons or any other. I am using firefox version 34
You can include it in your test. Here is an example for C#. To make this work, you need to install Microsoft Expression Encoder and add the reference to your project
using Microsoft.Expression.Encoder.ScreenCapture;
string timestamp = DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss");
ScreenCaptureJob vidrec = new ScreenCaptureJob();
vidrec.OutputScreenCaptureFileName = #"C:/yourPathToSaveFile/yourFilename " + timestamp + ".wmv";
vidrec.Start();
// your test
vidrec.Stop();
http://learnseleniumtesting.com/recording-selenium-test-execution/
using System;
.
.
using OpenQA.Selenium;
.
.
using Microsoft.Expression.Encoder.ScreenCapture;
using System.Drawing;
using Microsoft.Expression.Encoder.Profiles;
using Microsoft.Expression.Encoder;
namespace FRAMEWORK
{
//Call this method in setup method.
public static void StartRecordingVideo()
{
//Provide setting in config file if you want to do recording or not.
if (testEInfo.isRecording)
{
job = new ScreenCaptureJob();
job.CaptureRectangle = Screen.PrimaryScreen.Bounds;
job.ShowFlashingBoundary = true;
//provide the location where you want to save the recording.
job.OutputPath = AutomationLogging.newLocationInResultFolder;
job.Start();
}
}
}

Resources