Google App Indexing on iOS

663 views Asked by At

We want to implement Google's iOS App indexing into our app. So, I followed the guide over here:

https://developers.google.com/app-indexing/ios/app

Installed CocoaPods as well, which was seamless. We then added this code:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    NSURL *sanitizedURL = [GSDDeepLink handleDeepLink:url];

        NSLog(@"isdeeplinkApp    %@", [GSDDeepLink isDeepLinkFromGoogleAppCrawler:url] ? @"Yes" : @"No");
        NSLog(@"isdeeplinkSearch %@", [GSDDeepLink isDeepLinkFromGoogleSearch:url] ? @"Yes" : @"No");
        NSLog(@"sanitized-url    %@", sanitizedURL);

          return YES;
        }

We then tested it with our custom URLs after adding it to the Plist file.

Which looks like this for URLSchemes

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>googleapp</string>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>IDENTIFIER</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>IDENTIFIER </string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>gsd-IDENTIFIER </string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>gsd-IDENTIFIER </string>
        </array>
    </dict>
</array>

However our app is crashing on launch (Before even hitting our own code) at the first line in the openURL method:

NSURL *sanitizedURL = [GSDDeepLink handleDeepLink:url];

The error:

+[UIFont gsd_fontOfSize:]: unrecognized selector sent to class 0x112af3f48

According to Google we should do this if we get this error at runtime:

If you see a runtime error that looks something like: +[UIFont gsd_fontOfSize: ] : unrecognized selector sent to class 0xXXXXXXXXXX, make sure that you are correctly using CocoaPods, as outlined in the Get Started section on the CocoaPods website. Note that you should be opening the Xcode workspace generated by CocoaPods instead of the project file when building your project. CocoaPods will set some necessary linker flags.

If you're still seeing issues, make sure that the -ObjC linker flag has been set in the "Other Linker Flags" row in Build Settings.

However that has not solved the issue for us. As a test, I decided to start a demo project and test the links out there. On the demo app - it works just fine. So we're thinking its probably a project setting?

0

There are 0 answers