Skip to content

Commit 07645b8

Browse files
committed
Provisioning profile fixes
1 parent ce40525 commit 07645b8

File tree

4 files changed

+35
-58
lines changed

4 files changed

+35
-58
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You can set the provisioning_profile_id rather than a path to the file now

examples/webview/wiish_build.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var wb = WiishBuild(
1616
c.category_type = "public.app-category.example"
1717
cfg.with(MaciOSConfig, c):
1818
c.sdk_version = ""
19-
c.provisioning_profile = ""
19+
c.provisioning_profile_id = ""
2020
cfg.with(AndroidConfig, c):
2121
c.java_package_name = "org.wiish.webviewexample"
2222
)

wiish/building/config.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type
7272
7373
MaciOSConfig* = ref object
7474
sdk_version*: string
75-
provisioning_profile*: string
75+
provisioning_profile_id*: string
7676
7777
AndroidArchPair = tuple
7878
abi: string
@@ -114,7 +114,7 @@ extend(MacDesktopConfig, MacDesktopConfig(
114114
)
115115
extend(MaciOSConfig, MaciOSConfig(
116116
sdk_version: "",
117-
provisioning_profile: "",
117+
provisioning_profile_id: "",
118118
)
119119
)
120120
extend(AndroidConfig, AndroidConfig(

wiish/plugins/standard/build_ios.nim

Lines changed: 31 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import wiish/building/buildutil
2020

2121
const
2222
CODE_SIGN_IDENTITY_VARNAME = "WIISH_IOS_SIGNING_IDENTITY"
23-
PROVISIONING_PROFILE_VARNAME = "WIISH_IOS_PROVISIONING_PROFILE_PATH"
2423
SIMULATOR_APP = "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
2524

2625
var
@@ -314,6 +313,7 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
314313
sh "plutil", "-convert", "json", pbxproj_path
315314
var pbx = readFile(pbxproj_path).parseJson()
316315
let build_version = now().format("yyyyMMddHHmmss")
316+
let provisioning_profile_id = ctx.config.get(MaciOSConfig).provisioning_profile_id
317317
for (key,obj) in pbx["objects"].pairs():
318318
var buildSettings = obj.getOrDefault("buildSettings")
319319
if not buildSettings.isNil:
@@ -323,6 +323,10 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
323323
if buildSettings.hasKey("CURRENT_PROJECT_VERSION"):
324324
buildSettings["CURRENT_PROJECT_VERSION"] = % build_version
325325
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}"
326330
if obj.hasKey("productName"):
327331
obj["productName"] = % ctx.config.name
328332
ctx.log &"set productName to {ctx.config.name}"
@@ -377,17 +381,19 @@ proc iosRunStep*(step: BuildStep, ctx: ref BuildContext) =
377381
"build",
378382
"CONFIGURATION_BUILD_DIR=" & ctx.dist_dir.absolutePath,
379383
]
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+
]
380389
ctx.log args.join(" ")
381390
sh(args)
382391
of PostBuild:
383392
if ctx.targetFormat == targetIosIpa:
384393
ctx.logStartStep()
385394
let export_plist_path = ctx.build_dir.absolutePath / "ExportOptions.plist"
386395
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
391397
export_plist_path.writeFile(fmt"""
392398
<?xml version="1.0" encoding="UTF-8"?>
393399
<!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) =
422428
sh(args)
423429
of PrePackage:
424430
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}"
455431
of Package:
456432
discard
457433
of PostPackage:
@@ -572,26 +548,26 @@ proc checkDoctor*(): seq[DoctorResult] =
572548
if identities.len > 0:
573549
dr.fix.add(&"For instance: {CODE_SIGN_IDENTITY_VARNAME}='{identities[0].fullname}' might work.")
574550

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")
595571
else:
596572
result.dr "standard", "os":
597573
dr.targetOS = {Ios,IosSimulator}

0 commit comments

Comments
 (0)