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

Support linking brownfield iOS apps #177

Merged
merged 7 commits into from
Dec 6, 2017

Conversation

dhei
Copy link
Member

@dhei dhei commented Dec 1, 2017

Starting from react-native@0.50.0, react-native link supports installing from Podfile for brownfield react native applications.

This change will allow to link projects that contains its own .podspec file to CocoaPods-based projects. In case link detect Podfile in iOS directory, it will look for related .podspec file in linked project directory, and add it to Podfile. If Podfile and .podspec files are not present, it will fall back to previous implementation.

Previously it's difficult to install appcenter dependencies from Podfile via pod install. Even with pod install installed appcenter dependencies, users still need to figure out how to run rnpm postinstall script to configure appcenter-analytics and appcenter-crashes module correctly. With react-native link supports Podfile out-of-box, it's much easier to use our sdk in brownfield applications.

In other words, adding the following lines to the Podfile of your brownfield app, then run react-native link should integrate App Center SDK to your app.

  # Pods for MyApp
  pod 'appcenter', path: '../node_modules/appcenter/ios'
  pod 'appcenter-analytics', path: '../node_modules/appcenter-analytics/ios'
  pod 'appcenter-crashes', path: '../node_modules/appcenter-crashes/ios'
  pod 'appcenter-push', path: '../node_modules/appcenter-push/ios'

An example Podfile in ios directory will install App Center dependencies properly:

target 'TestApp' do
  pod 'React', path: '../node_modules/react-native', subspecs: [
    'Core',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'BatchedBridge',
    'RCTImage',
    'DevSupport',
    'RCTAnimation',
    'RCTActionSheet',
    'RCTLinkingIOS',
  ]
  pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'

  # Pods for MyApp

  pod 'appcenter', path: '../node_modules/appcenter/ios'
  pod 'appcenter-analytics', path: '../node_modules/appcenter-analytics/ios'
  pod 'appcenter-crashes', path: '../node_modules/appcenter-crashes/ios'
  pod 'appcenter-push', path: '../node_modules/appcenter-push/ios'

  # Add new pods below this line

  platform :ios, '8.0'
end

This should fix #94.

@dhei dhei removed the do not merge label Dec 1, 2017
@dhei dhei requested a review from guperrot December 1, 2017 23:51
Copy link
Member

@guperrot guperrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the change in linker script that enables this. Also we don't have a test app to cover this scenario, can you add one? Maybe just analytics at least.

@dhei dhei changed the title Support linking brownfield apps Support linking brownfield iOS apps Dec 5, 2017
@dhei
Copy link
Member Author

dhei commented Dec 6, 2017

@guperrot A sample brownfield app is added in the most recent commit.

There's no change in linker script because all the magic is done by react-native@0.50.0 itself. As long as brownfield iOS app add appcenter reference to Podfile, react-native link should take care of the rest.

@guperrot guperrot merged commit 6a433ee into develop Dec 6, 2017
@guperrot guperrot deleted the feature/support-linking-brownfield-apps branch December 6, 2017 03:12
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.

Support use without react-native link; add .podspec for libraries
2 participants