How to automate changes to an Xcode project?

I have a tedious task that I have to repeat every time I create my iPhone project for sending to non-programmers: all the libraries and headers that I reference outside the project folder must be copied to the project folder or subfolder, so I can pin source and pass it.

I know that you can automate Xcode with AppleScript, but I can’t find a suitable documentation about the available commands for life. If I plan on Google Xcode AppleScript, I just get a bunch of hits when writing AppleScript applications in Xcode.

Any help would be greatly appreciated!

+3
source share
2 answers

here is a demo to get you started. since you know how to find a dictionary, the rest can be easy if you are comfortable using AppleScript:

tell application "Xcode"
    -- of course, use your project name instead of Alias
    set projectName to "Alias" 
    set xcProject to project projectName

    repeat with idx from 1 to the count of (get every file reference of xcProject)
        set fileRef to (file reference idx) of xcProject
        get path of fileRef
        get id of fileRef
        get name of fileRef
        get properties of fileRef

        set newPath to path of fileRef
        -- add logic and alterations here
        set path of fileRef to newPath
        -- ...
    end repeat
end tell
+3
source

based on your description, it would be easier to create a custom goal in xcode to accomplish this task. xcode can run all kinds of unix utilities for copying, zipping, etc. soo ... shell scripting should be much simpler. you can also set this goal as a dependency if you want, so it always remains relevant (but a bit slow for regular development, tbh.

Yes, you can use applescript with xcode in many cases, but the task you have outlined will be much more difficult.

+1
source

Source: https://habr.com/ru/post/1764661/


All Articles