-
Notifications
You must be signed in to change notification settings - Fork 149
[generator-macos] Use CocoaPods to build iOS and macOS targets #298
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
Conversation
...erator-macos/templates/macos/HelloWorld-iOS/Images.xcassets/AppIcon.appiconset/Contents.json
Show resolved
Hide resolved
local-cli/generator-macos/templates/macos/HelloWorld-iOS/Info.plist
Outdated
Show resolved
Hide resolved
local-cli/generator-macos/templates/macos/HelloWorld-macOS/Base.lproj/Main.storyboard
Outdated
Show resolved
Hide resolved
<key>NSSupportsAutomaticTermination</key> | ||
<true/> | ||
<key>NSSupportsSuddenTermination</key> | ||
<true/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the defaults for a macOS app nowadays 🤷♂
local-cli/generator-macos/templates/macos/HelloWorld-macOS/main.m
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,40 @@ | |||
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the auto-linking that doesn’t work yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we tracking getting it working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is up next, I just wanted to make PRs for distinct units of work.
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' | ||
|
||
abstract_target 'Shared' do | ||
# use_native_modules! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
# use_native_modules! | ||
|
||
pod 'React', :path => "../node_modules/react-native-macos/" | ||
pod 'React-Core', :path => "../node_modules/react-native-macos/React" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the React-Core file is missing some source files for macOS. When i run the init'd app I get runtime errors about StatusBar and other components. It looks like the React/Modules/RCTStatusBarManager.m
needs to be added to React-Core-macOS
as it is in React-Core-iOS
. Its one of the things I had to fix in the static React.xcodeproj too for the initial PR for react-native-macos-init
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I verified the fix locally. Just remove the line in React-Core.podspec
that is excluding "Modules/RCTStatusBarManager.*"
for osx.
There are probably a few more files that have to be un-excluded to re-align with the changes I made in the static XCodeproj. I'll do that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice one 👍 I was going to ask about this one, but assumed it was currently a mobile only API. I’ll add this one in this PR and you can follow up with others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the comment on the guarded imports, we should perhaps see if we can have a CI task that does a build [of e.g. RNTester] that only builds for iOS and then only for macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I was going to update the CI to build RNTester using pods. Its currently sliced by platform/flavor now but using the static xcodeproj's. @HeyImChris FYI
} | ||
|
||
/** | ||
* @todo Move this upstream to @react-native-community/cli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we tracking this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll be touching the CLI package for the next iteration of this when I make auto-linking work and will make this change then.
@@ -0,0 +1,40 @@ | |||
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we tracking getting it working?
end | ||
|
||
target 'HelloWorld-iOS' do | ||
platform :ios, '9' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try and do currentVersion-1 for iOS, so probably worth making this 12 unless that'd break with RN still being on 9 somehow.
Also why is there an iOS target in the macos directory/Podfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try and do currentVersion-1 for iOS, so probably worth making this 12 unless that'd break with RN still being on 9 somehow.
Nothing would break, just trying to keep this in sync with upstream.
Also why is there an iOS target in the macos directory/Podfile?
Great question and one I asked myself too! 😄
@tom-un Explained to me that he likes to have one in the macos
dir for now as it can target the iOS
bits of our RN fork to quickly test if we’ve broken code as opposed to the code in the ios
dir that targets upstream RN. We did briefly discuss to perhaps hide this extra iOS target by default in the future, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, and I think it'll be easier to implement a --add-ios-target
flag once this PR lands. Because it could be implemented as Ruby script. Right now I think we'd have to have two project.pbxproj
templates: one with only a mac target and another with mac and ios targets and that would be a pain to maintain.
002f7b8
to
3ac07b9
Compare
3ac07b9
to
53ea1c5
Compare
15c2fb4
to
880787a
Compare
Please select one of the following
I am removing an existing difference between facebook/react-native and microsoft/react-native 👍
I am cherry-picking a change from Facebook's react-native into microsoft/react-native 👍
I am making a fix / change for the macOS implementation of react-native
I am making a change required for Microsoft usage of react-native
Updates the template from upstream v0.62 so we’ll have less merge issues going forward.
Renames iOS target to also have a platform suffix. (E.g.
HelloWorld-iOS
)Renames macOS product to remove the platform suffix. (E.g.
HelloWorld.app
)Adds
Podfile
which is able to build both iOS and macOS target.In the next PR I’ll work on auto-linking community modules.
Microsoft Reviewers: Open in CodeFlow