Set Bundle Id for Google APIs Client Library for iOS - google-api-client

Has the issue of setting the bundle identifier for the GoogleAPIClientForREST/YouTube ever been resolved?
I found these but never a resolution or solution:
https://issuetracker.google.com/issues/35173446
https://github.com/google/google-api-objectivec-client-for-rest/issues/70
Seems to me if there is a pulldown to set the bundle id, there should be a way to set it in iOS, and there should be something more useful then "remove the bundle id."

I found how to do it by looking at the test source and another post here:
Test source
Hint from another stackoverflow post
let query = GTLRYouTubeQuery_SearchList.query(withPart: "id,snippet")
var bundleIdentifier = Bundle.main.bundleIdentifier
bundleIdentifier = bundleIdentifier?.trimmingCharacters(in: .whitespacesAndNewlines)
query.additionalHTTPHeaders = ["X-Ios-Bundle-Identifier" : bundleIdentifier!]

Related

Swift open Maps application show specific address pins ( branches )?

I am trying to open Maps application on iOS from my app by providing a name of big company such as Orange for example and show all the company branches on the map .
so far i tried lots of solutions before i posted my question , i found this solution but its not working :
if let url = URL(string:"http://maps.apple.com/?address=United States,Orange S.A.") {
UIApplication.shared.open(url)
}
is it possible to find solution for my request? or i have to make my own map and pins inside the application ?
For People show is searching for same solution :
if let url = URL(string:"http://maps.apple.com/?q=Search+Text+here") {
UIApplication.shared.open(url)
}
i used q instead of address to query the search
also add + between words otherwise it wont work

Inter-App Data Migration (migrating data to new app version)

