Skip to content

feat(cli-patform-ios): allow setting a path to a Podfile #1459

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

Closed
wants to merge 3 commits into from

Conversation

grabbou
Copy link
Member

@grabbou grabbou commented Aug 4, 2021

Draft following explanation in #1435 (comment)

To be tested, CC @tido64 and @kelset, as I think I am not getting a successful project initialisation (.xcworkspace missing).

The react-native.config.js of my example has been customised as follows:

ios: {
 project: "node_modules/react-native-test-app/ios/ReactTestApp.xcodeproj",
 podfile: "ios/Podfile"
},

@grabbou grabbou changed the title initial commit feat(cli-patform-ios): allow setting a path to a Podfile and fix sourceDir inside run-ios Aug 4, 2021
@grabbou grabbou changed the title feat(cli-patform-ios): allow setting a path to a Podfile and fix sourceDir inside run-ios feat(cli-patform-ios): allow setting a path to a Podfile Aug 4, 2021
@tido64
Copy link
Contributor

tido64 commented Aug 4, 2021

Thanks, @grabbou. I applied the fixes directly to relevant files under node_modules and it works for me. I don't like that we have to specify where to find the Podfile but I guess this will be addressed in next?

@Kiesco08
Copy link

Kiesco08 commented Aug 4, 2021

Thanks for the fix! There is another area where it also assumes project root directory is the podfile directory. Would it be possible to apply a change there too?

+    project_pod_file_dir = File.dirname(config["project"]["ios"]["podfile"])
-    relative_path = podspec_dir_path.relative_path_from project_root
+    relative_path = podspec_dir_path.relative_path_from project_pod_file_dir

@tido64
Copy link
Contributor

tido64 commented Aug 4, 2021

On closer inspection, this doesn't fully work. I ran pod install before applying the fix so it worked fine. But if I run pod install with the fix, I get this error:

[!] No podspec found for `ReactTestApp-DevSupport` in `..`

In addition to @Kiesco08's proposal, I also had to make podfile an absolute path, i.e.

      podfile: path.join(__dirname, "ios", "Podfile"),

It's been so long since I looked at it but this is why sourceDir had to be fixed in #1444.

Edit: ~~It looks like you would also have to let us override sourceDir to complete this fix. The config should then look like this:

ios: {
  sourceDir: path.join(__dirname, "ios"),
  project: "node_modules/react-native-test-app/ios/ReactTestApp.xcodeproj",
  podfile: "ios/Podfile"
},

Where sourceDir needs to be absolute path otherwise something else would break.~~

Edit 2: Alternatively, we can just change this:

project_root = Pathname.new(config["project"]["ios"]["sourceDir"])

to

  project_root = Pathname.new(config["project"]["ios"]["podfile"]).realpath.parent

Which should be more correct given that we shouldn't be using sourceDir to begin with.

@grabbou grabbou closed this Aug 5, 2021
@grabbou grabbou deleted the fix/potential-autolinking branch February 25, 2022 07:03
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.

3 participants