igor-makarov / xcake

:cake: Describe Xcode projects in a human readable format and (re)generate one on demand.
MIT License
632 stars 48 forks source link

duplicate Info.plist #221

Closed joprice closed 3 years ago

joprice commented 3 years ago

I tried using this on a new project I created with xcode, but I get the following error:

Showing All Messages
Multiple commands produce '/Users/josephprice/Library/Developer/Xcode/DerivedData/scratch-djiusvaeqgsvgnbvelrbjodrmhpj/Build/Products/Debug-iphoneos/scratch.app/Info.plist':
1) Target 'scratch' (project 'scratch') has copy command from '/Users/josephprice/dev/scratch/scratch/Info.plist' to '/Users/josephprice/Library/Developer/Xcode/DerivedData/scratch-djiusvaeqgsvgnbvelrbjodrmhpj/Build/Products/Debug-iphoneos/scratch.app/Info.plist'
2) Target 'scratch' (project 'scratch') has process command with output '/Users/josephprice/Library/Developer/Xcode/DerivedData/scratch-djiusvaeqgsvgnbvelrbjodrmhpj/Build/Products/Debug-iphoneos/scratch.app/Info.plist'
igor-makarov commented 3 years ago

Could you post your Cakefile? It looks like you have got some Info.plist preprocessing set up.

joprice commented 3 years ago

I'm mostly using the defaults, to see what's actually needed by a empty project:

  project.name = "scratch"
  project.class_prefix = "APP"

  application_for :ios, 9.0 do |target|
      target.name = "scratch"
      target.all_configurations.each { |c| c.product_bundle_identifier = "com.yourcompany.yourapp"}
      unit_tests_for target
  end
igor-makarov commented 3 years ago

You're right, it looks very concise. Do you mind posting the directory structure? Or, perhaps isolate the issue to a demo project?

joprice commented 3 years ago

Here's a new project generated by xcode with a cakefile added: https://github.com/joprice/cakefile-test

igor-makarov commented 3 years ago

Hah, I see what the problem is. It seems an Xcode bug. Xcake generates the project with the assumption that the Info.plist is located at ${TARGET_NAME}/Supporting Files/Info.plist.

In the project you've created, the file is located at ${TARGET_NAME}/Info.plist. Because this is not the conventional location, the .plist file is handled as a regular resource file.

Xcode sees that both the resource step and the build config produce the same file, and raises an error. It should have failed in an earlier stage, since ${TARGET_NAME}/Supporting Files/Info.plist doesn't exist.

You can fix the issue you're experiencing easily by:

  project.name = "scratch"
  project.class_prefix = "APP"

  application_for :ios, 9.0 do |target|
      target.name = "scratch"
      target.all_configurations.each do |c| 
         c.product_bundle_identifier = "com.yourcompany.yourapp"
         c.settings['INFOPLIST_FILE'] = "scratchpad/Info.plist"
      end
      unit_tests_for target
  end

Alternatively, you could create a Supporting Files folder under your target and place the Info.plist there.

joprice commented 3 years ago

I tried that and I'm getting the same error. I removed the tests as well to simplify it further.

igor-makarov commented 3 years ago

My bad, the target is scratchpad - right? I wrote scratch because I copied from an earlier comment. Updated the comment to fix.

joprice commented 3 years ago

Oops I had two repos with those names that I was switching between. It works now. Thank you!

joprice commented 3 years ago

I must be missing something else, because the project does not seem to be runnable. I had to edit the scheme and set an executable. That added this new xml block:

<BuildableProductRunnable
         runnableDebuggingMode = "0">
   <BuildableReference
      BuildableIdentifier = "primary"
      BlueprintIdentifier = "630E33D4FA80670ADCA7CBE6"
      BuildableName = "scratchpad.app"
      BlueprintName = "scratchpad"
      ReferencedContainer = "container:scratchpad.xcodeproj">
   </BuildableReference>
</BuildableProductRunnable>

Has the scheme format changed in the xcode 12?

igor-makarov commented 3 years ago

Yeah, I looked at it and it seems that Xcode has changed its expectations of schemes, again.

Personally, I use an .xcworkspace and keep my schemes in it (without generation by Xcake). These files aren't large and change very infrequently, making keeping them in git not too troublesome.

samuelsainz commented 1 year ago

@igor-makarov hey Igor, is there a way to prevent Xcake from creating the xcschemes that it creates by default? I am deleting the generated xcschemes using the after_save hook but I'm wondering if there's a better way to do that