ios打包

This commit is contained in:
yuqucheng 2026-06-18 09:20:04 +08:00
parent 9728ded717
commit 1c73aef665
7 changed files with 99 additions and 253 deletions

View File

@ -0,0 +1,81 @@
#if UNITY_IOS
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
using System.Diagnostics;
public class FirebaseIosPodfilePostProcessor
{
[PostProcessBuild(100)] // 优先级设为 100在其他后处理之后执行
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
{
if (target != BuildTarget.iOS) return;
string podfilePath = Path.Combine(pathToBuiltProject, "Podfile");
// 生成 Podfile
string podfileContent = @"source 'https://cdn.cocoapods.org/'
platform :ios, '15.0'
target 'UnityFramework' do
pod 'Firebase/Core', '12.4.0'
pod 'Firebase/Auth', '12.4.0'
pod 'Firebase/Database', '12.4.0'
pod 'Firebase/Messaging', '12.4.0'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static
";
File.WriteAllText(podfilePath, podfileContent);
UnityEngine.Debug.Log("[FirebaseIosPostProcessor] Podfile 已生成: " + podfilePath);
// 尝试自动运行 pod install
TryRunPodInstall(pathToBuiltProject);
}
private static void TryRunPodInstall(string projectPath)
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "pod",
Arguments = "install",
WorkingDirectory = projectPath,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
using (Process process = Process.Start(startInfo))
{
string stdout = process.StandardOutput.ReadToEnd();
string stderr = process.StandardError.ReadToEnd();
process.WaitForExit();
if (process.ExitCode == 0)
{
UnityEngine.Debug.Log("[FirebaseIosPostProcessor] pod install 成功");
}
else
{
UnityEngine.Debug.LogWarning("[FirebaseIosPostProcessor] pod install 失败:\n" + stderr);
UnityEngine.Debug.LogWarning("[FirebaseIosPostProcessor] 请手动在 " + projectPath + " 目录下执行 pod install");
}
}
}
catch (System.Exception e)
{
UnityEngine.Debug.LogWarning("[FirebaseIosPostProcessor] 未找到 CocoaPods请手动执行:\n" +
" 1. 安装 CocoaPods: sudo gem install cocoapods\n" +
" 2. cd " + projectPath + "\n" +
" 3. pod install\n" +
" 错误: " + e.Message);
}
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3865f2d3232564d5eac2422f14cdf6e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,80 +0,0 @@
fileFormatVersion: 2
guid: 5383f7d08256547f6b36ee834b840062
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 0
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
iPhone: iOS
second:
enabled: 0
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>21E258</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>BluetoothLEOSX</string>
<key>CFBundleIdentifier</key>
<string>com.shatalmic.BluetoothLEOSX</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>BluetoothLEOSX</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>13E113</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>12.3</string>
<key>DTSDKBuild</key>
<string>21E226</string>
<key>DTSDKName</key>
<string>macosx12.3</string>
<key>DTXcode</key>
<string>1330</string>
<key>DTXcodeBuild</key>
<string>13E113</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Bluetooth is required to work with devices.</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Shatalmic. All rights reserved.</string>
</dict>
</plist>

View File

@ -1,115 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict/>
<key>files2</key>
<dict/>
<key>rules</key>
<dict>
<key>^Resources/</key>
<true/>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^Resources/.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^Resources/.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Resources/Base\.lproj/</key>
<dict>
<key>weight</key>
<real>1010</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>

View File

@ -9,9 +9,9 @@ PlayerSettings:
AndroidFilterTouchesWhenObscured: 0 AndroidFilterTouchesWhenObscured: 0
AndroidEnableSustainedPerformanceMode: 0 AndroidEnableSustainedPerformanceMode: 0
defaultScreenOrientation: 0 defaultScreenOrientation: 0
targetDevice: 2 targetDevice: 0
useOnDemandResources: 0 useOnDemandResources: 0
accelerometerFrequency: 60 accelerometerFrequency: 100
companyName: photonmatrix companyName: photonmatrix
productName: photonmatrix productName: photonmatrix
defaultCursor: {fileID: 0} defaultCursor: {fileID: 0}
@ -166,12 +166,13 @@ PlayerSettings:
androidMaxAspectRatio: 2.1 androidMaxAspectRatio: 2.1
applicationIdentifier: applicationIdentifier:
Android: com.photonmatrix.photonmatrix Android: com.photonmatrix.photonmatrix
iPhone: com.photonmatrix.photonmatrix
buildNumber: buildNumber:
Standalone: 0 Standalone: 0
VisionOS: 0 VisionOS: 0
iPhone: 0 iPhone: 0
tvOS: 0 tvOS: 0
overrideDefaultApplicationIdentifier: 1 overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 1 AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 31 AndroidMinSdkVersion: 31
AndroidTargetSdkVersion: 0 AndroidTargetSdkVersion: 0
@ -189,7 +190,7 @@ PlayerSettings:
strictShaderVariantMatching: 0 strictShaderVariantMatching: 0
VertexChannelCompressionMask: 4054 VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988 iPhoneSdkVersion: 988
iOSSimulatorArchitecture: 0 iOSSimulatorArchitecture: 1
iOSTargetOSVersionString: 15.0 iOSTargetOSVersionString: 15.0
tvOSSdkVersion: 0 tvOSSdkVersion: 0
tvOSSimulatorArchitecture: 0 tvOSSimulatorArchitecture: 0
@ -509,8 +510,8 @@ PlayerSettings:
enableInternalProfiler: 0 enableInternalProfiler: 0
logObjCUncaughtExceptions: 1 logObjCUncaughtExceptions: 1
enableCrashReportAPI: 0 enableCrashReportAPI: 0
cameraUsageDescription: 用于扫描二维码 cameraUsageDescription: "\u7528\u4E8E\u626B\u63CF\u4E8C\u7EF4\u7801"
locationUsageDescription: 用于蓝牙设备通信 locationUsageDescription: "\u7528\u4E8E\u84DD\u7259\u8BBE\u5907\u901A\u4FE1"
microphoneUsageDescription: microphoneUsageDescription:
bluetoothUsageDescription: bluetoothUsageDescription:
macOSTargetOSVersion: 10.13.0 macOSTargetOSVersion: 10.13.0