Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS SDK with CocoaPods #972

Closed
wants to merge 2 commits into from
Closed

iOS SDK with CocoaPods #972

wants to merge 2 commits into from

Conversation

rutbastoni
Copy link
Contributor

Referencing #672 , this PR completes installation of iOS SDK with CocoaPods structure (and of course with latest Sdk version).
I've tested it on my application, using latest Cordova Cli (8.1.2) and xCode version 10.
Crashlytics error reporting also works fine, I had to fix bugged install/uninstall hooks.
The official documentation states that the Crashlytics run script phase should include an additional input file, so I managed it in the hook script, since I couldn't figure out how to distinguish a .pbxproj file from a xCode 10 version to a lower one, shouldn't matter very much since everyone is forced to update xCode for new builds for Apple Store uploads starting from 2019.
Any help for possible bugs or problems with lower Cordova or xCode versions is welcome

@amirhmoradi
Copy link

@rutbastoni thanks for the PR.
Can someone please merge this?

@dpa99c
Copy link
Contributor

dpa99c commented Jan 14, 2019

When I installed the plugin from this PR branch into a Cordova project on iOS, I got this error during the build which caused it to fail:

Checking config.xml for pods.
Installing pods
Sit back and relax this could take a while.
Analyzing dependencies

[!] CocoaPods could not find compatible versions for pod "Firebase/Core":
  In snapshot (Podfile.lock):
    Firebase/Core (= 5.15.0)

  In Podfile:
    Firebase/Core (= 5.15.0)

Specs satisfying the `Firebase/Core (= 5.15.0)` dependency were found, but they required a higher minimum deployment target.

On examination, the generated Podfile defaults to a min iOS version of "7.0" (as outlined in the cordova-plugin-cocoapods-support docs) but the deployment target set in the Firebase podspecs is set to "8.0".

So to get the plugin to work in a build when this PR is included, I had to fork the PR branch and add this to plugin.xml to align the minimum iOS version with the Firebase podspecs:

<pods-config ios-min-version="8.0" use-frameworks="true"/>

The build then succeeded:

Checking config.xml for pods.
Installing pods
Sit back and relax this could take a while.
Analyzing dependencies

Downloading dependencies
Using Crashlytics (3.12.0)
Using Fabric (1.9.0)
Using Firebase (5.15.0)
Using FirebaseABTesting (2.0.0)
Using FirebaseAnalytics (5.4.0)
Using FirebaseAnalyticsInterop (1.1.0)
Using FirebaseAuth (5.2.0)
Using FirebaseAuthInterop (1.0.0)
Using FirebaseCore (5.1.10)
Using FirebaseInstanceID (3.3.0)
Using FirebaseMessaging (3.2.2)
Using FirebasePerformance (2.2.2)
Using FirebaseRemoteConfig (3.1.0)
Using GTMSessionFetcher (1.2.1)
Using GoogleAppMeasurement (5.4.0)
Using GoogleToolboxForMac (2.2.0)
Using GoogleUtilities (5.3.6)
Using Protobuf (3.6.1)
Using nanopb (0.3.901)
Generating Pods project
Integrating client project
Sending stats

Pod installation complete! There are 7 dependencies from the Podfile and 19 total pods installed.

@rutbastoni
Copy link
Contributor Author

@dpa99c thanks for your suggestion, I didn't see the issue, because my project already has minimum iOS version set to 9. I've just sent the fix, anyway the Travis build is still failing for Cordova < 8, I don't understand why (it's failing for Android platform, too) and I don't have the time to dig more into Travis builds

@dpa99c
Copy link
Contributor

dpa99c commented Jan 16, 2019

@rutbastoni thanks for adding the min iOS version.

The only other issue I encountered is not caused by this PR, but is due to a bug in cordova-ios (apache/cordova-ios#394) causing Cordova CLI builds to fail (Xcode builds work fine), so my CI builds to failed.

The PR to fix it (apache/cordova-ios#398) has been merged to the master branch of cordova-ios but has not yet been released (i.e. it is not in the latest 4.5.5 release).

The solution I used was, as inspired by this comment, to download the patched version of build.js for [email protected] and use a hook script to deploy it:

config.xml:

<platform name="ios">
    <hook type="after_platform_add" src="hooks/ios/deploy_build.js"/>

hooks/ios/deploy_build.js:

#!/usr/bin/env node

module.exports = function (context) {
    var path = context.requireCordovaModule('path');
    var fs = context.requireCordovaModule('fs');
    var sourcePath = path.join(context.opts.projectRoot, 'resources/ios/build.js');
    var targetPath = path.join(context.opts.projectRoot, 'platforms/ios/cordova/lib/build.js');

    var buildExtras = fs.readFileSync(sourcePath, { encoding: 'utf8' });
    fs.writeFileSync(targetPath, buildExtras, { encoding: 'utf8' });
};

@maeisdev
Copy link

Please accept this pull request

@wmaikon
Copy link

wmaikon commented Mar 6, 2019

@rutbastoni thanks for adding the min iOS version.

The only other issue I encountered is not caused by this PR, but is due to a bug in cordova-ios (apache/cordova-ios#394) causing Cordova CLI builds to fail (Xcode builds work fine), so my CI builds to failed.

The PR to fix it (apache/cordova-ios#398) has been merged to the master branch of cordova-ios but has not yet been released (i.e. it is not in the latest 4.5.5 release).

The solution I used was, as inspired by this comment, to download the patched version of build.js for [email protected] and use a hook script to deploy it:

config.xml:

<platform name="ios">
    <hook type="after_platform_add" src="hooks/ios/deploy_build.js"/>

hooks/ios/deploy_build.js:

#!/usr/bin/env node

module.exports = function (context) {
    var path = context.requireCordovaModule('path');
    var fs = context.requireCordovaModule('fs');
    var sourcePath = path.join(context.opts.projectRoot, 'resources/ios/build.js');
    var targetPath = path.join(context.opts.projectRoot, 'platforms/ios/cordova/lib/build.js');

    var buildExtras = fs.readFileSync(sourcePath, { encoding: 'utf8' });
    fs.writeFileSync(targetPath, buildExtras, { encoding: 'utf8' });
};

Excellent @dpa99c and @rutbastoni ! It worked flawlessly. Thank you!

@mismith
Copy link

mismith commented Apr 3, 2019

Looks like apache/cordova-ios#398 has been released in cordova-ios v5.0.0, so maybe this PR can progress further now?

@zakton5
Copy link

zakton5 commented May 3, 2019

Any updates on this? I would love to get this working so I can use the dynamic links plugin as well

@manish2535
Copy link

Any updates on this?

@redarea-snc redarea-snc closed this by deleting the head repository Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants