Recently used unity to connect iOS SDK, with unity to export Xcode project, since just started, each time is manually set. After watching the Unity3d Research Institute of iOS fully automatic editing framework, plist, OC Code (67) and unity-export Xcode project when the automatic configuration, with Xuporter tried, or feel inconvenient. See the Unity iOS one-click packaging of the elimination of Xuporter, decided to learn about unity with the API.
[Postprocessbuild] public static void Onpostprocessbuild (Buildtarget buildtarget, string path) {if (build
Target!= Buildtarget.ios) return;
Here is the fixed string projpath = Pbxproject.getpbxprojectpath (path);
Pbxproject proj = new Pbxproject (); Proj.
Readfromstring (File.readalltext (Projpath)); String target = proj.
Targetguidbyname ("Unity-iphone"); 1, modify settings//Add system library (Third-party library will not add, is now placed in a folder, copy to the Xcode project, will be added later) Proj.
Addframeworktoproject (Target, "assetslibrary.framework", false); Proj.
Addframeworktoproject (Target, "adsupport.framework", false); Proj.
Addframeworktoproject (Target, "security.framework", false); Proj.
Addframeworktoproject (Target, "gamekit.framework", false); Proj.
Addframeworktoproject (Target, "systemconfiguration.framework", false); Proj.
Addframeworktoproject (Target, "coretelephony.framework", false); Add TBD String fileguidsqlite = proj. AddFile("Usr/lib/libsqlite3.0.tbd", "Libraries/libsqlite3.0.tbd", PBXSOURCETREE.SDK); Proj.
Addfiletobuild (target, fileguidsqlite); String fileguidlibz = proj.
AddFile ("Usr/lib/libz.tbd", "Libraries/libz.tbd", PBXSOURCETREE.SDK); Proj.
Addfiletobuild (target, FILEGUIDLIBZ); String fileguidlibc= proj.
AddFile ("Usr/lib/libc++.tbd", "Libraries/libc++.tbd", PBXSOURCETREE.SDK); Proj.
Addfiletobuild (target, FILEGUIDLIBC); String fileguidlibstdc = proj.
AddFile ("Usr/lib/libstdc++.tbd", "Libraries/libstdc++.tbd", PBXSOURCETREE.SDK); Proj.
Addfiletobuild (target, FILEGUIDLIBSTDC); Modify property proj.
Setbuildproperty (Target, "Enable_bitcode", "NO"); Proj.
Setbuildproperty (Target, "gcc_enable_cpp_exceptions", "yes"); Proj.
Setbuildproperty (Target, "gcc_enable_objc_exceptions", "yes"); Proj.
Setbuildproperty (Target, "Gcc_enable_cpp_rtti", "yes"); Proj.
Addbuildproperty (Target, "other_ldflags", "-OBJC"); Proj.Addbuildproperty (Target, "other_ldflags", "-force_load");
Add Framework search Paths, Header search Paths, Library search Paths//(the default here is non-recursive, temporarily do not know how to add recursive) Proj.
Addbuildproperty (Target, "framework_search_paths", "xxxx"); Proj.
Addbuildproperty (Target, "library_search_paths", "xxxx"); Proj.
Addbuildproperty (Target, "header_search_paths", "xxxx"); File.writealltext (Projpath, Proj.
Writetostring ());
2, modify Info.plist file var Plistpath = Path.Combine (Path, "info.plist");
var plist = new Plistdocument (); Plist.
ReadFromFile (Plistpath);
Similar can be added, this relatively simple//select language (String) plist.root.SetString ("Cfbundledevelopmentregion", "xxxx");
Set Lsapplicationqueriesschemes (array) Plistelementarray Loginchannelsarr;
Loginchannelsarr = Plist.root.CreateArray ("Lsapplicationqueriesschemes");
Loginchannelsarr.addstring ("xxxx"); Configuration amount (dictionary) plistelementdictPlistmoneydic;
Plistmoneydic = Plist.root.CreateDict ("Dict");
Plistmoneydic.setstring ("Key", "value");
(bool value) Plist.root.SetBoolean ("Supportmobile", false);
The complex is that the configuration urlschemes (there is a dictionary inside the array, the dictionary has a child array) Plistelementarray urltypes = Plist.root.CreateArray ("Cfbundleurltype
S ");
Plistelementdict itemdict;
Itemdict = Urltypes.adddict ();
Itemdict.setstring ("Cfbundletyperole", "Editor");
Itemdict.setstring ("Cfbundleurlname", "xxxx");
Plistelementarray schemesArray1 = Itemdict.createarray ("Cfbundleurlschemes");
Schemesarray1.addstring ("xxxx");
Itemdict = Urltypes.adddict ();
Itemdict.setstring ("Cfbundletyperole", "Editor");
Plistelementarray schemesArray2 = Itemdict.createarray ("Cfbundleurlschemes");
Schemesarray2.addstring ("xxxx");
Itemdict = Urltypes.adddict ();
Itemdict.setstring ("Cfbundletyperole", "Editor");
Itemdict.setstring ("Cfbundleurlname", "xxxx");
Plistelementarray schemesArray3 = Itemdict.createarray ("Cfbundleurlschemes");
Schemesarray3.addstring ("xxxx"); File.writealltext (Plistpath, plist. Writetostring ());
< array >//This is Xcode project Urlschemes source//< Dict >//< key > Cfbundl Etyperole </key >/< String > Editor </string >//< key > Cfbun Dleurlname </key >/< String > XXXX </string >//< key > Cfbund
Leurlschemes </key >/< array >//< String > XXXX </string > </array >//</dict >//< Dict >//< Key &G T Cfbundletyperole </key >/< String > Editor </string >//< Key ; Cfbundleurlschemes </key >/< array >//< string > XXXX </stri ng >//</array >//</dict >//< Dict >//&L T Key > CfbundlEtyperole </key >/< String > Editor </string >//< key > Cfbun Dleurlname </key >/< String > XXXX </string >//< key > Cfbund Leurlschemes </key >/< array >//< String > XXXX </string
;
</array >//</dict >//</array >;
3, modify the code//read unityappcontroller.mm file UnityEditor.XCodeEditor.XClass unityappcontroller = new Unity
Editor.XCodeEditor.XClass (path + "/classes/unityappcontroller.mm"); Adds a line of code after the specified code unityappcontroller.writebelow ("#include \" pluginbase/appdelegatelistener.h\ "", "\n#import <xxxx
.h> ");
Google Login String Adinitcds = "//google login \ xxxx your code XXXX"; Unityappcontroller.writebelow ("Appcontroller_sendnotificationwitharg (Kunityonopenurl, notifData); \ n", AdInitCds)
; -(void) application: (uiapplication*) Application didfinishlaunchingwithoptions: (Nullable nsdictionary*)
Launchoptions string Adfaceinitcds = "//facebook login \ xxxx your code XXXX";
Unityappcontroller.writebelow ("[Keyboarddelegate initialize];\n", Adfaceinitcds);
String Adfacebookinitcds = "//facebook login \ xxxx your code XXXX";
Unityappcontroller.writebelow ("_didresignactive = false;\n", Adfacebookinitcds); }
Here is Xcodeapi set urlschemes code, my top code is to imitate this write.
There is also a reference to a third party library is not tested, have the opportunity to learn.