Skip to content

Commit 5db7582

Browse files
authored
Update casconfig.rb script 1.3 (#11)
2 parents abab923 + 7f7288a commit 5db7582

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

Script XCodeConfig/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CAS.AI iOS XCode Config script change log
22

3+
# [1.3] - Jan 30, 2024
4+
- Added support new `PBXFileSystemSynchronizedRootGroup` from XCode 16.
5+
- Removed `MyTargetSDKAutoInitMode` property from Info.plist.
6+
37
# [1.2] - Feb 28, 2024
48
- Update `NSUserTrackingUsageDescription` value to `Your data will remain confidential and will only be used to provide you a better and personalised ad experience`.
59

Script XCodeConfig/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The script automatically performs the following integration steps:
1414
> Read more about it on [wiki page](https://github.com/cleveradssolutions/CAS-iOS/wiki/Manually-configure-project).
1515
1616
## Getting Started
17-
1. Download the [casconfig.rb](https://github.com/cleveradssolutions/CAS-iOS/releases/download/3.5.6/casconfig.rb)
17+
1. Download the [casconfig.rb](https://github.com/cleveradssolutions/CAS-iOS/releases/download/3.9.9/casconfig.rb)
1818
3. Place the script in directory with the app `.xcodeproj`
1919
4. Open the terminal window and run command:
2020
```

Script XCodeConfig/casconfig.rb

+16-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module CASConfig
1414
ARG_HELP = '--help'
1515

1616
XC_PROJECT_FILE = '.xcodeproj'
17-
SCRIPT_VERSION = '1.2'
17+
SCRIPT_VERSION = '1.3'
1818

1919
class << self
2020
attr_accessor :casId, :project_path, :gad_included, :clean_install
@@ -307,20 +307,27 @@ def set_setting(key, value)
307307
@is_dirt = true
308308
end
309309

310-
def new_file(name, group)
310+
def get_path_to_new_file(name, group)
311311
@is_dirt = true
312-
if group == '.'
313-
return @project.new_file(name)
312+
if group.nil?
313+
xcFile = @project.new_file(name)
314+
@mainTarget.add_resources([xcFile])
315+
return xcFile.full_path.to_s
316+
elsif group.isa == 'PBXFileSystemSynchronizedRootGroup'
317+
return File.join(@project.path.dirname, group.display_name, name)
314318
else
315-
return @project[group].new_file(name)
319+
xcFile = group.new_file(name)
320+
@mainTarget.add_resources([xcFile])
321+
return xcFile.full_path.to_s
316322
end
317323
end
318324

319325
def get_plist_path()
320326
path = get_setting("INFOPLIST_FILE")
321327
if path.empty?
322-
path = @project.groups.find{ |group| !group.path.empty? }.new_file("Info.plist").full_path.to_s
328+
path = get_path_to_new_file("Info.plist", @project.groups.find{ |group| !group.path.empty? })
323329
set_setting("INFOPLIST_FILE", path)
330+
return path
324331
end
325332
if path.start_with?("$(SRCROOT)/")
326333
return path["$(SRCROOT)/".length..]
@@ -336,10 +343,9 @@ def check_config_file(configBody, configName)
336343

337344
if CASConfig.file_expired?(filePath)
338345
CASConfig.success "- Config file has been " + (if File.exist?(filePath) then "updated" else "created" end)
339-
puts " " + CASConfig.thin_text(filePath)
340-
xcFile = new_file(configName, groupPath)
341-
File.open(xcFile.real_path, 'w') { |file| file.write(configBody) }
342-
@mainTarget.add_resources([xcFile])
346+
newFilePath = get_path_to_new_file(configName, @project[groupPath])
347+
puts " " + CASConfig.thin_text(newFilePath)
348+
File.open(newFilePath, 'w') { |file| file.write(configBody) }
343349
else
344350
puts "- Config file is up-to-date"
345351
end
@@ -353,7 +359,6 @@ class ProjectPlist
353359
KEY_ALLOWS_LOADS = "NSAllowsArbitraryLoads"
354360
KEY_GAD_APP_ID = "GADApplicationIdentifier"
355361
KEY_GAD_DELAY_INIT = "GADDelayAppMeasurementInit"
356-
KEY_MYTARGET_AUTO_INIT = "MyTargetSDKAutoInitMode"
357362
KEY_TRACKING_USAGE = "NSUserTrackingUsageDescription"
358363
KEY_BOUND_DOMAINS = "WKAppBoundDomains"
359364

@@ -421,7 +426,6 @@ def check_google_app_Id(casConfig)
421426
if currAppId != requiredAppId
422427
@plist[KEY_GAD_APP_ID] = requiredAppId
423428
@plist[KEY_GAD_DELAY_INIT] = true
424-
@plist[KEY_MYTARGET_AUTO_INIT] = false
425429
@is_dirt = true
426430
CASConfig.success("- " + KEY_GAD_APP_ID + " has been " + (if currAppId.nil? then "added" else "updated" end))
427431
puts " required for Google AdMob network. Use " + ARG_NO_GAD + " option if app doesn't use AdMob"

0 commit comments

Comments
 (0)