Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:45:02+00:00 2026-05-22T19:45:02+00:00

I want to automatically add files to an Xcode project that is created from

  • 0

I want to automatically add files to an Xcode project that is created from scratch (through another IDE) as a post-build step. Our project is set up to call an applescript that makes the appropriate file references in the project, but every attempt to add the file references to the project fails.

The core problem seems to be this error:
Xcode got an error: file reference id “DCDCC17E13819A8E004B4E75” of Xcode 3 group id “D82DCFB50E8000A5005D6AD8” of project “TestProject” of workspace document “project.xcworkspace” doesn’t understand the add message.

on this line:

add fileRef to first target of testProject

Where fileRef is the variable set to the newly-created file reference, and testProject is the variable set to the project containing the fileRef.

Here is the code:

on run argv

-- Get the folder containing items to be added to the project
tell application "Finder"
    set thisScript to path to me
    set projectFolder to get folder of thisScript as string
    set sourceFolder to projectFolder & "FilesToAdd:"
end tell

-- Get all the files that will be added to Xcode
tell application "System Events"
    set filesToAddList to the name of every disk item of (sourceFolder as alias)
end tell

tell application "Xcode"
    -- Open the project using posix-style paths
    open ((POSIX path of projectFolder) & "TestProject.xcodeproj")

    -- Give Xcode some time to open the project before we start giving it commands
    delay 1

    set testProject to project "TestProject"
    tell testProject
        set sourceGroup to group "Sources"
        tell sourceGroup
            -- Iterate over all files in the list
            repeat with i in filesToAddList

                set fileName to (contents of i)

                -- Get the file path using Unix-style pathing, since that is the kind that Xcode needs
                set filePath to (POSIX path of sourceFolder) & fileName

                -- Don't add duplicate file references
                if filePath is not in path of file references in sourceGroup then
                    -- Add a new file reference to the project
                    set fileRef to make new file reference with properties {name:fileName, full path:filePath, path type:absolute, path:filePath, file encoding:macos roman}

                    -- Add the file reference to the build target
                    add fileRef to first target of testProject
                end if
            end repeat

        end tell -- end group tell

    end tell -- end project tell

end tell -- end app tell

end run

I’ve looked up other examples of adding files to targets, and it seems like this is the cleanest and concise way of doing it, and it seems to have worked for other people in the past. Is there a different way that file references are supposed to be added to targets?

For reference, I’m running OSX 10.6.7 and Xcode 4.0.2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:45:03+00:00Added an answer on May 22, 2026 at 7:45 pm

    So I emailed Apple about this problem, and it turns out to be a bug. I’ve submitted a bug report, so hopefully this issue will get fixed soon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to automatically commit the database when we copy files from one branch
I have an access macro, that I want to run automatically from a batch
I'm doing a Unity-iPhone project, but want to automatically add some native code and
I get poorly formatted invoice-related email from my payment gateway. I want to automatically
I have an index view that I want to update automatically as the user
I want to set my server to automatically build my application upon commit on
I want to generate a classpath automatically with all the *.jar files contained under
Is there a single command that automatically regenerates a git repository? I want to
I am working with source files in C# and I want to add headers
I want to add an ajax:TabContainer to my webpage. I don't get any build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.