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

[v6] Cocoapods (round two) #741

Merged
merged 8 commits into from
Nov 28, 2017
Merged

Conversation

jesseditson
Copy link
Contributor

Prior PR had a few issues, didn't find them until today when I realized my test environment wasn't exactly clean (I had manually integrated this lib, so some headers that should have been missing were not!)

I'm not sure if excluding the RCTSource and RCTLayer is preferable to deleting them, since they don't seem to be used anywhere. Should I just remove the files instead?

Otherwise, this PR should get cocoapods into a truly working state.

@smoll
Copy link

smoll commented Nov 12, 2017

Not sure if this is relevant, but my pod install fails on master using the Podfile:

platform :ios, '8.0'

target 'mapboxspike' do
  pod 'react-native-mapbox-gl', :path => '../node_modules/@mapbox/react-native-mapbox-gl'
end

with

error: bundling failed: ambiguous resolution: module `/Users/s/workspace/mapboxspike/index.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:

  * `/Users/s/workspace/mapboxspike/ios/Pods/React/package.json`
  * `/Users/s/workspace/mapboxspike/node_modules/react-native/package.json`

does your PR resolve this error as well? For reference, here's a minimal project that reproduces the issue for me https://github.com/smoll/mapboxspike/tree/b1c61ca6d5566fe7ede26c02b036f76d4a5e1d6c

Edit: hmm, is this because Podfiles are generally used for integrating Mapbox + RN with an existing ObjC/Swift project? Is it possible to not hardcode the 'React' dependency here or would that bork dependency resolution?

@nitaliano
Copy link
Owner

@jesseditson Yes, RCTSource and RCTLayer should be deleted. RCTLayer collides with an RN class so I renamed them to RCTMGLSource and RCTMGLLayer so I missed removing them, if you could on this PR that would be greatly appreciated.

@nitaliano
Copy link
Owner

@jesseditson I'll test this out today, are you good with me merging this in once I test it?

@jesseditson
Copy link
Contributor Author

I got some build errors on the example yesterday, so i’m gonna try to figure out what’s going on there today - maybe hold off until that’s building? I suspect you’ll run in to the same errors in your tests as well. Sorry for the churn, lots of moving parts getting npm and coda pods to play nice together.

@henrikra
Copy link
Contributor

@jesseditson Should you try with empty repo then?

@carljoachim
Copy link

Please prioritize this, needs to use cocoapods in our codebase 😅

@nitaliano
Copy link
Owner

@jesseditson let me know if you need help with this, I would be happy to help. I would also get this working on an empty repo since the example project has extra things set on it for local development.

@nitaliano nitaliano added this to To Do in 6.0.2 Nov 17, 2017
@jesseditson
Copy link
Contributor Author

jesseditson commented Nov 17, 2017

@henrikra yes! Part of my current TODO list RE: this PR is to make sure it installs clean after create-react-native-app and eject. @nitaliano thank you! Just a bit sidetracked yesterday - If I'm not making major progress this afternoon I'll ping!

@jesseditson
Copy link
Contributor Author

Ok, latest has been tested (and works) using the following steps:

create-react-native-app MapboxCocoapods
cd MapboxCocoapods
yarn run eject
# Select first option, fill out info
yarn add jesseditson/react-native-mapbox-gl#v6_cocoapods
cd ios
pod init
vi Podfile
# remove test and tvOS outer targets (not sure why pod init makes these...)
# copy paste pods from ios/install.md
pod install
cd ..
vi App.js
# Add:
# import MapboxGL from '@mapbox/react-native-mapbox-gl';
# to the imports at the top, and
# <MapboxGL.MapView style={StyleSheet.absoluteFill}/>
# instead of the default content in render()
yarn run ios

Note:

When trying to get the example project in this repo to build, I noticed that it fails consistently with 'RCTAnimation/RCTValueAnimatedNode.h' file not found - this looks like the same issue as this react-native bug: facebook/react-native#13198
I tried updating the react-native version to see if it would resolve, but got the same error. The only thing I can see that is meaningfully different about the example podfile is the !use_frameworks directive. I'll continue poke it but figured you may want to address that separately as it seems folks are very interested in pod support on the v6 branch asap.

@jesseditson
Copy link
Contributor Author

@nitaliano Sorry again for the churn, LMK if I should file an issue about the example project, ignore it, or resolve in this PR!

@nitaliano
Copy link
Owner

I think we can just remove anything pod related for the example project. I'd rather have another example project in a different repo that's setup to use pods

@jesseditson
Copy link
Contributor Author

Sounds reasonable! I'll clean that out, 1 sec

@jesseditson
Copy link
Contributor Author

Ok, example now has no cocoapods and is building. That said, it looks like it is not compatible with the v6 API (it errors trying to use MapboxGL.UserTrackingModes). Seems out of scope for this PR to fix that bit, but I'd imagine it'll be a fairly straightforward port.

@ahmetabdi
Copy link

How is the progress of this?

@jesseditson
Copy link
Contributor Author

Should be ready to go! I'm running this branch on an active project, and it's working well. @nitaliano let me know if there's anything else you'd like me to update here!

@ahmetabdi
Copy link

I get this when I run through your steps from previous post @jesseditson

screen shot 2017-11-26 at 21 57 16

@jesseditson
Copy link
Contributor Author

@ahmetabdi Just ran through the steps in this comment to make sure I didn't miss something!

It worked for me, but the instructions aren't specific about what the Podfile should look like. What does your Podfile look like? My successful test had this podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'mapboxtest' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for mapboxtest

  # Flexbox Layout Manager Used By React Natve
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
 
  # React Native
  pod 'React', path: '../node_modules/react-native', subspecs: [
    # Comment out any unneeded subspecs to reduce bundle size.
    'Core',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTCameraRoll',
    'RCTGeolocation',
    'RCTImage',
    'RCTNetwork',
    'RCTPushNotification',
    'RCTSettings',
    'RCTTest',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'RCTLinkingIOS'
  ]
   
  # Mapbox
  pod 'react-native-mapbox-gl', :path => '../node_modules/@mapbox/react-native-mapbox-gl'

  target 'mapboxtest-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'mapboxtestTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

The error you have leads me to believe that the mapbox pod was not properly installed - perhaps try building via XCode to make sure the project does not error? Sometimes the errors can be hard to see when building via the CLI.

@ahmetabdi
Copy link

Adding React and Yoga pod did it, I couldn't see anywhere in the docs that said these should have been added to the Podfile only:

pod 'react-native-mapbox-gl', :path => '../node_modules/@mapbox/react-native-mapbox-gl'

Thanks @jesseditson

@jesseditson
Copy link
Contributor Author

Ah cool! Yeah the instructions are updated in this PR, but obviously that isn't on the main repo yet so I can understand the confusion!

@nitaliano
Copy link
Owner

@jesseditson Hi, sorry this has taken long to merge in I've been working on another project. I will try to get this in today with a proper npm release after

@nitaliano
Copy link
Owner

@jesseditson I just tried to run through the pods install and it's working great. We do need to make one change to this PR then we can merge it in. Would you be able to remove the changes made to the example apps xcode project file? It currently doesn't build due to some path changes

@jesseditson
Copy link
Contributor Author

@nitaliano no worries! This stuff takes time. Checked out the project from master, and tested the example build - looks good on my end, let me know if I can help with anything else!

@nitaliano
Copy link
Owner

nope, LGTM thanks for the PR!

@nitaliano nitaliano merged commit d7c9f7c into nitaliano:master Nov 28, 2017
@jesseditson jesseditson deleted the v6_cocoapods branch November 28, 2017 19:02
@nitaliano nitaliano removed this from To Do in 6.0.2 Nov 28, 2017
@ghost
Copy link

ghost commented Dec 5, 2017

Hello,

When installing via CocoaPods I'm getting an error from xcode

framework not found Mapbox

Ld /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/clustr.app/clustr normal x86_64
    cd /Users/michaelstokes/clustr/clustr_app/ios
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk -L/Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator -L/Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/React -L/Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/Stripe -L/Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/react-native-mapbox-gl -L/Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/yoga -F/Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator -F/Users/michaelstokes/Documents/FacebookSDK -filelist /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Intermediates.noindex/Clustr.build/Debug-iphonesimulator/clustr.build/Objects-normal/x86_64/clustr.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -Xlinker -object_path_lto -Xlinker /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Intermediates.noindex/Clustr.build/Debug-iphonesimulator/clustr.build/Objects-normal/x86_64/clustr_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -lReact -lStripe -lreact-native-mapbox-gl -lstdc++ -lyoga -framework AddressBook -framework Foundation -framework JavaScriptCore -framework Mapbox -framework PassKit -framework Security -framework WebKit -framework XCTest -weak_framework Contacts -ObjC -lc++ -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Intermediates.noindex/Clustr.build/Debug-iphonesimulator/clustr.build/clustr.app.xcent /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libReact.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTAnimation.a -framework FBSDKLoginKit /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTActionSheet.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTGeolocation.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTImage.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTLinking.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTNetwork.a -framework FBSDKShareKit -framework Bolts /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTSettings.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTText.a /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTVibration.a -framework FBSDKCoreKit /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/libRCTWebSocket.a -lAirMaps -lRNDeviceInfo -lPods-clustr -lRCTCamera -lreact-native-branch -lRNGeocoder -lReact -lyoga -lcxxreact -ljschelpers -lRNVectorIcons -lTPSStripe -Xlinker -dependency_info -Xlinker /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Intermediates.noindex/Clustr.build/Debug-iphonesimulator/clustr.build/Objects-normal/x86_64/clustr_dependency_info.dat -o /Users/michaelstokes/Library/Developer/Xcode/DerivedData/Clustr-fkpfvfogtttxepgdsdrkmamfpvax/Build/Products/Debug-iphonesimulator/clustr.app/clustr

ld: framework not found Mapbox
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My podfile is as follows:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'clustr' do

  # Flexbox Layout Manager Used By React Natve
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  
  # React Native
  pod 'React', path: '../node_modules/react-native', subspecs: [
    # Comment out any unneeded subspecs to reduce bundle size.
    'Core',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTCameraRoll',
    'RCTGeolocation',
    'RCTImage',
    'RCTNetwork',
    'RCTPushNotification',
    'RCTSettings',
    'RCTTest',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'RCTLinkingIOS'
  ]
  
  # Mapbox
  pod 'react-native-mapbox-gl', :path => '../node_modules/@mapbox/react-native-mapbox-gl'
    
  pod 'Stripe', '~> 10.1.0'

  inherit! :search_paths
end

When running pod install I get

MacBook-Pro:ios michaelstokes$ pod install
Analyzing dependencies
Fetching podspec for `React` from `../node_modules/react-native`
Fetching podspec for `react-native-mapbox-gl` from `../node_modules/@mapbox/react-native-mapbox-gl`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga/Yoga.podspec`
Downloading dependencies
Using React (0.50.4)
Using Stripe (10.1.0)
Using react-native-mapbox-gl (6.0.1)
Using yoga (0.50.4.React)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 19 dependencies from the Podfile and 4 total pods installed.

[!] Automatically assigning platform ios with version 8.0 on target clustr because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] The `clustr [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-clustr/Pods-clustr.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `clustr [Release]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-clustr/Pods-clustr.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

Thanks very much!

@jesseditson
Copy link
Contributor Author

I can try with the new version tomorrow, but in the meantime

  • Quit XCode
  • Try deleting node_modules and installing again, I think the framework downloads as a postInstall step
  • Try pod install again after a clean npm install
  • Open up the .xcworkspace (not .xcodeproj) file
  • Clean the build folder (cmd-opt-shift-k)
  • Build again

I have tested cold on this branch, but not integrated in 6.0.1 or via upgrade yet, so thanks for posting here, and let me know how the clean install goes!

@ghost
Copy link

ghost commented Dec 5, 2017

Hi @jesseditson Thanks for your response :)

I followed the steps provided, and unfortunately, it had no impact on the build which still fails with

framework not found Mapbox

@jesseditson
Copy link
Contributor Author

Hey! So I tried a brand new project (even named it clustr) using your exact podfile and using this lib from npm, and it all builds ok for me. The only thing that stood out to me was the !inherit :search_paths directive, which did not cause any issues for me.

I'm curious, here's what the sidebar of my app looks like in XCode - does this match yours? Specifically, do you have a frameworks folder under Pods -> Development Pods -> react-native-mapbox-gl?

