Code Runs Perfect in G++ But Not in Xcode - Cannot Find File

Code runs perfect in g++ but not in Xcode - Cannot find File

Your file fails to open because XCode launches from the IDE in the default build location, which is actually a temporary directory off somewhere on your disk. If you want change the working directory at launch-time to something else (like the location where your files can be found):

  1. Select the Product/Edit Scheme... menu option.
  2. Select the Run schema in the left list.
  3. At the bottom Options tab on the right pane should be a "Working Directory" option. Check the checkbox and set the custom working directory to someplace you know (your "/Users/yourname" home directory is a decent place that I use).
  4. Make sure any "current directory" data files you need for your program execution from the IDE are in this directory.

And in case you didn't see it, this is also the place where you can configure command-line arguments (on another tab) of the same dialog.

Problems after upgrading to Xcode 10: Build input file cannot be found

Try to switch back to the Legacy Build System (File > Project Settings > Workspace Settings > Legacy Build System)

Build input file cannot be found' Swift 4.2, Xcode 10.0

Moving the folders around the inspector can cause the error "Build input file cannot be found"

SWIFT 5

In Swift 5, the error came up but the identity showed no errors.

  • Go under build settings and select packaging.
  • Delete the current paths for Debug and Release and enter your new path where the info.plist is kept.

For example [APPROJECTNAME]/[THEINFOPLISTFOLDER]/info.plist
In the screenshot below, the path is API-client/Resources/info.plist

Sample Image

SWIFT 4

To fix it, go to the general tab and under identity reselect the info.plist that you like

Sample Image

Sample Image

I hope this helps

How to reference files relatively in Xcode 4 (C++)?

Are you referring to the working directory the executable uses when run? If so, you can set the working directory by editing the scheme.

Choose Edit Scheme from the Schemes popup, then choose the Run action from the side bar. Working Directory controls are near the bottom. Check the "Use custom working directory" box then click the little window/folder/card-looking icon (I have no idea what symbol they're going for there) in the right side of the text field and choose your path.

To determine the working directory programmatically works the same as it always has, regardless of the IDE.

Xcode playgrounds can't access swift files in Sources folder

You have to add public access attribute to your classes, methods and properties in source folder to make them accessible from main playground file as they treated as separate module by compiler

How to read a XML file using fstream in IOS

It looks like you are trying to open the file from the wrong directory.
"templates.Xml" is saved in the bundle- is not saved in the documents directory. By default, if you open "./filename", this actually points to:

/Users/arinmorf/Library/Application Support/iPhone Simulator/7.0.3/Applications/246E91F9-FAB2-4A46-B1F1-855B5363F24D/Documents/

Where arinmorf would be your username and the long hex string is randomly generated every time you install the app on the simulator.

The templates.xml file would be found in:
/Users/arinmorf/Library/Application Support/iPhone Simulator/7.0.3/Applications/246E91F9-FAB2-4A46-B1F1-855B5363F24D/iFly.app/templates.xml

iFly.app is the name of my app, yours would be "T". BUT you can't use the absolute path in your project, because of the randomly generated string, you need to use the NSBundle or CFBundleRef.

In objective-C, you would use:

filePath = [[NSBundle mainBundle] pathForResource:@"templates" ofType:@"xml"];
NSData *myData = [NSData dataWithContentsOfFile:filePath];

In C++ it looks like:

CFURLRef fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("templates"), CFSTR("xml"), NULL);
CFStringRef filePath = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
const char *path = CFStringGetCStringPtr(filePath, encodingMethod);
FILE* f = fopen(path, "r");

(Credit to Chris Frederick at https://stackoverflow.com/a/8768366/2070758 for C++ version)

Xcode Project Run on Device but failed to archive

I solved my own problem with the help of if condition. I added this line at the top of file

#if !(os(iOS) && (arch(i386) || arch(arm)))

and at the end of file

#endif

This peace of code solved my problem, and now I am able to build my app for the TestFlight.



Related Topics



Leave a reply



Submit