CocoaPods / CocoaPods/Xcodeproj
Using Xcodeproj as part of Xcode run script doesn't work
- Dominant language
- Ruby
- Stars
- 2.4k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to use this gem as part of a run script in Xcode to move some files around before compilation, but I can't seem to get it to work and am wondering if it's possible at all.
My `manage_unit_tests` script starts like this:
```ruby
#!/usr/bin/env ruby
require 'json'
require 'xcodeproj'
root_path = ARGV[0]
project_path = "#{root_path}/Project.xcodeproj"
unit_test_file_path = "#{root_path}/ProjectTests/Supporting Files/One.xctestplan"
snapshot_test_file_path = "#{root_path}/ProjectTests/Supporting Files/Two.xctestplan"
project = Xcodeproj::Project.open(project_path)
...
```
My build phase in Xcode looks like:
```bash
$SRCROOT/script/tests/manage_unit_tests.rb $SRCROOT
```
When I build, I get the following error:
```
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `match': invalid byte sequence in US-ASCII (ArgumentError)
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `match'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `file_in_conflict?'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:20:in `read_from_path'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:211:in `initialize_from_file'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open'
from /Users/user/Documents/Code/Project/script/tests/manage_unit_tests.rb:9:in `'
```
The script runs fine when it's not part of a run script phase, so maybe this just isn't possible and I need to move it to run as part of a pre-commit hook, but I thought I'd ask here
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure by running script/tests/manage_unit_tests.rb from the Xcode run-script phase and compare it with standalone execution. Read lib/xcodeproj/plist.rb around line 91 and the Xcodeproj::Project.open path in lib/xcodeproj/project.rb, then trace the differing environment or encoding behavior. Done means identifying whether this invocation is supported and documenting or correcting the failing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100