前提・実現したいこと
Unity Cloud Buildを使い、iosアプリにFirebaseの機能を追加する
- Analytics
- Auth
- Database
- Firestore
- Messaging
- Storage
発生している問題・エラーメッセージ
5720: ▸ Compiling netstandard.cpp 5721: ▸ Compiling mscorlib_CodeGen.c 5722: ▸ Compiling mscorlib9.cpp 5723: ▸ Compiling mscorlib8.cpp 5724: ▸ Compiling mscorlib7.cpp 5725: ▸ Compiling mscorlib6.cpp 5726: ▸ Linking tuyopon 5727: ▸ ❌; Undefined symbols for architecture armv7 5728: ▸ > Symbol: _SWIGRegisterStringCallback_FirebaseMessaging 5729: ▸ > Referenced from: _SWIGStringHelper__cctor_mE5F36F659A4B2283BE917F75E5B861D8F6F03DBD in Firebase.Messaging.o 5730: ▸ ❌; ld: symbol(s) not found for architecture armv7 5731: ▸ ❌; clang: error: linker command failed with exit code 1 (use -v to see invocation) 5732: ▸ Compiling mscorlib5.cpp 5733: ▸ Compiling mscorlib4.cpp 5734: ▸ Compiling mscorlib3.cpp 5735: ▸ Compiling mscorlib2.cpp 5736: ▸ Compiling mscorlib19.cpp 5737: ▸ Compiling mscorlib18.cpp 5738: ▸ Compiling mscorlib17.cpp 5739: ▸ Compiling mscorlib16.cpp 5740: ▸ Compiling mscorlib15.cpp
該当のソースコード
Xcodeの設定を変えるScriptです。
c#
1using UnityEngine; 2using UnityEditor; 3using UnityEditor.Callbacks; 4#if UNITY_IOS 5using UnityEditor.iOS.Xcode; 6using System.Collections.Generic; 7#endif 8using System.IO; 9 10using System.Xml; 11 12 13public class PostBuildProcess { 14 15 [PostProcessBuild] 16 public static void OnPostProcessBuild (BuildTarget buildTarget, string path) { 17#if UNITY_IOS 18 19 20 PBXProject proj = new PBXProject (); 21 string projPath = Path.Combine (path, "Unity-iPhone.xcodeproj/project.pbxproj"); 22 proj.ReadFromFile(PBXProject.GetPBXProjectPath(path)); 23 24 var projectGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName()); 25 proj.SetBuildProperty(projectGuid, "CLANG_ENABLE_MODULES", "YES"); 26 27 proj.WriteToFile(PBXProject.GetPBXProjectPath(path)); 28 proj.ReadFromString (File.ReadAllText (projPath)); 29 30 string target = proj.TargetGuidByName ("Unity-iPhone"); 31 proj.AddBuildProperty (target, "OTHER_LDFLAGS", "-lz"); 32 proj.AddBuildProperty (target, "OTHER_LDFLAGS", "-ObjC"); 33 proj.AddBuildProperty (target, "OTHER_LDFLAGS", "-lsqlite3"); 34 proj.AddBuildProperty (target, "OTHER_LDFLAGS", "-lc++"); 35 36 37 38 List<string> frameworks = new List<string> () { 39 "AdSupport.framework", 40 "CoreData.framework", 41 "SystemConfiguration.framework", 42 "libz.dylib", 43 "libsqlite3.dylib", 44 "libicucore.tbd", 45 "UserNotifications.framework" 46 }; 47 48 foreach (var framework in frameworks) { 49 proj.AddFrameworkToProject (target, framework, false); 50 } 51 //List of frameworks that will be added to project 52 53 54 //Add each by name 55 if (!File.Exists(path + "/GoogleService-Info.plist")) 56 { 57 FileUtil.CopyFileOrDirectory("GoogleService-Info.plist", path + "/GoogleService-Info.plist"); 58 } 59 //Add 60 File.WriteAllText (projPath, proj.WriteToString ()); 61 62 //Set Push Notification Capability 63 CreateEntitlements(path,"tuyopon"); 64 SetCapabilities(path); 65 SetBackgroundMode(path); 66 67 68#endif 69 } 70 #if UNITY_IOS 71 private static void SetBackgroundMode(string path) 72 { 73 var plistPath = Path.Combine(path, "Info.plist"); 74 75 PlistDocument plist = new PlistDocument(); 76 plist.ReadFromFile(plistPath); 77 78 plist.root.SetBoolean("FirebaseAppDelegateProxyEnabled",false); 79 80 PlistElementArray bgModes = plist.root.CreateArray("UIBackgroundModes"); 81 bgModes.AddString("remote-notification"); 82 83 plist.WriteToFile(plistPath); 84 } 85 86 private static void CreateEntitlements(string path,string your_appname) 87 { 88 XmlDocument document = new XmlDocument (); 89 XmlDocumentType doctype = document.CreateDocumentType ("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); 90 document.AppendChild (doctype); 91 92 XmlElement plist = document.CreateElement ("plist"); 93 plist.SetAttribute ("version", "1.0"); 94 XmlElement dict = document.CreateElement ("dict"); 95 plist.AppendChild (dict); 96 document.AppendChild (plist); 97 98 XmlElement e = (XmlElement) document.SelectSingleNode ("/plist/dict"); 99 100 XmlElement key = document.CreateElement ("key"); 101 key.InnerText = "aps-environment"; 102 e.AppendChild (key); 103 104 XmlElement value = document.CreateElement ("string"); 105 value.InnerText = "development"; 106 e.AppendChild (value); 107 108 string entitlementsPath = path + "/Unity-iPhone/"+your_appname+".entitlements"; 109 document.Save(entitlementsPath); 110 111 string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; 112 PBXProject proj = new PBXProject (); 113 proj.ReadFromString (File.ReadAllText (projPath)); 114 string target = proj.TargetGuidByName ("Unity-iPhone"); 115 string guid = proj.AddFile("GoogleService-Info.plist", path+"GoogleService-Info.plist"); 116 proj.SetBuildProperty(target, "CODE_SIGN_ENTITLEMENTS", "Unity-iPhone/"+your_appname+".entitlements"); 117 proj.AddFileToBuild(target, guid); 118 proj.WriteToFile(projPath); 119 } 120 121 private static void SetCapabilities(string path) 122 { 123 string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; 124 PBXProject proj = new PBXProject (); 125 proj.ReadFromString (File.ReadAllText (projPath)); 126 127 string[] lines = proj.WriteToString().Split ('\n'); 128 List<string> newLines = new List<string> (); 129 bool editFinish = false; 130 131 for (int i = 0; i < lines.Length; i++) { 132 133 string line = lines [i]; 134 135 if (editFinish) { 136 newLines.Add (line); 137 } else if (line.IndexOf ("isa = PBXProject;") > -1) { 138 do { 139 newLines.Add (line); 140 line = lines [++i]; 141 } while (line.IndexOf("TargetAttributes = {") == -1); 142 143 // 以下の内容はxcodeprojの内容にあるproject.pbxprojを参照してください 144 newLines.Add("TargetAttributes = {"); 145 newLines.Add("****** = {");//見えなくしています 146 newLines.Add("DevelopmentTeam = ******;");//見えなくしています 147 newLines.Add("SystemCapabilities = {"); 148 newLines.Add("com.apple.BackgroundModes = {"); 149 newLines.Add("enabled = 1;"); 150 newLines.Add("};"); 151 newLines.Add("com.apple.Push = {"); 152 newLines.Add("enabled = 1;"); 153 newLines.Add("};"); 154 newLines.Add("};"); 155 newLines.Add("};"); 156 editFinish = true; 157 158 } else { 159 newLines.Add (line); 160 } 161 } 162 163 File.WriteAllText(projPath, string.Join ("\n", newLines.ToArray ())); 164 } 165#endif 166}
####firebaseのframework
####Assets/Firebase/Editor/__???__Dependenciesのファイル
xml
1<!-- Copyright (C) 2018 Google Inc. All Rights Reserved. 2 3FirebaseApp iOS and Android Dependencies. 4--> 5 6<dependencies> 7 <!--<iosPods> 8 <iosPod name="Firebase/***" version="6.5.0" minTargetSdk="8.0"> 9 </iosPod> 10 </iosPods>--> 11 <androidPackages> 12 <androidPackage spec="com.google.firebase:firebase-common:18.0.0"> 13 </androidPackage> 14 <androidPackage spec="com.google.firebase:firebase-analytics:17.0.1"> 15 </androidPackage> 16 <androidPackage spec="com.google.firebase:firebase-app-unity:6.3.0"> 17 <repositories> 18 <repository>Assets/Firebase/m2repository</repository> 19 </repositories> 20 </androidPackage> 21 </androidPackages> 22</dependencies> 23 24
補足情報
Unity 2019.2.6f1(Cloud Buildも同じ)
Xcode 10.2 (Cloud Build)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。