@@ -796,23 +796,30 @@ def build_ios(self):
796
796
"\" %s\" " % self .xcworkspace if self .cocoapods else projectPath ,
797
797
"-configuration" ,
798
798
"%s" % 'Debug' if self ._mode == 'debug' else 'Release' ,
799
- "-scheme" if self . cocoapods else "-target" ,
799
+ "-scheme" ,
800
800
"\" %s\" " % targetName ,
801
801
"%s" % "-arch i386" if self .use_sdk == 'iphonesimulator' else '' ,
802
802
"-sdk" ,
803
803
"%s" % self .use_sdk ,
804
804
"CONFIGURATION_BUILD_DIR=\" %s\" " % (output_dir ),
805
805
"%s" % "VALID_ARCHS=\" i386\" " if self .use_sdk == 'iphonesimulator' else ''
806
806
])
807
+
808
+ # PackageApplication is removed since xcode 8.3, should use new method to generate .ipa
809
+ # should generate .xcarchive first, then generate .ipa
810
+ use_new_ipa_method = float (cocos .get_xcode_version ()) >= 8.3
807
811
808
812
if self ._sign_id is not None :
809
- command = "%s CODE_SIGN_IDENTITY=\" %s\" " % (command , self ._sign_id )
813
+ if use_new_ipa_method :
814
+ archive_path = os .path .join (output_dir , "%s.xcarchive" % targetName )
815
+ command = "%s CODE_SIGN_IDENTITY=\" %s\" -archivePath %s archive" % (command , self ._sign_id , archive_path )
816
+ else :
817
+ command = "%s CODE_SIGN_IDENTITY=\" %s\" " % (command , self ._sign_id )
810
818
811
819
command = self .append_xcpretty_if_installed (command )
812
820
self ._run_cmd (command )
813
821
814
822
filelist = os .listdir (output_dir )
815
-
816
823
for filename in filelist :
817
824
name , extention = os .path .splitext (filename )
818
825
if extention == '.a' :
@@ -825,13 +832,22 @@ def build_ios(self):
825
832
826
833
if self ._sign_id is not None :
827
834
# generate the ipa
828
- app_path = os .path .join (output_dir , "%s.app" % targetName )
829
835
ipa_path = os .path .join (output_dir , "%s.ipa" % targetName )
830
- ipa_cmd = "xcrun -sdk %s PackageApplication -v \" %s\" -o \" %s\" " % (self .use_sdk , app_path , ipa_path )
831
- self ._run_cmd (ipa_cmd )
836
+ if use_new_ipa_method :
837
+ # generate exportoptions.plist file if needed
838
+ export_options_plist_path = os .path .join (output_dir , "exportoptions.plist" )
839
+ self ._generate_export_options_plist (export_options_plist_path )
840
+
841
+ archive_path = os .path .join (output_dir , "%s.xcarchive" % targetName )
842
+ ipa_cmd = "xcodebuild -exportArchive -archivePath %s -exportPath %s -exportOptionsPlist %s" % (archive_path , output_dir , export_options_plist_path )
843
+ self ._run_cmd (ipa_cmd )
844
+ else :
845
+ ipa_cmd = "xcrun -sdk %s PackageApplication -v \" %s\" -o \" %s\" " % (self .use_sdk , self ._iosapp_path , ipa_path )
846
+ self ._run_cmd (ipa_cmd )
832
847
833
848
cocos .Logging .info (MultiLanguage .get_string ('COMPILE_INFO_BUILD_SUCCEED' ))
834
- except :
849
+ except Exception , e :
850
+ print str (e )
835
851
raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_BUILD_FAILED' ),
836
852
cocos .CCPluginError .ERROR_BUILD_FAILED )
837
853
finally :
@@ -845,6 +861,32 @@ def build_ios(self):
845
861
if engine_js_dir is not None :
846
862
self .reset_backup_dir (engine_js_dir )
847
863
864
+ def _generate_export_options_plist (self , export_options_plist_path ):
865
+ if os .path .exists (export_options_plist_path ):
866
+ return
867
+
868
+ file_content_head = """
869
+ <?xml version="1.0" encoding="UTF-8"?>
870
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
871
+ <plist version="1.0">
872
+ <dict>
873
+ <key>compileBitcode</key>
874
+ <false/>
875
+ """
876
+
877
+ # should use add-hoc for release mode?
878
+ method = "app-store" if self ._mode == 'release' else "development"
879
+ method_content = "<key>method</key>\n <string>%s</string>" % method
880
+
881
+ file_content_end = """
882
+ </dict>
883
+ </plist>
884
+ """
885
+
886
+ file_content = file_content_head + method_content + file_content_end
887
+ with open (export_options_plist_path , 'w' ) as outfile :
888
+ outfile .write (file_content )
889
+
848
890
def build_mac (self ):
849
891
if not self ._platforms .is_mac_active ():
850
892
return
0 commit comments