Skip to content

Conversation

@guidomb
Copy link

@guidomb guidomb commented Jan 23, 2017

This supersedes #309 and #305.

This is still a work-in-progress.

TODO

  • Create Xcode project that builds an iOS framework
  • Fix failing tests on Xcode
  • Make pod lib lint pass and make sure YogaKit can be included using CocoaPods
  • Add pod lib lint to .travis.yml
  • Migrate to travis osx image with Xcode 8.2

FOLLOW-UP

  • Make YogaKitSample use framework built by new Xcode project.
  • Make Travis to upload prebuilt versions of the framework. More here
  • Upgrade github/jekyll docs about installation using Cocoapods/Carthage

@guidomb
Copy link
Author

guidomb commented Jan 23, 2017

@dshahidehpour @emilsjolander There are 4 tests that are failing in Xcode. Most of them seems to rounding errors when computing frames. I think @hartbit run into the same issue. Do you have any idea what could be the problem or how to solve this?

@d16r
Copy link
Contributor

d16r commented Jan 23, 2017

@guidomb The rounding failure is happening because buck test and Xcode are slightly different testing environments and their scales seem to be different, generating different results. I'll take care of it today.

Meanwhile, would you like some help with some of those other tasks? I'll migrate Travis to Xcode 8.2 today.

@guidomb
Copy link
Author

guidomb commented Jan 23, 2017

@dshahidehpour Thanks! I'll wait until there are any news regarding the tests. Regarding the other items no worries I can work on those once the tests are fixed and there is no rush on migrating to Xcode 8.2 for now. I can do that once everything else has bee implemented but If you need / want to do that no worries.

@d16r
Copy link
Contributor

d16r commented Jan 23, 2017

I put up a PR to use Xcode8.2 in #353

@d16r
Copy link
Contributor

d16r commented Jan 24, 2017

@guidomb I landed fixes for the stuff blocking you. I also broke the list up into two sections, feel free to move stuff around!

@guidomb
Copy link
Author

guidomb commented Jan 24, 2017

Awesome! I'll keep working on this by the end of my day. Thanks!

@guidomb guidomb force-pushed the carthage-cocoapods-support branch from b9f5f34 to f75f717 Compare January 24, 2017 23:51
@guidomb
Copy link
Author

guidomb commented Jan 24, 2017

I've incorporated the latest changes in master. The Xcode project is compiling and tests are passing. Carthage is also working. I am having problems with CocoaPods. There seems to be a problems with how header files are included. Need to do more research about it.

@d16r
Copy link
Contributor

d16r commented Jan 24, 2017

Awesome progress @guidomb! let us know if we can help with the header import stuff, can you paste the error?

@guidomb
Copy link
Author

guidomb commented Jan 25, 2017

In file included from /Users/guidomb/Documents/projects/github/yoga/YogaKit/YogaKit/YGLayout.m:10:
In file included from /Users/guidomb/Documents/projects/github/yoga/YogaKit/YogaKit/YGLayout+Private.h:10:
/Users/guidomb/Documents/projects/github/yoga/YogaKit/YogaKit/YGLayout.h:11:9: fatal error: 'YogaKit/YGEnums.h' file not found
#import <YogaKit/YGEnums.h>
        ^

CompileC /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/Objects-normal/i386/YogaKit-dummy.o /private/var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/Pods/Target\ Support\ Files/YogaKit/YogaKit-dummy.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/Pods
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/guidomb/.rbenv/versions/2.3.1/bin:/usr/local/Cellar/rbenv/1.1.0/libexec:/Users/guidomb/.nvm/versions/node/v6.3.1/bin:/usr/local/heroku/bin:/Users/guidomb/.rbenv/shims:/Users/guidomb/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/guidomb/.swiftyrobot"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/guidomb/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/guidomb/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Xclang -fmodule-implementation-of -Xclang YogaKit -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-implicit-atomic-properties -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DPOD_CONFIGURATION_RELEASE=1 -DCOCOAPODS=1 -DNS_BLOCK_ASSERTIONS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -g -Wno-sign-conversion -Wno-infinite-recursion -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/YogaKit-generated-files.hmap -I/Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/YogaKit-own-target-headers.hmap -I/Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/YogaKit-all-non-framework-target-headers.hmap -ivfsoverlay /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/all-product-headers.yaml -iquote /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/YogaKit-project-headers.hmap -I/Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Products/Release-iphonesimulator/YogaKit/include -I/var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/Pods/Headers/Private -I/var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/Pods/Headers/Public -I/Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/DerivedSources/i386 -I/Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/DerivedSources -F/Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Products/Release-iphonesimulator/YogaKit -Wincomplete-umbrella -include /var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/Pods/Target\ Support\ Files/YogaKit/YogaKit-prefix.pch -MMD -MT dependencies -MF /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/Objects-normal/i386/YogaKit-dummy.d --serialize-diagnostics /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/Objects-normal/i386/YogaKit-dummy.dia -c /private/var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/Pods/Target\ Support\ Files/YogaKit/YogaKit-dummy.m -o /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/Objects-normal/i386/YogaKit-dummy.o

