Skip to content

Commit

Permalink
优化iOS xcodesetting工具,兼容unity2019的xcode工程
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuachen committed Nov 12, 2021
1 parent 39ad85e commit 390dcb7
Show file tree
Hide file tree
Showing 262 changed files with 1,437 additions and 8,908 deletions.
11 changes: 10 additions & 1 deletion publish/ios/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ function __buildIPA(){
targetname=Unity-iPhone
xcodeprojname=$targetname.xcodeproj
xcodeproj=${tempXcodeDir}/$xcodeprojname

UNITY_VER=2018
if [ -d "${tempXcodeDir}/UnityFramework/" ];then
UNITY_VER=2019
fi

array=(${ipatypes//,/ })
for var in ${array[@]}
Expand All @@ -229,7 +234,11 @@ function __buildIPA(){
echo -e "</plist>">>$ExportOptionsPlist

xcodebuild clean -project $xcodeproj -configuration Release -alltargets
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$var.xcarchive CODE_SIGN_IDENTITY="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE=$PROVISIONING_PROFILE
if [ ${UNITY_VER} == 2019 ];then
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$var.xcarchive clean archive CODE_SIGN_IDENTITY_APP="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE_APP=$PROVISIONING_PROFILE
else
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$var.xcarchive clean archive CODE_SIGN_IDENTITY="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE=$PROVISIONING_PROFILE
fi
xcodebuild -exportArchive -archivePath build/$targetname-$var.xcarchive -exportOptionsPlist $ExportOptionsPlist -exportPath ipa
done
}
Expand Down
48 changes: 11 additions & 37 deletions publish/ios/buildJenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,46 +203,15 @@ function __buildUnity2Xcode(){

#构建ipa包
function __buildIPA(){
ipatypes=( $( __getPublishProperties ipatypes ) )
targetname=Unity-iPhone
xcodeprojname=$targetname.xcodeproj
xcodeproj=${tempXcodeDir}/$xcodeprojname

array=(${ipatypes//,/ })
for var in ${array[@]}
do
CODE_SIGN_IDENTITY=( "$( __readINI ${global_properties} CODE_SIGN_IDENTITY $var )" )
PROVISIONING_PROFILE=( "$( __readINI ${global_properties} PROVISIONING_PROFILE $var )" )
time=$(date "+%Y%m%d%H%M%S")

echo -e "\n------------build ipa,please wait------------"
ExportOptionsPlist=${tempXcodeDir}/ExportOptionsPlist.plist
echo -e "<plist version=\"1.0\">">$ExportOptionsPlist
echo -e "<dict>">>$ExportOptionsPlist
echo -e " <key>provisioningProfiles</key>">>$ExportOptionsPlist
echo -e " <dict>">>$ExportOptionsPlist
echo -e " <key>${package}</key>">>$ExportOptionsPlist
echo -e " <string>$PROVISIONING_PROFILE</string>">>$ExportOptionsPlist
echo -e " </dict>">>$ExportOptionsPlist
echo -e " <key>method</key>">>$ExportOptionsPlist
echo -e " <string>$var</string>">>$ExportOptionsPlist
echo -e " <key>uploadBitcode</key>">>$ExportOptionsPlist
echo -e " <false/>">>$ExportOptionsPlist
echo -e "</dict>">>$ExportOptionsPlist
echo -e "</plist>">>$ExportOptionsPlist

xcodebuild clean -project $xcodeproj -configuration Release -alltargets
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$var.xcarchive CONFIGURATION_BUILD_DIR=$tempXcodeDir/configuration CODE_SIGN_IDENTITY="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE=$PROVISIONING_PROFILE
xcodebuild -exportArchive -archivePath build/$targetname-$var.xcarchive -exportOptionsPlist $ExportOptionsPlist -exportPath ipa
done
}
UNITY_VER=2018
if [ -d "${tempXcodeDir}/UnityFramework/" ];then
UNITY_VER=2019
fi

#构建ipa包
function __buildIPA2(){
targetname=Unity-iPhone
xcodeprojname=$targetname.xcodeproj
xcodeproj=${tempXcodeDir}/$xcodeprojname

CODE_SIGN_IDENTITY=( "$( __readINI ${global_properties} CODE_SIGN_IDENTITY $IPAType )" )
PROVISIONING_PROFILE=( "$( __readINI ${global_properties} PROVISIONING_PROFILE $IPAType )" )
time=$(date "+%Y%m%d%H%M%S")
Expand All @@ -264,7 +233,12 @@ function __buildIPA2(){
echo -e "</plist>">>$ExportOptionsPlist

xcodebuild clean -project $xcodeproj -configuration Release -alltargets
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$IPAType.xcarchive CONFIGURATION_BUILD_DIR=$tempXcodeDir/configuration CODE_SIGN_IDENTITY="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE=$PROVISIONING_PROFILE
if [ ${UNITY_VER} == 2019 ];then
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$IPAType.xcarchive clean archive CONFIGURATION_BUILD_DIR=$tempXcodeDir/configuration CODE_SIGN_IDENTITY_APP="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE_APP=$PROVISIONING_PROFILE
else
xcodebuild archive -project $xcodeproj -scheme $targetname -configuration Release -archivePath build/$targetname-$IPAType.xcarchive clean archive CONFIGURATION_BUILD_DIR=$tempXcodeDir/configuration CODE_SIGN_IDENTITY_="$CODE_SIGN_IDENTITY" PROVISIONING_PROFILE_=$PROVISIONING_PROFILE
fi

xcodebuild -exportArchive -archivePath build/$targetname-$IPAType.xcarchive -exportOptionsPlist $ExportOptionsPlist -exportPath ipa
}

Expand All @@ -281,7 +255,7 @@ function __main(){

__showVersion
__buildUnity2Xcode
__buildIPA2
__buildIPA
}

__main
14 changes: 12 additions & 2 deletions publish/ios/publish.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
;none 渠道
[none-default]
;ipa证书类型,可支持多个类型同时出包,多个类型之间用半角逗号隔开
ipatypes=development
package=com.test.ios
appname=裸包
;需要打入包内的插件名称,多个插件之间用半角逗号隔开
plugins=

;test 渠道
[none-test]
;ipa证书类型,可支持多个类型同时出包,多个类型之间用半角逗号隔开
ipatypes=app-store
package=com.sloth.domina.ios
appname=轩辕战刃
package=com.test.ios
appname=裸包
;需要打入包内的插件名称,多个插件之间用半角逗号隔开
;Bugly插件里面包含了cocoapods的示例
plugins=Bugly
10 changes: 9 additions & 1 deletion publish/ios/sdk/platforms/none/module/XcodeSetting.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@
"src": "Libraries/Plugins/iOS/none"
},
"filesCompileFlag": {},
"capabilitys": {}
"capabilitys": {
"SignInWithApple": [],
"PushNotifications": [
true
],
"BackgroundModes": [
"RemoteNotifications"
]
}
}
34 changes: 19 additions & 15 deletions publish/ios/sdk/usdk/module/XcodeSetting.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
{
"libs":{
"+":["libc++.tbd"],
"-":[]
"libs": {
"+": [
"libc++.tbd"
],
"-": []
},
"frameworks":{
"+":[],
"-":[]
"frameworks": {
"+": [],
"-": []
},
"properties":{
"=":{},
"+":{},
"-":{}
"properties": {
"=": {},
"+": {},
"-": {}
},
"plist":{},
"files":{},
"folders":{
"src":"Libraries/Plugins/iOS/Usdk"
"plist": {
"ITSAppUsesNonExemptEncryption": "false"
},
"filesCompileFlag":{}
"files": {},
"folders": {
"src": "Libraries/Plugins/iOS/Usdk"
},
"filesCompileFlag": {}
}
Binary file modified publish/ios/tools/XcodeSetting.exe
Binary file not shown.
Binary file modified publish/ios/tools/XcodeSetting/.vs/XcodeSetting/v16/.suo
Binary file not shown.
Binary file not shown.
40 changes: 20 additions & 20 deletions publish/ios/tools/XcodeSetting/Cocoapods/IOSResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Threading;
using System.Xml;
using GooglePlayServices;
using UnityEditor.iOS.Xcode.Custom;
using UnityEditor.iOS.Xcode;

namespace Google {
public class IOSResolver {
Expand Down Expand Up @@ -361,9 +361,9 @@ public static bool CocoapodsIntegrationEnabled {

private static string TargetSdk {
get {
List<string> val = GetBuildSettingProperties ("IPHONEOS_DEPLOYMENT_TARGET");
if (val.Count > 0)
return val[0];
string val = GetBuildSettingProperties ("IPHONEOS_DEPLOYMENT_TARGET");
if (!string.IsNullOrEmpty(val))
return val;
return "8.2";
}
set {
Expand All @@ -386,7 +386,18 @@ private static int TargetSdkVersion {
private static string configPath;

public static void Init (string xcodePath, string configPath) {
IOSResolver.xcodePath = xcodePath;
//plist
string plistPath = xcodePath + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
plistRootDict = plist.root;

//build setting
string projPath = PBXProject.GetPBXProjectPath(xcodePath);
proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));

IOSResolver.xcodePath = xcodePath;
IOSResolver.configPath = configPath;

IOSResolver.pods = new SortedDictionary<string, IOSResolver.Pod> ();
Expand Down Expand Up @@ -444,22 +455,11 @@ public static void Init (string xcodePath, string configPath) {
if (IOSResolver.AutoPodToolInstallInEditorEnabled && IOSResolver.CocoapodsIntegrationEnabled && !ExecutionEnvironment.InBatchMode) {
IOSResolver.AutoInstallCocoapods ();
}

//plist
string plistPath = xcodePath + "/Info.plist";
PlistDocument plist = new PlistDocument ();
plist.ReadFromString (File.ReadAllText (plistPath));
plistRootDict = plist.root;

//build setting
string projPath = PBXProject.GetPBXProjectPath (xcodePath);
proj = new PBXProject ();
proj.ReadFromString (File.ReadAllText (projPath));
}

private static List<string> GetBuildSettingProperties (string key) {
string target = proj.TargetGuidByName (PBXProject.GetUnityTargetName ());
return proj.GetBuildProperty (target, key);
private static string GetBuildSettingProperties (string key) {
string target = proj.TargetGuidByName (IOSResolver.TARGET_NAME);
return proj.GetBuildPropertyForAnyConfig(target, key);
}

private static List<string> FindFile (string searchPath, string fileToFind, int maxDepth, int currentDepth = 0) {
Expand Down Expand Up @@ -488,7 +488,7 @@ private static List<string> FindFile (string searchPath, string fileToFind, int
}

private static void InitializeTargetName () {
IOSResolver.TARGET_NAME = PBXProject.GetUnityTargetName ();
IOSResolver.TARGET_NAME = proj.GetTargetName ();
}

internal static void Log (string message, bool verbose = false, LogLevel level = LogLevel.Info) {
Expand Down
Loading

0 comments on commit 390dcb7

Please sign in to comment.