Skip to content

Commit

Permalink
Include Swift lib in LIBRARY_SEARCH_PATHS
Browse files Browse the repository at this point in the history
Summary:
changelog: Fix Xcode 13 build error in HelloWorld template

Including `usr/lib/swift` fixes error:
{F642876047}

Reviewed By: p-sun

Differential Revision: D30301799

fbshipit-source-id: b93eb51ec5dd929ddc46574fc11bc89934eadeaf
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Aug 16, 2021
1 parent ec083f9 commit eb93886
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions template/ios/HelloWorld.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
"\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
"\"$(inherited)\"",
"\"$(SDKROOT)/usr/lib/swift\"",
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -495,6 +496,7 @@
"\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
"\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
"\"$(inherited)\"",
"\"$(SDKROOT)/usr/lib/swift\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
Expand Down

12 comments on commit eb93886

@alantoa
Copy link

Choose a reason for hiding this comment

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

thanks!

@cudocode19
Copy link

Choose a reason for hiding this comment

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

million thanks!!!!

@ansarikhurshid786
Copy link

Choose a reason for hiding this comment

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

Great is fixed my problem.

react native : 63
xcode: 13
macos: 11.6

@barbieri
Copy link
Contributor

Choose a reason for hiding this comment

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

guys, in particular @sammy-SC and @mikehardy: this fix to use SDKROOT is not really correct, the actual bug is Apple build of iphonesimulator lacks the arm64 architecture, see more info at #31480 (comment)

I've reported this to Apple, but if more people can do the same or someone have a faster access to Apple SDK guys, please ask this to be fixed.

@barbieri
Copy link
Contributor

Choose a reason for hiding this comment

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

@sammy-SC, @mikehardy see #31480 (comment), at least with Xcode 13.0 we just don't need these lines at all, being the problem $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME).

Would it be better to just have Podfile to delete the problematic LIBRARY_SEARCH_PATHS if Xcode is new enough? I don't have 12.5 or any other to confirm, but will see what I can do to verify.

@nithinyell
Copy link

Choose a reason for hiding this comment

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

This fix is not working for RN 0.65 Release schema

#32301

@mikehardy
Copy link
Contributor

Choose a reason for hiding this comment

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

@nithinyell that's a separate issue. I'll comment on your issue 32301

@NazarB99
Copy link

@NazarB99 NazarB99 commented on eb93886 Oct 6, 2021

Choose a reason for hiding this comment

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

@sammy-SC, @mikehardy see #31480 (comment), at least with Xcode 13.0 we just don't need these lines at all, being the problem $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME).

Would it be better to just have Podfile to delete the problematic LIBRARY_SEARCH_PATHS if Xcode is new enough? I don't have 12.5 or any other to confirm, but will see what I can do to verify.

Yes, can confirm that $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) in LIBRARY_SEARCH_PATH was a problem(Xcode 13, RN 0.66). After removing it my project was finally built successfully

@vtquy98
Copy link

Choose a reason for hiding this comment

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

You saved my day. Many thanks! (y)

@mikehardy
Copy link
Contributor

Choose a reason for hiding this comment

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

As a note for those interested, react-native version 0.67.0-rc.0 is already out (and seems to work fine, to me...) without all the path hackery and other workarounds, it has @barbieri's clean solution in there with the sole new requirement that you need to upgrade to cocoapods 1.11.2. However! Moving to 1.11.2 from 1.10.x cocoapods is trivial, it should not have a negative impact. If you are really suffering from build issues on Xcode, 0.67.0, even in it's rc.0 form should be a breath of fresh air.

@samridhgupta
Copy link

Choose a reason for hiding this comment

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

This answer helped
Quick Fix
https://stackoverflow.com/a/64071403/2457493

@carlaiau
Copy link

Choose a reason for hiding this comment

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

Beautiful! This also solved RN 0.64.2 in Xcode 13.2.1.

The alternative blank Swift.file strategy I read elsewhere did not fix it.

Please sign in to comment.