** BUILD FAILED **


The following build commands failed:
	CompileC /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/Objects-normal/i386/UIView+Yoga.o /Users/guidomb/Documents/projects/github/yoga/YogaKit/YogaKit/UIView+Yoga.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/guidomb/Library/Developer/Xcode/DerivedData/App-evazeamnsdiztlbpbpbtigpkmeaa/Build/Intermediates/Pods.build/Release-iphonesimulator/YogaKit.build/Objects-normal/x86_64/UIView+Yoga.o /Users/guidomb/Documents/projects/github/yoga/YogaKit/YogaKit/UIView+Yoga.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
 -> YogaKit (1.0.0)
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
    - NOTE  | xcodebuild:  /Users/guidomb/Documents/projects/github/yoga/YogaKit/YogaKit/YGLayout.h:11:9: fatal error: 'YogaKit/YGEnums.h' file not found

Pods workspace available at `/var/folders/gf/dslbq4t94zg44sz7wnk2lg2r0000gp/T/CocoaPods/Lint/App.xcworkspace` for inspection.

@hartbit
Copy link
Contributor

hartbit commented Jan 25, 2017 via email

@d16r
Copy link
Contributor

d16r commented Jan 25, 2017

@guidomb I messed around with this last night for a bit too. Here are some takeaways:

  1. Lose the symlink to add the yoga/* files. Just move .swift-version and YogaKit.podspec to the parent directory. @emilsjolander is fine with that.
  2. React-Native has to do something very similar. They have a mirrored copy of yoga in their library. Here's their podspec. Notice how they declare yoga as a subspec and make another react subspec. I think we should go that route too. I tried it last night, but pod lib lint still wasn't happy.

@alloy
Copy link

alloy commented Jan 26, 2017

I was able to get it to lint with the changes outlined by @dshahidehpour and adding a header search path: afa4ff6

Additionally I simplified the file selection sets.

Does anyone have an application that this should integrate with that I can test out? Or should this be used inside React Native?

@alloy
Copy link

alloy commented Jan 26, 2017

However, I should add that the fix depends on a change that’s in CP 1.2.0, which is currently in RC: https://github.com/CocoaPods/CocoaPods/blob/master/CHANGELOG.md#120beta1-2016-10-28

DESC
spec.documentation_url = 'https://facebook.github.io/yoga/docs/getting-started/'
spec.source = { :git => 'https://github.com/facebook/yoga.git', :tag => "v#{spec.version}" }
spec.platform = :ios
Copy link

Choose a reason for hiding this comment

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

Why is this only targeting iOS, shouldn’t the core library be able to build for all platforms? (So minus the UIView stuff.)

Copy link
Contributor

Choose a reason for hiding this comment

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

While the core library could technically build on all platforms, I plan to send a PR soon with an NSView extension. I guess we could all platforms then.

Copy link

Choose a reason for hiding this comment

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

Gotcha.

So then I guess my assumption that this podspec was somehow also tied to React Native’s podspec using this is incorrect. /cc @javache

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

@hartbit @dshahidehpour I am migrating my current project to use the latest version of Yoga and using Carthage with the goal of testing this PR. So far the built generated by Carthage works. Had no issues with header files.

This change forced me to migrate to the new API that @hartbit introduced in #322. Just wanted to say, awesome work! The API feels way more natural in Swift now. One thing I noticed is that both border and position don't support the horizontal and vertical edge cases. Is this correct?

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

@dshahidehpour @alloy How should I proceed with CocoaPods support? Should I add the changes you have suggested to this PR?

@alloy
Copy link

alloy commented Jan 26, 2017

Is your project OSS and/or do you know of one in which this podspec is expected to work for me to test?

@alloy
Copy link

alloy commented Jan 26, 2017

…or can you create a simple Hello World app for Yoga for me to test with?

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

@alloy My project is not open source (yet). I want to open source it but I need to do some work first in order for it to be ready to be published. I don't see that happening any time soon, at least not in the next few day. But I could extract some code from it in order to test CocoaPods integration. I'll try to do that later this day o tomorrow.

@alloy
Copy link

alloy commented Jan 26, 2017

@guidomb Yeah just something simple is good enough. I could do it myself, but as I haven’t used the API in anger I might make it too simple.

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

@alloy OK I'll do that then. I'll try to do that by the end of my day (GMT -03:00) or tomorrow.

@d16r
Copy link
Contributor

d16r commented Jan 26, 2017

Update!

TL:DR; I'm making a Cocoapod specifically for the C-Lib. Once that lands (in a few hours) we can simply add that pod as a dependency to YogaKit's podspec and keep the imports as <yoga/*>.

The reason we are doing this is that we don't want to change the imports of core yoga files to YogaKit. Currently, that's not really possible by adding them all to the same podspec without building a static library (pod lib lint --use-libraries). The problem with a static library is that it won't play nice with Swift Projects (source: @nlutsenko).

I was surprised to learn this because the React Native library uses yoga as well, and they have yoga defined as a subspec. What I learned is that you can only build the React Native pod as a static lib, so, I don't think it works with Swift (need to confirm).

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

@dshahidehpour OK let me know once that is landed into master. AFAIK it should be a problem for Swift users because we can make YogaKit podspec to create a framework. The static lib should only be for the C code. I am assuming that framework can contain a static lib. Not really sure if my assumption is correct.

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

This blog post seems to explain how to use static libs inside frameworks.

@d16r
Copy link
Contributor

d16r commented Jan 26, 2017

@guidomb The C-lib podspec is landing now. When we push it, do you think that we should push it as a static lib? I'd be fine with pushing it as a regular framework.

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

@dshahidehpour Not really sure. I think it would be better to use frameworks because I know that should work we both Swift and Objective-C users. What do you think @alloy ?

Guido Marucci Blas added 2 commits January 26, 2017 19:23
Yoga now exposes its C API as CocoaPod. YogaKit dependends
on it.
@guidomb guidomb force-pushed the carthage-cocoapods-support branch from f75f717 to 95df27d Compare January 26, 2017 22:41
@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

I've rebased with master and added Yoga as a dependency of YogaKit. pod lib lint passes if the --allow-warnings flag is given. I am getting the following warning

 -> Yoga (1.0.0)
    - WARN  | source: The version should be included in the Git tag.

Because the git tag hasn't been created yet.

I still need to fully test this in a project. Later today I will publish the project where I am using Yoga and I'll create a brach to include YogaKit using CocoaPods to make sure that everything is working.

@dshahidehpour remember that once this PR is landed, every time you want to cut a new release you are going to have to publish both Yoga and YogaKit pods to the trunk repository.

@guidomb
Copy link
Author

guidomb commented Jan 26, 2017

Also @dshahidehpour did you have a chance to take a look at my comment in #352 (comment)

One thing I noticed is that both border and position don't support the horizontal and vertical edge cases. Is this correct?

@hartbit
Copy link
Contributor

hartbit commented Jan 26, 2017

One thing I noticed is that both border and position don't support the horizontal and vertical edge cases. Is this correct?

That is my doing. I based myself off the React Native properties (https://facebook.github.io/react-native/docs/layout-props.html). I think they don't exist for ambiguity reasons. The horizontal margin makes sense, but the horizontal position seems less clear.

@d16r
Copy link
Contributor

d16r commented Jan 26, 2017

I've rebased with master and added Yoga as a dependency of YogaKit. pod lib lint passes if the --allow-warnings flag is given. I am getting the following warning

Yeah I was getting the same warning. I had to use --allow-warnings to create the Yoga pod. We should talk to @emilsjolander about changing the release tags. Go ahead and use the --allow-warnings flag to create your pod.

@emilsjolander
Copy link
Contributor

It's a weird thing to warn about, seems non-important. I'll think about it for the next time. For now let's just ignore the warning. I'll push YogaKit to cocoapods once this has been merged.

@d16r
Copy link
Contributor

d16r commented Jan 26, 2017

Awesome work @guidomb! I'm going to import this, fixup a couple things (update spec description) and merge it! We can continue to iterate after it lands. Thank you so much!

@facebook-github-bot
Copy link
Contributor

@dshahidehpour has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@alloy
Copy link

alloy commented Jan 26, 2017

@emilsjolander People would push specs and forget to push their git tags. The warning is correct in that the build would fail in that case.

@emilsjolander
Copy link
Contributor

@alloy Ok good to know the reason behind it. We continuously tag the project so not a problem i foresee us having. Can I remove this lint from the project without disabling all the other helpful warnings?

@alloy
Copy link

alloy commented Jan 27, 2017

Hmmm, don't think so, but I'll double check when I'm back at a machine. Nonetheless, this should just pass if you push the tag before the spec during your release process.

@alloy
Copy link

alloy commented Jan 27, 2017

Btw, just wanna be sure that you are indeed switching to a different versioning scheme: 2cc2a5f#commitcomment-20632914

@emilsjolander
Copy link
Contributor

@alloy The version number of the project does not match the tag used. See the release for 1.0.0 here https://github.com/facebook/yoga/releases/tag/v2017.01.23.00

@alloy
Copy link

alloy commented Jan 27, 2017

Ok 👌

@alloy
Copy link

alloy commented Jan 27, 2017

 -> Yoga (1.0.0)
   - WARN  | source: The version should be included in the Git tag.

Because the git tag hasn't been created yet.

Oops, I didn't read that well.

This warning is not about the tag not having been created yet, but rather that the tag’s name does not include the version (in this case 1.0.0), which does seem something you want to be able to do.

There’s no way to currently disable just that warning. If this remains an issue with future tags, I suggest you file a new issue about it.

@guidomb
Copy link
Author

guidomb commented Jan 27, 2017

I think that the tag name should follow semantic versioning. Otherwise CocoaPods won't be able to checkout the corresponding revision after resolving the version that should be used after running pod install. Not 100% sure though.

@alloy
Copy link

alloy commented Jan 27, 2017

No there’s no such requirement. It’s just common and allows you to not have to type out two different versions in the same file, but instead refer to the pod version for the tag’s name. Why do you think it might be required?

@d16r
Copy link
Contributor

d16r commented Jan 27, 2017

@guidomb just a quick heads-up. I'm going to trim this diff so it only contains the Cocoapods support.

Our internal build system is giving us some grief about the changes made for the Carthage support, so, I want to attack that stuff in another diff. Me or @emilsjolander need to create the .xcodeproj and add Facebook as the Organization. We also to need to some work on the .plist files so they work externally, and internally at FB.

@alloy
Copy link

alloy commented Jan 27, 2017

@dshahidehpour Btw, want me to send you a PR to run pod lib lint on Travis CI?

@d16r
Copy link
Contributor

d16r commented Jan 27, 2017

@alloy Yes plz! Just an FYI, because of our branch tag, we will have to add --allow-warnings to make it pass.

@alloy
Copy link

alloy commented Jan 27, 2017

@dshahidehpour Aye, indeed.

For now, just want to let you know that I’m successfully able to use the core pod in React Native facebook/react-native#12089

@guidomb
Copy link
Author

guidomb commented Jan 27, 2017

@dshahidehpour OK. Let me know if you need any help preparing the project to be Carthage friendly. Do you have an ETA for that?

@alloy I had the impression that tag name must matched pod version but I wasn't really sure. Had the memory of not being able to publish a pod for this reason but it's been a long time since the last time I published a pod.

@d16r d16r mentioned this pull request Jan 27, 2017
@d16r
Copy link
Contributor

d16r commented Jan 27, 2017

@alloy @guidomb Cocoapods support has landed, so I'm going to keep this thread closed. We can talk about Carthage support in #361, or in a new pull request. Thanks!

@quentinfasquel
Copy link

@dshahidehpour When you say Cocoapods support has landed, any idea if this issue has been solved: facebook/react-native#11781 ? Thank you.

@alloy
Copy link

alloy commented Feb 2, 2017

@quentinfasquel
Copy link

Thanks @alloy for your quick reply. So that means I should wait?
I found that just adding the 'Core' subspec doesn't trigger the yoga/Yoga.h issue but when I import React will encounter an issue with the C++ lib that's used: 'cstdint' file not found in JSBundleType.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants