Skip to content

Commit

Permalink
Merge pull request #940 from Werelds/fix/optional-includes
Browse files Browse the repository at this point in the history
fix: Support optional includes
  • Loading branch information
segiddins committed Jul 22, 2024
2 parents a234cae + 0f3db67 commit fe55cf5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/xcodeproj/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def strip_comment(line)
# @return [Nil] if no include was found in the line.
#
def extract_include(line)
regexp = /#include\s*"(.+)"/
regexp = /#include\??\s*"(.+)"/
match = line.match(regexp)
match[1] if match
end
Expand Down
6 changes: 6 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ def filename.open(mode)
config.includes.first.should.be.equal 'Somefile.xcconfig'
end

it 'contains file path refs to optional included xcconfigs' do
config = Xcodeproj::Config.new(fixture_path('optional-include.xcconfig'))
config.includes.size.should.be.equal 1
config.includes.first.should.be.equal 'Optional.xcconfig'
end

it 'contains file path refs to all included xcconfigs, even without the extension added' do
config = Xcodeproj::Config.new(fixture_path('config-with-include-no-extension.xcconfig'))
config.includes.size.should.be.equal 1
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/optional-include.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include? "Optional.xcconfig"

0 comments on commit fe55cf5

Please sign in to comment.