first push!
This commit is contained in:
29
Assets/Shatalmic/Editor/BluetoothPostProcessBuild.cs
Normal file
29
Assets/Shatalmic/Editor/BluetoothPostProcessBuild.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System.IO;
|
||||
|
||||
public class BluetoothPostProcessBuild
|
||||
{
|
||||
[PostProcessBuild]
|
||||
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
|
||||
{
|
||||
if (buildTarget == BuildTarget.iOS)
|
||||
{
|
||||
// Get plist
|
||||
string plistPath = pathToBuiltProject + "/Info.plist";
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromString(File.ReadAllText(plistPath));
|
||||
|
||||
// Get root
|
||||
PlistElementDict rootDict = plist.root;
|
||||
|
||||
rootDict.SetString("NSBluetoothAlwaysUsageDescription", "Uses BLE to communicate with devices.");
|
||||
|
||||
// Write to file
|
||||
File.WriteAllText(plistPath, plist.WriteToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
12
Assets/Shatalmic/Editor/BluetoothPostProcessBuild.cs.meta
Normal file
12
Assets/Shatalmic/Editor/BluetoothPostProcessBuild.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1695b640ed1354053a8cdd9e0186f57f
|
||||
timeCreated: 1493664761
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Assets/Shatalmic/Editor/PostprocessBuildPlayer
Executable file
93
Assets/Shatalmic/Editor/PostprocessBuildPlayer
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/perl
|
||||
use File::Copy;
|
||||
|
||||
print ("\n*** Starting PostprocessBuildPlayer ***\n");
|
||||
|
||||
my $installPath = $ARGV[0];
|
||||
|
||||
#values to watch for already existing
|
||||
my $requiredDeviceCapsString = "UIRequiredDeviceCapabilities";
|
||||
my $backgroundModesString = "UIBackgroundModes";
|
||||
my $bluetoothLEString = "bluetooth-le";
|
||||
|
||||
#go through the info.plist file line by line until you find this one:
|
||||
my $endOfPlist = "</dict>";
|
||||
|
||||
# The type of player built:
|
||||
# "dashboard", "standaloneWin32", "standaloneOSXIntel", "standaloneOSXPPC", "standaloneOSXUniversal", "webplayer", "iPhone"
|
||||
my $target = $ARGV[1];
|
||||
|
||||
print ("\n*** PostprocessBuildPlayer - Building at '$installPath' with target: $target ***\n");
|
||||
|
||||
################################################################
|
||||
# This modifies info.plist to add the external accessory #
|
||||
# entries #
|
||||
################################################################
|
||||
|
||||
#open this file
|
||||
|
||||
$oplistPath = $installPath."/Info.plist";
|
||||
$nplistPath = $installPath."/Info.plist.tmp";
|
||||
|
||||
open OLDPLIST, "<", $oplistPath or die("Cannot open Info.plist");
|
||||
open NEWPLIST, ">", $nplistPath or die("Cannot create new Info.plist");
|
||||
|
||||
my $nextLine = 0;
|
||||
my $requiredDeviceCapsFound = 0;
|
||||
my $backgroundModesFound = 0;
|
||||
|
||||
while(<OLDPLIST>)
|
||||
{
|
||||
if ($nextLine == 1)
|
||||
{
|
||||
if ($_ =~ m/$bluetoothLEString/)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ =~ s|</array>|\n\t<string>bluetooth-le</string></array>|
|
||||
}
|
||||
|
||||
$nextLine = 0;
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Check for required device caps string already exists #
|
||||
################################################################
|
||||
if ($_ =~ m/$requiredDeviceCapsString/ )
|
||||
{
|
||||
$nextLine = 1;
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Check for background modes string already exists #
|
||||
################################################################
|
||||
if ($_ =~ m/$backgroundModesString/ )
|
||||
{
|
||||
$backgroundModesFound = 1;
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Add any key/value pairs you want at the end of Info.plist #
|
||||
################################################################
|
||||
|
||||
if ($_ =~ m/$endOfPlist/ && $backgrounModesFound == 0)
|
||||
{
|
||||
my $keys = "";
|
||||
|
||||
$keys .= " <key>UIBackgroundModes</key>\n";
|
||||
$keys .= " <array>\n";
|
||||
$keys .= " <string>bluetooth-central</string>\n";
|
||||
$keys .= " <string>bluetooth-peripheral</string>\n";
|
||||
$keys .= " </array>\n";
|
||||
|
||||
$_ = $keys . $_;
|
||||
}
|
||||
|
||||
print NEWPLIST $_;
|
||||
}
|
||||
|
||||
close OLDPLIST;
|
||||
close NEWPLIST;
|
||||
|
||||
`mv \'$nplistPath\' \'$oplistPath\'`;
|
||||
9
Assets/Shatalmic/Editor/PostprocessBuildPlayer.meta
Normal file
9
Assets/Shatalmic/Editor/PostprocessBuildPlayer.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c726eecf85fe4a88a7e7d57812ff455
|
||||
timeCreated: 1515198229
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user