• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How can I programmatically add build files to Xcode4?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How can I programmatically add build files to Xcode4?


  • Subject: How can I programmatically add build files to Xcode4?
  • From: Jeff Stedfast <email@hidden>
  • Date: Tue, 27 Sep 2011 15:09:38 -0400

Hi all,

I've been trying to figure out how to programmatically add files to an Xcode4 project and it seemed like AppleScript would be the way to go, however I'm running into "missing value" errors.

Here's the code I've got:

tell application "Xcode"
    set theProject to first project
    set theTarget to first target of theProject
    set theBuildPhase to compile sources phase of theTarget
    tell first group of theProject
        set theFileRef to make new file reference with properties {full path:"/Users/jeff/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
        add theFileRef to theProject
    end tell
    --tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell

I've tried the commented-out line instead of the add-command as well, but that doesn't work either (I get "missing value").

The 'add' error is:

error "Xcode got an error: file reference id \"251AD3431432472E006E300F\" of Xcode 3 group id \"251AD32C14324645006E300F\" of project \"XcodeTest\" of workspace document \"XcodeTest.xcodeproj/project.xcworkspace\" doesn’t understand the add message." number -1708 from file reference id "251AD3431432472E006E300F" of Xcode 3 group id "251AD32C14324645006E300F" of project "XcodeTest" of workspace document "XcodeTest.xcodeproj/project.xcworkspace"

The "make new reference" does add the file to the list of files in Xcode, but I also need it to be added to the project target so that I can add actions and outlets to the file from Xcode w/o having to first check the checkbox to add it to the "target membership".


Can anyone give me any clues on how to do this? I've spent days trying to figure this out trying everything I could think of and googling around for solutions but none of the solutions I've found seem to work in Xcode4 (all the solutions I've found for similar problems were from 2008 and 2005, long before Xcode4 was released).

Any help would be greatly appreciated!


Thanks,

Jeff

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How can I programmatically add build files to Xcode4?
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: iPad Simulator Intermittent Crash When Accessing Settings
  • Next by Date: Re: nssplitview thin divider?
  • Previous by thread: Re: nssplitview thin divider?
  • Next by thread: Re: How can I programmatically add build files to Xcode4?
  • Index(es):
    • Date
    • Thread