Add a file generated by run script into the test target compilation list in Xcode
- your
run script
phase should be beforeCompile Sources
phase - you need to add output file paths to
Output Files
.
By doing this you're letting Xcode know that it should wait this script to be finished before capturing the file structure.
Add files to an Xcode project from a script?
This can be done by adding a new build phase to your application.
In your Xcode project browser, find the target for your application, and expand it to show all of the build phases.
Add a new "run script" build phase to your target. The easiest way is to right-click on the target and choose "Add/New Build Phase/New Run Script Build Phase"
Adding the new build phase should bring up an inspector window. In this window, you can enter the entire shell script, or simply a command line to run the script.
Here's the gold: At the bottom of the inspector window you can specify input files and output files. Specifying input files sets up dependencies automatically (the shell script will only be executed if some of the input files have been modified). Specifying output files automatically propagates the dependencies to those files. When your shell script is run, Xcode knows that it needs to deal with those files that the shell script has modified.
Be sure to drag your new build phase up to the top of the list of phases as shown in the screenshot below. The order will be important if you need those resource files to be included in the bundle.
Save, build, commit to the repository, ask for a raise, get some fresh air and have a nice day! :)
Add source code to Xcode target programmatically
CocoaPods uses this project to modify project files: https://github.com/CocoaPods/Xcodeproj
Xcode 13 error: input file [...] was modified during the build
I'm debugging a similar issue in R.swift, I think I've found the cause of the issue.
Xcode 13 appears to execute Run Script build phases during index builds. This can cause a file to be written to by an index pass, in parallel with a build.
To check if this is happening for you, add this to your build script: say $ACTION
On Xcode 12, it only says "build", but in Xcode 13 I hear it saying "indexbuild" during compilation, whenever I save .swift files or otherwise navigate through my code.
To prevent your script from running during indexing, add this check:
if [ $ACTION != "indexbuild" ]; then
# your script here
fi
Is it possible to script adding a directory of source files into an Xcode project for compile?
Xcode makes it possible to script adding resource files such as images to the project file using the "Build Phases" tab however this does not work for source code files that need to be recognized at compile time. Luckily I managed to come across a nice community-developed Python script which does allow us to do this.
https://github.com/kronenthaler/mod-pbxproj
With this script we can make all sorts of modifications to the project file including adding or deleting files.
See this link for a full list of available operations:
https://github.com/kronenthaler/mod-pbxproj/wiki
Where is Run Script on the target?
- Select target in outline view
- In the context menu, select "Add..." → "New Build Phase" → "New Run Script Build Phase"
- A window will appear where you can edit the script
Related Topics
Implementing Ignoredproperties() on Both a Object Subclass and Its Own Subclass
Modify Scpreferences Persistent Storage: Invalid Argument
How to Pass Text from Cell to Textview in Another View Controller
Xcode + Swift + Darwin.Ncurses = "A_Bold Not Found" Compilation Error. I Can't Get Bright Colors
How to Modify Codable Class Properties
Writing an Enum Case Check to a Bool Variable Without Equatable Conformance
Swift Google Maps Smoothly Rounded Polylines
How to Implement Doubly Linked List in Swift
Communicate Data Between Watchos & Today Extension Widget
Problem with Swiftui and Foreach on Xcode Playground
Why Swift Disallows Weak Reference for Non-Optional Type
Bool.Hashvalue Valid to Convert to Int
Adding Constraints Programmatically in UIview with UItextview
#If Canimport(Coreimage) Not Working in Swift Package Manager
Cannot Divide and Assign Int64 Value