I currently have a Swift iOS app on Apple's App Store. I have many users and I would like to make a new version and help current users migrate to the new version. FYI: the new version is an Ionic app.
Data-wise, my app is using Core Data without any iCloud or sync support. It contains JSON data and also multiple images. So I'd need to bundle the current data and find a way of bringing it to the new ionic app version.
Basically my question is: Is there a way of writing in the app's documents directory and let the new version grab that file to import its data? Is there a way of letting both apps transmit data other than AirDrop or Custom URLs?
I don't want to upload the data remotely, I'd like to do this all locally on the device and also seamlessly so the user don't have to manually do anything.
Suggestions are welcome, thanks!
I would suggest using App Groups to get a shared container. I’m not familiar with Ionic, but this is quite straightforward in native Swift. It allows multiple apps or extensions to access a shared container of data, like the image below:
(Image from https://agostini.tech/2017/08/13/sharing-data-between-applications-and-extensions-using-app-groups/ )
This would require an update to the existing app to copy data to the shared container and then users would have to install the new app while the old one was still installed, because the shared container will be deleted when there are no installed apps using it.
It can be set up like this:
1: Enable App Groups in your project's Capabilities tab (for both apps).
2: Add a new app group and name it something like "group.appDomain.appName" or similar.
3: Now that the App Group is set up, it’s shared container can be used in several ways (User Defaults, NSCoding or Core Data).
For shared User Defaults:
let defaults = UserDefaults.init(suiteName: "group.appDomain.appName")
defaults.set("Example", forKey: "exampleKey")   
defaults.synchronize()
More info from Apple here.
For NSCoding:
let sharedContainerDirectory: URL = FileManager().containerURL(forSecurityApplicationGroupIdentifier: "group.appDomain.appName")!
let sharedArchiveURL: URL = sharedContainerDirectory.appendingPathComponent("whateverYouNeed")
NSKeyedArchiver.archiveRootObject(yourObject, toFile: sharedArchiveURL.path)
For Core Data:
You can set up the container as below. I have taken this code from this answer as I have not actually tried this with Core Data myself.
You use containerURL(forSecurityApplicationGroupIdentifier: "group.appDomain.appName")! to make this work in shared container.
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application.
This implementation creates and returns a container, having loaded the store for the application to it.
This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "xx")
let appName: String = "xx"
var persistentStoreDescriptions: NSPersistentStoreDescription
let storeUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.appDomain.appName")!.appendingPathComponent("xx.sqlite")
let description = NSPersistentStoreDescription()
description.shouldInferMappingModelAutomatically = true
description.shouldMigrateStoreAutomatically = true
description.url = storeUrl
container.persistentStoreDescriptions = [NSPersistentStoreDescription(url: FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.xxx.xx.container")!.appendingPathComponent("xx.sqlite"))]
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
This answer provides a way to migrate the persistent store.
As I mentioned, I am not familiar with Ionic, so I’m not sure how working in that context might change this technique.
I hope this is helpful.
I would have just left a comment but I am unable to do so.
I was able to see that after loading a native iOS application then a Ionic project with the same bundle structure that the data within Library/Application Support/DisplayName.sqlite was still there and the data within the database still intact. (Note: this is deploying using Xcode not through the App Store)
You can see this using Xcode -> Window -> Devices and Simulators -> Devices tab -> Click on your app -> settings cog -> Download container -> after saving Show package contents
I was unable to use the Ionic SQLite native plugin to open the database for some reason. That is as far as I could get. I think it might have something to do with the space of the Application Support folder.
You can do the transition without using AirDrop or Custom Url. The idea is based on how ionic works. Much of the ionic functionality depends upon the plugins developed by community like working with hardware features.
Dealing with device specific features are done in native codes then JS wrapper classes are created for making a bridge between your code and native code.
I would suggest you to write native code which will access the data and files from CoreData and then use the cordova plugin tech to setup communication between the native code and the ionic code. here is a good post on Creating Custom Plugin for ionic and a sample github project

How to obtain the app ID programmatically in Swift?

In a macOS app, I'm using this code to create a directory in Application Support folder.
let directoryURL = appSupportURL.appendingPathComponent("com.myCompany.myApp").appendingPathComponent("Documents")
How can the string com.myCompany.myApp obtained programmatically in Swift?
I saw this question but I'm not sure how to use it in my macOS Swift app: Access App Identifier Prefix programmatically
if let bundleIdentifier = Bundle.main.bundleIdentifier {
appSupportURL.appendingPathComponent("\(bundleIdentifier)").appendingPathComponent("Documents")
}
Little explanation: Property bundleIdentifier is optional, therefore you have to safely-unwrap the value and then you won't be asked for any exclamation mark :)
It is pretty simple to get the app ID :
let bundleIdentifier = Bundle.main.bundleIdentifier
appSupportURL.appendingPathComponent("\(bundleIdentifier)").appendingPathComponent("Documents")
A bundle identifier is the string assigned to the CFBundleIdentifier key in the bundle’s Info.plist file. This string is typically formatted using reverse-DNS notation so as to prevent name space conflicts with developers in other companies. For example, a Finder plug-in from Apple might use the string com.apple.Finder.MyGetInfoPlugin as its bundle identifier. Rather than passing a pointer to a bundle object around your code, clients that need a reference to a bundle can simply use the bundle identifier to retrieve it
For more details & other operation's details, please check
https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/AccessingaBundlesContents/AccessingaBundlesContents.html

Bundle Identifier Read Only

I have an application that has a bundle identifier of my application.
com.sc.Quitchen_ap
I want to change it but the application won't let me do it as the part is read-only. I really need to change the name to quitchen instead of quitchen_ap. Please check the image below.
Please help.
Thanks to trojanfoe. The answer is in the other link. Let me complete this question answer.
1. Chose the Build Target your application.
2. Then click on the Build Settings.
**3. Then Look for the Packaging section and change the name of the product. **"Product Name"****
4. You will see the name changed in the SUMMARY tab of the application.
THANKS #trojanfoe

How to create Unique Identifier and save it to identify user(device)

I want to create unique identifier on iOS 5 and use it for identifying user (user device) every time app is started. I am able to create a unique identifier by following code
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
But unable to save it on user device so that particular identifier is not deleted even when app is uninstalled. I tried using SSKeychain approach but it gives Apple Mach-o Linker error.
Please let me know the the way I can accomplish the same.
Any help is appreciated.
I had exactly the same problem after adding SSKeyChain to my project following the author's instructions online. I eventually discovered that the implementation file was not included in my list of source files in build phases. To rectify the issue do the following:
1) Select your project, then its target.
2) Then select the Build Phases tab
3) On the Build Phases tab you will see a group called Compile Sources, expand it to view contents
4) Check to see if SSKeyChain is in the list
5) If not (as in my case) click the little plus sign at the bottom of the group and navigate to where you added SSKeyChain.m and add it.
Build your project and the error should have disappeared...
I hope this helps!