• 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
Re: adding file reference via applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: adding file reference via applescript


  • Subject: Re: adding file reference via applescript
  • From: Dmitry Markman <email@hidden>
  • Date: Thu, 17 Nov 2005 01:28:47 -0500

it looks like everything works with the following procedure

1. duplicate empty template project (so all target's properties are set)
2. set desirable name for the duplicate
3. add groups and files into the project (no additional rules about *.cpp/*.c files needed)
4. close the project
5. open the project again
6. add file references into the target


____________________________________

tell application "Xcode"
	quit
end tell
delay 1
...
set project_new_path to POSIX file posix_project_new_path
...
tell application "Finder"
...
	set new_project to item project_new_path
...
end tell

tell application "Xcode"
...
open new_project
...
tell src_simulink_group
...
set new_group to make new group with properties ¬
{name:name of sim_folder, full path:full_folder_path, path:name of sim_folder}
...
end tell
...
tell new_group
set new_file to make new file reference with properties {file kind:"sourcecode.cpp.cpp", name:file_name, file encoding:macos roman, full path:full_file_path, path:file_name}
end tell


...

	close every project document
	delay 1

	open new_project

	add new_file to simulink_target
	quit
end tell




On Nov 16, 2005, at 2:41 PM, Rick Ballard wrote:

On Nov 16, 2005, at 8:53 AM, Dmitry Markman wrote:

Hi
I'm trying to add file reference to the group via applescript with the following command:


set new_file to make new file reference with properties {file kind:"sourcecode.cpp.cpp", name:file_name, file encoding:"macos roman", full path:full_file_path, path:file_name}

properties name, full path and path were set successfully

but file kind and file encoding were not

all properties (except file encoding) marked as r/o in the XCode dictionary
(but I'm creating NEW file reference so I think I can provide those properties's initial values)


XCode dictionary has the following definition of the file encoding property:

"file encoding (iso 2022 japanese/iso latin 1/iso latin 2/Japanese EUC/macos roman/nextstep/nonlossy ascii/shift jis string/symbol string/unicode/utf8/windows cyrillic/windows greek/windows latin 1/ windows latin 2/windows turkish) : ..."

that's why I use "macos roman" for file encoding property

XCode successfully creates and adds new file reference into the group with the right
name, full path and path properties, BUT file kind is always "file" and file encoding is undefined.


also: I can open that file from XCode by 2click on it,
but it doesn't not colorize c++ key words (because it doesn't have right kind I think)

File kind is unfortunately not currently settable via applescript. File encoding is settable, but it takes one of the values displayed in the dictionary next to the file encoding property, not a string. To set the file encoding, instead of specifying "macos roman", you specify macos roman (without the quotes).


Xcode colorizes files based on their file kind, so for now you'll need to either manually set the file kind on your file references or give you file references a file extension that corresponds to their file kind (e.g. '.cpp' for a c++ file).

- Rick

Dmitry Markman

_______________________________________________
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: adding file reference via applescript
      • From: Rick Ballard <email@hidden>
References: 
 >adding file reference via applescript (From: Dmitry Markman <email@hidden>)
 >Re: adding file reference via applescript (From: Rick Ballard <email@hidden>)

  • Prev by Date: Re: gcc4.0 and -Wcast-qual
  • Next by Date: Shortcut for "add breakpoint in project"
  • Previous by thread: Re: adding file reference via applescript
  • Next by thread: Re: adding file reference via applescript
  • Index(es):
    • Date
    • Thread