Project Navigator

Did you update from an earlier version of react-native-mapbox-gl? Perhaps one that also used Cocoapods? One nuclear-ish option would be to pod deintegrate, which should remove all the artifacts, allowing you to pod install freshly. The fact that you're not getting errors until build time leads me to believe that there's something wrong with either your pod install or your framework search paths, and I know it can be difficult to tell if you've modified either - another nuclear-ish option would be to remove mapbox from your podfile, pod install, add it back, then pod install again. I believe this would roughly amount to the same thing as deintegrate, but generally what I'd be trying to accomplish is for it to run through a clean "add mapbox" process, since the Podspec has changed to include a framework. In theory cocoapods should handle this just fine, but with aggressive XCode caches it can end up a bit trickier.

@nitaliano
Copy link
Owner

If you are upgrading from a project where you had this library installed manually the header search paths that we're set to find Mapbox.framework could be the issue. If you have that set I would try removing it.

@ghost
Copy link

ghost commented Dec 8, 2017

Hi thanks, both @jesseditson and @nitaliano for your responses, I've been able to run through this again this evening.

Firstly @jesseditson mine is similiar to yours, and I appreciate the effort you went through to help both of you and continue to do so.

I attempted to run pod deintegrate and pod install following but this made no difference.

So just to clarify there are two apporaches to installing mapbox for ios; via CocoaPods or Manual?

I've tried both and had no luck, it seems that even when running the manual installation, I get odd and various errors such as framework not found XCTest

screen shot 2017-12-08 at 23 49 12

@ghost
Copy link

ghost commented Dec 11, 2017

After removing the project, cloning again, running npm install, and jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js clustr_app/node_modules/ on my project node modules, I then get the following after the app starts up which is libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

Update #860 seems related to libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

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.

None yet

6 participants