@@ -20,7 +20,6 @@ import wiish/building/buildutil
20
20
21
21
const
22
22
CODE_SIGN_IDENTITY_VARNAME = " WIISH_IOS_SIGNING_IDENTITY"
23
- PROVISIONING_PROFILE_VARNAME = " WIISH_IOS_PROVISIONING_PROFILE_PATH"
24
23
SIMULATOR_APP = " /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
25
24
26
25
var
@@ -314,6 +313,7 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
314
313
sh " plutil" , " -convert" , " json" , pbxproj_path
315
314
var pbx = readFile(pbxproj_path).parseJson()
316
315
let build_version = now().format(" yyyyMMddHHmmss" )
316
+ let provisioning_profile_id = ctx.config.get(MaciOSConfig).provisioning_profile_id
317
317
for (key,obj) in pbx[" objects" ].pairs():
318
318
var buildSettings = obj.getOrDefault(" buildSettings" )
319
319
if not buildSettings.isNil:
@@ -323,6 +323,10 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
323
323
if buildSettings.hasKey(" CURRENT_PROJECT_VERSION" ):
324
324
buildSettings[" CURRENT_PROJECT_VERSION" ] = % build_version
325
325
ctx.log & " set CURRENT_PROJECT_VERSION to { build_version} "
326
+ if provisioning_profile_id != " " :
327
+ if buildSettings.hasKey(" PROVISIONING_PROFILE_SPECIFIER" ):
328
+ buildSettings[" PROVISIONING_PROFILE_SPECIFIER" ] = % provisioning_profile_id
329
+ ctx.log & " set PROVISIONING_PROFILE_SPECIFIER to { provisioning_profile_id} "
326
330
if obj.hasKey(" productName" ):
327
331
obj[" productName" ] = % ctx.config.name
328
332
ctx.log & " set productName to { ctx.config.name} "
@@ -377,17 +381,19 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
377
381
" build" ,
378
382
" CONFIGURATION_BUILD_DIR=" & ctx.dist_dir.absolutePath,
379
383
]
384
+ let prov_profile_id = ctx.config.get(MaciOSConfig).provisioning_profile_id
385
+ if prov_profile_id != " " :
386
+ args.add @ [
387
+ " PROVISIONING_PROFILE=" & prov_profile_id
388
+ ]
380
389
ctx.log args.join(" " )
381
390
sh(args)
382
391
of PostBuild:
383
392
if ctx.targetFormat == targetIosIpa:
384
393
ctx.logStartStep()
385
394
let export_plist_path = ctx.build_dir.absolutePath / " ExportOptions.plist"
386
395
if not existsFile(export_plist_path):
387
- var prov_profile = getEnv(PROVISIONING_PROFILE_VARNAME, " " )
388
- var prov_profile_name = " "
389
- if prov_profile != " " :
390
- prov_profile_name = prov_profile.getProvisioningProfileName()
396
+ var prov_profile_name = ctx.config.get(MaciOSConfig).provisioning_profile_id
391
397
export_plist_path.writeFile(fmt"""
392
398
<?xml version="1.0" encoding="UTF-8"?>
393
399
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -422,36 +428,6 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
422
428
sh(args)
423
429
of PrePackage:
424
430
discard
425
- # if not ctx.simulator:
426
- # ctx.logStartStep
427
- # # provisioning profile
428
- # var prov_profile = getEnv(PROVISIONING_PROFILE_VARNAME, "")
429
- # if prov_profile == "":
430
- # let options = listProvisioningProfiles()
431
- # if options.len > 0:
432
- # debug &"Since {PROVISIONING_PROFILE_VARNAME} was not set, choosing a provisioning profile at random ..."
433
- # prov_profile = options[0]
434
- # else:
435
- # raise newException(CatchableError, "No provisioning profile set. Run 'wiish doctor' for instructions.")
436
-
437
- # let dst = ctx.app_dir/"embedded.mobileprovision"
438
- # ctx.log &"Copying '{prov_profile}' to '{dst}'"
439
- # copyFile(prov_profile, dst)
440
-
441
- # # Extract entitlements from provisioning profile and put them in the signature
442
- # let prov_guts = prov_profile.readFile()
443
- # let i_prestart = prov_guts.find("<key>Entitlements")
444
- # let i_start = prov_guts.find("<dict>", i_prestart)
445
- # let i_end = prov_guts.find("</dict>", i_start) + "</dict>".len
446
- # let entitlements = prov_guts[i_start .. i_end]
447
- # writeFile(ctx.entitlements_file, &"""
448
- # <?xml version="1.0" encoding="UTF-8"?>
449
- # <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
450
- # <plist version="1.0">
451
- # {entitlements}
452
- # </plist>
453
- # """)
454
- # ctx.log &"Wrote {ctx.entitlements_file}"
455
431
of Package:
456
432
discard
457
433
of PostPackage:
@@ -572,26 +548,26 @@ proc checkDoctor*(): seq[DoctorResult] =
572
548
if identities.len > 0 :
573
549
dr.fix.add(& " For instance: { CODE_SIGN_IDENTITY_VARNAME} ='{ identities[0 ].fullname} ' might work. " )
574
550
575
- result .dr " standard" , " provisioning-profile" :
576
- dr.targetOS = {Ios}
577
- if getEnv(PROVISIONING_PROFILE_VARNAME, " " ) == " " :
578
- dr.status = NotWorking
579
- dr.error = " No provisioning profile chosen for iOS code signing"
580
- dr.fix = & """ Set { PROVISIONING_PROFILE_VARNAME} to the path of a valid provisioning profile. They can be found in '{ PROV_PROFILE_DIR} ' """
581
- let possible_profiles = listProvisioningProfiles()
582
- if possible_profiles.len == 0 :
583
- dr.fix.add("""
584
- You *might* be able to create such a profile by:
585
- 1. Opening Xcode
586
- 2. Creating a blank iOS project
587
- 3. Enabling 'Automatically manage signing'
588
- 4. Building the project once.
589
-
590
- TODO: come up with less goofy instructions. """ )
591
- else :
592
- dr.fix.add(" Here are the profiles wiish can identify:\l\l " )
593
- for prof in possible_profiles:
594
- dr.fix.add(& " { prof.extractFilename()} '{ prof.getProvisioningProfileNAme()} '\l " )
551
+ # result.dr "standard", "provisioning-profile":
552
+ # dr.targetOS = {Ios}
553
+ # if getEnv(PROVISIONING_PROFILE_VARNAME, "") == "":
554
+ # dr.status = NotWorking
555
+ # dr.error = "No provisioning profile chosen for iOS code signing"
556
+ # dr.fix = &"""Set {PROVISIONING_PROFILE_VARNAME} to the path of a valid provisioning profile. They can be found in '{PROV_PROFILE_DIR}'"""
557
+ # let possible_profiles = listProvisioningProfiles()
558
+ # if possible_profiles.len == 0:
559
+ # dr.fix.add("""
560
+ # You *might* be able to create such a profile by:
561
+ # 1. Opening Xcode
562
+ # 2. Creating a blank iOS project
563
+ # 3. Enabling 'Automatically manage signing'
564
+ # 4. Building the project once.
565
+
566
+ # TODO : come up with less goofy instructions.""")
567
+ # else:
568
+ # dr.fix.add(" Here are the profiles wiish can identify:\l\l")
569
+ # for prof in possible_profiles:
570
+ # dr.fix.add(&" {prof.extractFilename()} '{prof.getProvisioningProfileNAme()}'\l")
595
571
else :
596
572
result .dr " standard" , " os" :
597
573
dr.targetOS = {Ios,IosSimulator}
0 commit comments