forked from hodlwallet/hodl-wallet-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toggleTestnetBundleId
executable file
·53 lines (46 loc) · 2.45 KB
/
toggleTestnetBundleId
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
require 'xcodeproj'
project_path = './dogecwallet.xcodeproj'
$project = Xcodeproj::Project.open(project_path)
$production_id = 'co.dogecwallet.dev'
$development_id = 'co.dogecwallet.dev-testnet'
desired_targets = ['dogecwallet', 'dogecwallet WatchKit App', 'dogecwallet WatchKit Extension', 'MessagesExtension', 'TodayExtension', 'NotificationServiceExtension']
targets = $project.native_targets.select { |target| desired_targets.include? target.name }
targets.each do |target|
config = target.build_configurations.first
bundle_id = config.build_settings['PRODUCT_BUNDLE_IDENTIFIER']
if bundle_id.include? $production_id
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = bundle_id.gsub($production_id, $development_id)
elsif bundle_id.include? $development_id
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = bundle_id.gsub($development_id, $production_id)
end
end
def toggleWatchTargetCompanionId()
watch_target = $project.native_targets.find { |target| target.name == 'dogecwallet WatchKit App'}
config = watch_target.build_configurations.first
plist_path = config.build_settings['INFOPLIST_FILE']
plist = Xcodeproj::Plist.read_from_path(plist_path)
companion_bundle_id = plist['WKCompanionAppBundleIdentifier']
if companion_bundle_id.include? $production_id
plist['WKCompanionAppBundleIdentifier'] = companion_bundle_id.gsub($production_id, $development_id)
elsif companion_bundle_id.include? $development_id
plist['WKCompanionAppBundleIdentifier'] = companion_bundle_id.gsub($development_id, $production_id)
end
Xcodeproj::Plist.write_to_path(plist, plist_path)
end
def toggleWatchExtensionId()
watch_extension_target = $project.native_targets.find { |target| target.name == 'dogecwallet WatchKit Extension'}
config = watch_extension_target.build_configurations.first
plist_path = config.build_settings['INFOPLIST_FILE']
plist = Xcodeproj::Plist.read_from_path(plist_path)
bundle_id = plist['NSExtension']['NSExtensionAttributes']['WKAppBundleIdentifier']
if bundle_id.include? $production_id
plist['NSExtension']['NSExtensionAttributes']['WKAppBundleIdentifier'] = bundle_id.gsub($production_id, $development_id)
elsif bundle_id.include? $development_id
plist['NSExtension']['NSExtensionAttributes']['WKAppBundleIdentifier'] = bundle_id.gsub($development_id, $production_id)
end
Xcodeproj::Plist.write_to_path(plist, plist_path)
end
toggleWatchTargetCompanionId()
toggleWatchExtensionId()
$project.save