xcode - Locate source project directory in Swift from compiled code -


I want to find a directory of my uncompressed source code (because I want to count my lines) project. Project Rippo = "/ User / Tomburorn / Workspace / SwiftGolf" // < - I want this program to know that path = "\ (project ripo) / swift / Gulf Gulf / swift" var fileContents = String.stringWithContentsOfFile (path, encoding: NSUTF8StringEncoding, error: zero)

I've found the compiled location with the NSBundle.mainBundle (). BundlePath , but does not contain unrelated code in any ideas? Perhaps there is a way that I can write a temporary file during the build process?

The challenge is getting faster Runtime versus location to estimate on collection time. The logic in Xcode suggestion works fine and can be accepted as a solution. I could not use this approach because I am using SPM without XM.

Package in you. Swift

  Dependencies: [. Package .git ", version (1,8,0))]   

Then enter

  import files in your code projectrepo =" (Folder .home .path) / gitWorkspace / SwiftGolf "{Enter Model = Try Data (Content: URL (fileURLWithPath:" \ (projectDir) / \ (modelFile) ")}} Hold {Print (" Error: \ (error) " )}   

Another option is commandlinekit / xcode logic

  import command line kit cmdline = commandline kit.commandline (). File = string ocean (shortflag) : "F", Longflag: "File", Required Yes: true, help message: "the file that you are trying to parse"). CmdLine.addOptions (file) {try cmdLine.parse () print (file.value!)} {Print ("Error: \ (Error) ") ​​exit (-1)}   



Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -