Build Settings
关于Xcode的Other Linker Flags (链接器)
Objective-C Automatic Reference Counting (ARC 内存自动回收)
Enable Bitcode (一种中间代码, Unity发布CPP要用,是AppStroe优化用的)
理解Bitcode:一种中间代码
General
如横屏的时候游戏需要勾选竖屏支持,如图
Info.plist
xcode 中 info.plist 键值对应关系
Xcode中Info.plist文件各个键的作用说明
NSAppTransportSecurity,(简称ATS) ios9 HTTP请求
关于iOS9中的App Transport Security相关说明及适配
iOS9 HTTP 不能正常使用的解决办法
ios 简单的plist文件读写操作(Document和NSUserDefaults)
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
LSApplicationQueriesSchemes 白名单
iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单
IOS集成第三方支付、分享、登录功能小结
<key>LSApplicationQueriesSchemes</key> <array> <string>alipay</string> <string>weixin</string> <string>mqqapiwallet</string> <string>i4Tool4008227229</string> </array>
NSCameraUsageDescription 相册访问权限(iOS10 新添加)
xcode8 iOS10上关于NSPhotoLibraryUsageDescription NSCameraUsageDescription 等问题
<key>NSCameraUsageDescription</key> <string>使用相机</string> <key>NSPhotoLibraryUsageDescription</key> <string>使用相册</string> <key>NSContactsUsageDescription</key> <string>使用通讯录</string> <key>NSMicrophoneUsageDescription</key> <string>使用麦克风</string> <key>NSLocationAlwaysUsageDescription</key> <string>使用地理位置服务</string> <key>NSLocationWhenInUseUsageDescription</key> <string>使用地理位置服务</string>
NSContactsUsageDescription -> 通讯录 NSMicrophoneUsageDescription -> 麦克风 NSPhotoLibraryUsageDescription -> 相册 NSCameraUsageDescription -> 相机 NSLocationAlwaysUsageDescription -> 地理位置 NSLocationWhenInUseUsageDescription -> 地理位置
Unity 修改 Unity-iPhone.xcodeproj/project.pbxproj 和 Info.plist
Unity iOS 省心打包
Unity iOS 自动修改Xcode配置
using UnityEngine; using System.Collections; using UnityEditor.Callbacks; using UnityEditor; using UnityEditor.iOS.Xcode; using System.IO; public class AsBuildEditor { //构建完毕处理 [PostProcessBuild] public static void OnPostProcessBuild(BuildTarget buildTarget, string path) { if (buildTarget == BuildTarget.iOS) { OnPostProcessBuild_As(buildTarget, path); } } // 爱思 public static void OnPostProcessBuild_As(BuildTarget buildTarget, string path) { string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; PBXProject proj = new PBXProject(); proj.ReadFromString(File.ReadAllText(projPath)); string target = proj.TargetGuidByName("Unity-iPhone"); // 添加依赖库 proj.AddFrameworkToProject(target, "CoreMotion.framework", true); proj.AddFrameworkToProject(target, "CoreTelephony.framework", true); proj.AddFrameworkToProject(target, "Security.framework", true); proj.AddFrameworkToProject(target, "SystemConfiguration.framework", true); proj.AddFrameworkToProject(target, "AdSupport.framework", true); proj.AddFrameworkToProject(target, "AudioToolbox.framework", true); proj.AddFrameworkToProject(target, "MediaPlayer.framework", true); proj.AddFrameworkToProject(target, "AVFoundation.framework", true); proj.AddFrameworkToProject(target, "CFNetwork.framework", true); proj.AddFrameworkToProject(target, "CoreGraphics.framework", true); proj.AddFrameworkToProject(target, "CoreText.framework", true); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libsqlite3.dylib", "Frameworks/libsqlite3.dylib", PBXSourceTree.Sdk)); // proj.AddFileToBuild(target, proj.AddFile("usr/lib/libsqlite3.tbd", "Frameworks/libsqlite3.tbd", PBXSourceTree.Sdk)); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.dylib", "Frameworks/libz.dylib", PBXSourceTree.Sdk)); // proj.AddFileToBuild(target, proj.AddFile("usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk)); proj.AddFileToBuild(target, proj.AddFile("usr/lib/libstdc++.dylib", "Frameworks/libstdc++.dylib", PBXSourceTree.Sdk)); // proj.AddFileToBuild(target, proj.AddFile("usr/lib/libstdc++.tbd", "Frameworks/libstdc++.tbd", PBXSourceTree.Sdk)); // 链接器 proj.AddBuildProperty(target, "OTHER_LDFLAGS", "$(inherited)\n" + "-ObjC"); // 对所有的编译配置设置选项 proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO"); // Team File.WriteAllText(projPath, proj.WriteToString()); Debug.Log(projPath); //Info.plist PlistElementArray arr; PlistElementDict dict; PlistElementArray arr2; string plistPath = path + "/Info.plist"; PlistDocument plist = new PlistDocument(); plist.ReadFromString(File.ReadAllText(plistPath)); PlistElementDict rootDict = plist.root; // 权限 rootDict.SetString ("NSCameraUsageDescription", "使用摄像机"); rootDict.SetString ("NSPhotoLibraryUsageDescription", "使用相册"); // 白名单 arr = rootDict.CreateArray("LSApplicationQueriesSchemes"); arr.AddString("alipay"); arr.AddString("weixin"); arr.AddString("mqqapiwallet"); arr.AddString("i4Tool4008227229"); // 设置支持HTTP dict = rootDict.CreateDict("NSAppTransportSecurity"); dict.SetBoolean("NSAllowsArbitraryLoads", true); // 配置支付宝和 QQ 钱包的 URLSchemes arr = rootDict.CreateArray("CFBundleURLTypes"); dict = arr.AddDict(); dict.SetString("CFBundleTypeRole", "None"); arr2 = dict.CreateArray("CFBundleURLSchemes"); arr2.AddString("As2558"); File.WriteAllText(plistPath, plist.WriteToString()); Debug.Log(plistPath); } }