Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xcode complexity? No more.

Xcode complexity? No more.

https://github.com/pvinis/talk-xcodegen-rn

Xcode has been a big part of the difficulty users face when trying to use and upgrade React Native. We added CocoaPods to make linking in Xcode easier. We made upgrade-helper to document the changes in Xcode. We made upgrade-support to help users with their problems. Today, I'll show you how to make your Xcode problems go away.

Avatar for Pavlos Vinieratos

Pavlos Vinieratos

August 25, 2020
Tweet

More Decks by Pavlos Vinieratos

Other Decks in Technology

Transcript

  1. Why It's an unknown/unfamilar tool. Almost all settings need to

    be edited using Xcode UI. Its file format is not very friendly.
  2. React Native Core and Community are working hard. Besides the

    many improvements and new features shipped, tooling has been getting better too: CocoaPods was added, making manual linking a thing of the past. upgrade-helper was created, making manual upgrading easier.
  3. I've had this idea for a while: Wouldn't it be

    nice if my Xcode project was more like package.json?
  4. It can generate an Xcode project from a project.yml file.

    Imagine project.yml is package.json and MyProject.xcodeproj is yarn.lock.
  5. Visit https://github.com/pvinis/react-native-xcodegen to get set up. Steps: Install xcodegen and

    xunique. Copy make into your ios dir of your project. Find the right project file for your RN version from templates. Copy into your ios dir of your project and rename to project.yml. Done. You can now run ./make from inside ios dir to have your Xcode project generated.
  6. Adding libraries 2/3 With native code, tiny change. Old way

    yarn add react-native-permissions cd ios && pod install New way yarn add react-native-permissions cd ios && ./make https://github.com/pvinis/talk-xcodegen- rn/commit/8940952a5d046ea0ef2db856ed3418e9bcfa91e9
  7. Adding libraries 3/3 Adding native code yourself, simple. Create the

    native files with or without Xcode Make sure they are in the target's sources in project.yml cd ios && ./make https://github.com/pvinis/talk-xcodegen- rn/commit/90ff2d1ac34b34ad6b229c9b7b486e9e457f9a78 https://github.com/pvinis/talk-xcodegen- rn/tree/master/code/MyProject/ios/MyProject https://github.com/pvinis/talk- xcodegen-rn/blob/master/code/MyProject/ios/project.yml
  8. How do I upgrade next time Look for updated template

    in https://github.com/pvinis/react-native-xcodegen. Otherwise check the upgrade-helper xcodeproj diffs for anything interesting. https://react-native-community.github.io/upgrade-helper/?from=0.62.2&to=0.63.0 https://github.com/pvinis/talk-xcodegen- rn/commit/286c0f5b7a18b8a2b68db41e44c1702860f94173
  9. Takeaways 1/3 XcodeGen is a great way to keep complicated

    upgrades simple. From https://github.com/react-native-community/upgrade-support/issues/13 To https://github.com/pvinis/talk-xcodegen- rn/commit/286c0f5b7a18b8a2b68db41e44c1702860f94173#diff- 5b58604e7164c95a2602ad5b5fab7235
  10. Takeaways 2/3 Read the docs and specs of XcodeGen if

    you'd like to learn more. https://github.com/yonaskolb/XcodeGen/tree/master/Docs
  11. Takeaways 3/3 XcodeGen has no way right now to generate

    a project.yml from an existing xcodeproj, but it is being worked on. That means when a new Xcode setting is changed, we need to look for the right yml name for it. Or grab the latest template project.yml file and merge it with any changes we might already have. https://github.com/yonaskolb/XcodeGen/pull/735 https://github.com/pvinis/react-native-xcodegen
  12. Work to be done Keep the templates up-to-date with the

    diffs and upgrade-helper Make an RFC and a PR on react-native to add a project.yml to the init template
  13. Go set this up for your project Try it out

    Make issues for things that might not work for your project Find me on twitter.
  14. Thank you twitter.com/pvinis (@ me) p0l.co/talk-xcodegen (this talk) p0l.co/rn-xcodegen (tempate

    files) artsy.net (where I work) pvin.is (my blog, ) pavlos.dev (my portfolio, )