I need to access a file from my main app in my share extension is that possible? The file is the "bundle" for distribution for a react native iOS app, something like
jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle" subdirectory:#"../myMainProject"];
If I copy and paste the main.jsbundle file on my share extension it works fine.
Or should I place this main.jsbundle in an app group so both app and extension can use it?
An app and its extensions can only share data over a common app group folder, and both must be added explicitly in Xcode to that group.
If your JavaScript bundle is static and is delivered with your app, you max place it as a resource into a shared framework, and add this framework to both app and extension. So you can access this bundle by
jsCodeLocation = [[NSBundle bundleWithIdentifier: <framework identifier>] URLForResource:#"main" withExtension:#"jsbundle"];
Note: You shouldn't access the contents of the parent folder of a bundle folder.
Related
I am using google sign-in in an app using react-native-google-signin. I have a dev and a prod google API project set up in the backend.
I want to use the separate GoogleService-Info.plist for dev and prod in my react-native app.
How can I configure GoogleService-Info.plist depending upon the environment?
You need to config based on your env.
NSString *firebasePlist = [[NSBundle mainBundle] pathForResource:#"GoogleService-Info" ofType:#"plist"];
#if DEV
firebasePlist = [[NSBundle mainBundle] pathForResource:#"GoogleService-Info-DEV" ofType:#"plist"];
#endif
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebasePlist];
[FIRApp configureWithOptions:options];
If you have configured your project with https://console.developers.google.com
There is no need to configure anything in your code.
For ANDROID by default, you can set up 3 environments
DEV
RELEASE
Google Play(Production)
ANDROID provides separate SHA-1 Keys for the above-mentioned environemnts.
With these SHA-1 keys, you can create 3 Oauth projects. Now you have 3 Oauth google projects that you can configure with 3 separate branches(dev, release, prod) of your project.
FOR IOS
You can create as many Oauth google projects as you like.
Just keep the GoogleService-Info.plist of your Oauth google project depending upon the environment in the ios folder at the time of making the build.
Here is the problem:
I am trying to check the contents of my app's bundle. So by writing a couple of lines of code like:
NSBundle *myBundle = [NSBundle mainBundle];
NSLog(#"%#",myBundle);
I got the path that I need to locate my app's bundle. However, when I deleted the bundle, I was expecting my app to give an error saying that bundle doesn't exist. Instead, it showed that same path again. Hy doesn't it have any impact on the program. How does it work under the hoods? I am new to iOS, so any help will be appreciated.
Thanks in advance!!!
Need to install a pre-built couches lite database in my IOS application, for that I need to locate the database's .cblite file.
When I go to [[NSBundle mainBundle] bundlePath] . I cannot find anything.
You can use http://simpholders.com/ to locate the application folder in a simulator running the app with Couchbase Lite.
The cblite file and folder to store the attachments are in the folder returned by SimPholders in Library/Application Support/CouchbaseLite.
Once you have the canned database, see this documentation guide to use it as a resource in your app and to set it up with the replaceDatabaseNamed:withDatabaseFile:withAttachments:error: method.
I've got a cordova project and need to authorise a google maps API call from our index.html page. I've successfully done this for Android by adding "file:///android_asset/www/default/index.html" to our authorised URLs. However I can't seem to get the file path right for our iOS build. The index.html is in a www/default folder, so I tried file:///www/default/index.html however this doesn't work, any ideas?
I think that is what you're searching:
NSString* path = [[NSBundle mainBundle] pathForResource:#"www/index" ofType:#"html"];
I have a directory structure on my computer i wanted to include into my app bundle:
#"/Users/playra/Desktop/2 DivyaLoka/Собрание Тайн";
application starts surf folders, keeping the directory tree, which is visible in the screenshot
but when using the load
self.pathProperty = [[NSBundle mainBundle] resourcePath];
or
self.pathProperty = NSHomeDirectory();
structure disappears and everything is loaded into one tableView.
How to start an application starting with a folder **Собрание Тайн** that is in the sandbox keeping structure inside for further load on the device?
First choose IOS Device
Product --> Archive
Choose Disribute
Then, Save for nterPrice or Ad-hoc Deployment
Then choose your certificate and Export
Then save the build