How to know the contents of NSbundle in XCode Porject??
bcoz issue is, I have placed a config.doc file in resource folder of my XCode project and i want to read the contents of that config.doc file, but it says that config.doc file is not found. How to solve this problem??
This is how my code looks like:
-(void)applicationDidFinishLaunching:(UIApplication*)application
{
if([NSBundle mainBundle]pathForResource;#"config" ofType:#"doc")!=nil)
{
NSLog(#"File Exists");
}
else
{
NSLog(#"File not found!!");
}
NSString *configContents = [[NSBundle mainBundle]pathForResource:#"config" ofType:#"doc"];
NSLog(#"Contents of config file : %#",configContents);
}
OUTPUT :
File not found!!
Contents of config file :(null)
how to solve this problem?? i'm not able to make where is the mistake..
plz help
Thank You
You can see the contents of the bundle in the following way :
Expand the "Products" group in xcode
Right click on your_prodcuct.app and click "Reveal in Finder"
In finder right click on your app and click "Show package contents"
Now you can check whether the file actually exists in the bundle or not.
Related
I know the question has already been asked, but I’m having trouble uploading a file with karate.
I have a file called "example.pdf" in my project. I put this document in a "assets" folder
I tried to build on the example of the documentation here.
https://github.com/karatelabs/karate/tree/master/karate-core#file-upload
and here’s my code:
* configure driver = { type: '#(driverType)', executable: '#(driverExecutable)', addOptions: #(driverOptions), headless: #(driverHeadless), webDriverSession: #(webDriverSession), showDriverLog: true }
Given waitFor('#upload)
And driver.inputFile('#upload', '../assets/pdf-exemple.pdf')
My browser is chrome
what am I missing ?
Thanks for your help
EDIT:
Thank you for your feedback, I’ll try to clarify.
Meanwhile I have some details. In fact the browser is chromedriver and geckodriver
const drivers = {
path: "./src/test/java/drivers/",
chromedriver: "95.0.4638.69",
geckodriver: "0.30.0",
};
So I think I have to use the approach "multipart file".
I tried this code, and my test passes without error, but does not handle the expected functionality (uploading an attachment)
And url 'https://url file file to upload/test' //page where is the area to upload a file
And waitFor(data.inputPJ).click() //area where you click on the application to upload a file
And multipart file file = { read: '../../assets/pdf-exemple.pdf', filename: '../../assets/pdf-exemple.pdf' }
And method post
But in my application this code has no effect, in the application I should have :
But the uploaded file doesn't appear, and I have:
The difficulty here is that I have no mistake. I will continue to try to understand the doc
I am at your disposal to provide more information
I have defined wdio.conf.js file (main file) and environment specific dev-chrome.conf.js file.
I can't get get cucumber to recognize my step definitions folder.
This is my structure:
And this is what I have in dev-chrome.config.js file:
const wdioConfig = require('../../../../../wdio.conf.js');
const commands = require('../../../../../src/commands/commands');
wdioConfig.config.cucumberOpts = [{
// other stuff here
require:
[
'./src/step_definitions/**/*.js',
// Or search a (sub)folder for JS files with a wildcard
// works since version 1.1 of the wdio-cucumber-framework
//'./src/**/*.js',
],
// other stuff here
}];
exports.config = wdioConfig.config;
I am getting an error:
"Step "When I add the product to a cart" is not defined. You can ignore this error by setting cucumberOpts.ignoreUndefinedDefinitions as true."
When I have same path for step definitions defined on main wdio.conf.js file then it works.
My main wdio.conf.js file is located in the root folder of the project.
Do you know how could I make it work in the environment specific conf.js file?
I am using #wdio/cucumber-framework": "^5.13.2"
As per the below example config, the cucumberopts should be an object and I think you are trying to set it as an array.
https://github.com/amiya-pattnaik/webdriverIO-with-cucumberBDD/blob/master/test/config/suite.cucumber.conf.js#L156
Maybe you should follow this example which will help to understand config setup.
Cheers!
My problem:
I have a zip file that contains a firmware update for my company's device
I want to be able to access it using react-native-fs with the code below
.
export function readAssetFile(name) {
if(Platform.OS === 'ios') {
return RNFS.readFile(`${RNFS.MainBundlePath}/assets/data/${name}`);
} else {
return RNFS.readFileAssets(`raw/${name}`, 'base64');
}
}
My project structure looks like:
ProjectDir
android
data
image1.png
image2.png
firmwarefile.zip
ios
The android branch works, because I added a build step in my .gradle to copy firmwarefile.zip into ProjectDir/android/app/src/main/assets/raw. So I can call readAssetFile('firmwarefile.zip'), and it returns the data.
On iOS, all the image files (Image1.png, Image2.png) are included in MyProject.app/assets/data/ without me having to do anything, but the zip file that sits beside them is not.
Looking into the actual packager code (from the metro project), it seems (based on metro/src/defaults.js) that zip files aren't included by default by the packager, but the packager can be configured to include other file types. But I can't find any documentation for how I'd go about doing that configuring.
Sorry for what feels like a really simple question, but I've been trying to get this zip included in my bundle for ~4 hours now. I'm resorting to manually putting in console.logs and error-throws to trace things inside metro to try and find where I should be sending in my config.
Versions:
React-native: 0.55.3
Metro: 0.30.2
This is a hack, but it gets it done:
Convert your zip binary to a base64 string
Stick it in a .js file, a la module.exports = "<your base64 data goes here>"
In your file that needs the zip file, use import myZipFileAsBase64 from './hacky-base64-file.js';
Here's a quick script to make your base64 files:
var fs = require('fs');
function prepareZip(file, outJs) {
const b64 = fs.readFileSync(file, 'base64');
fs.writeFileSync(outJs, `module.exports = ${JSON.stringify(b64)};`);
}
prepareZip('./data/myFirmware.zip', './hacky-base64-file.js');
My Mac app is designed to edit and analyse graphs, which users can create and store in files anywhere on the file system. I go to user to let them open a previously created file with [NSOpenPanel openPanel] and an inline completion handler block. During the menu processing I get this console error message several times:
2017-02-25 13:42:47.394433 pasteurnet3[32901:1263849] [default] Failed to updated bookmark for item (null) [60AF512E-6072-427D-8624-C406B0EF7D5A] - URL:file:///AirDrop with error Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
This happens just in the creation of the NSOpenPanel, even before sending it the beginWithCompletionHandler: message. FWIW, the menu nonetheless does comes up when eventually requested, allows file selection, and otherwise seems to work. There does seem to be a long delay in the initialisation of the menu object.
I haven't paid attention to this app in a long time but the appearance of the message apparently owes to a MacOS change. I immediately suspected sandboxing, but sandboxing was turned off for the app. If I turn on sandboxing and request the "User-selected file" entitlement it seems to make no difference.
There is nothing special about the object creation except it is done inside a #try block:
#try {
// Create the File Open Dialog class.
openDialog_ = [NSOpenPanel openPanel]; // error occurs here
}
#catch (NSException *e){
NSLog(#"innocuous exception(1) in -initForOpenWithDefaultFile:callBackTo:");
}
#catch (NSString *s){
NSLog(#"innocuous exception(2) in -initForOpenWithDefaultFile:callBackTo: \"%#\"", s);
}
#catch (...) {
NSLog(#"innocuous exception(3) in -initForOpenWithDefaultFile:callBackTo: probably a layout error");
}
#finally {
;
}
I am not doing anything with bookmarks from within the program nor, for that matter, with AirDrop.
Xcode 8.2.1, Macbook MacOS 10.12.3.
For me, "Failed to updated bookmark for item (null)" was logged at launch when my app's File > Open Recent menu contained items for files I had opened, then later deleted in the Finder. I don't know if there's a way to get the menu to just remove the items, but I got rid of the messages by choosing File > Open Recent > Clear Menu while running my app.
My app does not use NSDocument. I am adding items to Open Recent using -noteNewRecentDocumentURL.
how can I change in Xcode this line
NSString *filePath = [[NSBundle mainBundle] pathForResource:(#"%#",[command.arguments objectAtIndex:0]) ofType:#"pdf"];
to look in Phonegap (cordova) file structure for the PDF like:
~/Library/Caches
or
~/Docuemnts
I don't have a definite answer for you, but I believe the cordova-plugin-file plugin is where the answer will be found. I have only limited experience with it, but it looks like you would be looking for the following paths:
cordova.file.cacheDirectory = '~/Library/Caches'
cordova.file.documentsDirectory = '~/Documents'
From the cordova documentation, it looks like you'll be trying to get a DirectoryEntry from the window object, and then use a DirectoryReader to iterate over the contained files. There may be a search, but I don't know the API well enough beyond the basics.
var bundleDocs = window.resolveLocalFileSystemURL(cordova.file.documentsDirectory);
var bundleDocsReader = bundleDocs.createReader();
bundleDocsReader.readEntries(
function success(files) { // iterate over files and do stuff },
function error(err) { // respond to error }
);
Hope that helps!
NOTE: The direct API references for DirectoryEntry and DirectoryReader link to the Cordova 3.0 documentation because the Cordova 5.1 documentation for plugins is awful.