How to copy bundle resources for command line tool project in Xcode?
A command-line-tool only consists of an executable. No bundle is created and what you are trying to do is not possible.
You’ll have to place the file in some other place and load it from there.
Get full path of a program in cmd line
very simple just
where myprog.exe
for example
where ping
result:
C:\Windows\System32\PING.EXE
Using an included command line exe in a C# program: what's the path?
Copying to the output folder guarantees that the "resource" will have a relative location to your executable. With the method of copying to the output folder, you can use the following code to get the location of your main executable:
String baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
At which point you can use
Path.Combine(baseDir, "myProgram.exe")
to get the final path. If it is in a "tools" folder, you would have to include that in the second argument (that argument is the relative path to your seperate program). The command line arguments go into the ProcessStartInfo object.
C# find file location of xml resource both in web and command line app
The AppContext.BaseDirectory
property is a good fit for this:
Gets the file path of the base directory that the assembly resolver uses to probe for assemblies.
pathForResource returns nil in Mac OS X Console Application — Swift
To use bundles with command line tools you need to make sure you're adding the resource files as part of the build phase. It sounds like you appreciate this, but haven't executed it correctly. The following worked for me in a quick demo app:
- Add the resource to your project.
- Select the project file in the project navigator.
- Add a new copy file phase.
- To the phase you added in step 3, add the file from step 1. You do this by clicking the + button (circled), and then navigating to the file in question.
When you build the project, you should now be able to access the file's path using NSBundle
.
import Foundation
let bundle = NSBundle.mainBundle()
let path = bundle.pathForResource("numbers", ofType: "txt")
if let p = path {
let string = NSString(contentsOfFile: p,
encoding: NSUTF8StringEncoding,
error: nil)
println(string)
} else {
println("Could not find path")
}
// Output -> Optional(I am the numbers file.)
Insert data in codename one resource file in command line or directly
You can check the XML Team Mode
flag in the designer tool and save. Once you do that you will see an XML file and a hierarchy next to it in the res
directory. This will be used by the designer tool but is invisible to the build process.
You can use the following in the latest designer tool:
java -jar /path/to/designer_1.jar -sync-xml /path/to/theme.res
This updates the res file from the XML.
Alternatively you can add this to the build.xml
so it's automated:
<taskdef name="syncXML" classname="com.codename1.build.client.SyncXMLTask" classpath="CodeNameOneBuildClient.jar"/>
Then use this in some place to regenerate the res file:
<syncXML/>
Using stripe CLI to test webhooks in windows dev machine
You need to cd
into the folder where you have stored stripe.exe
. In your case that's:
C:\Users\GABRIEL> cd Desktop
Then you simply run stripe commands from there and it'll work. For instance:
C:\Users\GABRIEL\Desktop> stripe --help
OR
C:\Users\GABRIEL\Desktop> stripe login
Related Topics
How to Animate Transition Between Views in Swiftui
Wait Until an Asynchronous API Call Is Completed - Swift/Ios
Cannot Read the Nfc Chip of the Epassport Using iOS13
Swiftui 2 Firebase Push Notification
How to Install the Alamofire 4.0 in Xcode 8.0
Why Does Swift Provide Both a Cgrect Initializer and a Cgrectmake Function
Swift 4 Attributedstring Get Typing Attributes
Alamofire, Objectmapper, Realm: Nested Objects
How to Encode Realm's List<> Type
Why Can't I Divide Integers in Swift
Peak Detection for Growing Time Series Using Swift
Sum Values of Properties Inside Array of Custom Objects Using Reduce
Swift Error: Guard Body Must Not Fall Through
Check for Nil with Guard Instead of If
How to Check Object Is Nil or Not in Swift
Detailed Instruction on Use of Nsopenpanel
Can a Swift Property Wrapper Reference the Owner of the Property Its Wrapping