10

A new XCode project has Debug and Release Configurations. I've added a new one under "ProjectName > Info" called "development", which is for now a duplicate of "debug".

I wanted to create a new scheme for building the app in development mode, so I duplicated the "Projectname" scheme and named it "DevelopmentScheme".

I set the build configuration for "run" and "archive" to the new "development" configuration that I created.

I'm still able to build the original Scheme.

I'm also able to build all of the required libraries when the project is configured with the development scheme, but when I get to the linking phase, I get the error:

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

Being relatively new to iOS development, I'm not really sure what the issue could be. Since I duplicated everything, shouldn't that mean they behave in the same way? Thoughts on what might be different between the original and new schemes?

wheresmycookie
  • 683
  • 3
  • 16
  • 39

2 Answers2

27

The problem is that Xcode will expect to find the libraries inside a folder named after your custom configuration. You can add the custom configuration to each library you use, or better follow the steps below to make it use the libraries built via the Release configuration.

Steps:

  • Select your target
  • Open Build Settings tab
  • Search for 'Library Search Paths'
  • You'll see your new configuration name alongside Debug and Release
  • Double-click the space next to your new configuration name
  • Enter "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)"
  • Set recursive to true.

enter image description here

  • Exit the dialog and you should see:

enter image description here

(inspired by this post)

Ben Clayton
  • 80,996
  • 26
  • 120
  • 129
  • 2
    Thanks for the inspiration. I was building a react-native project and what I did was to change both `Per-configuration Build Products Path` and `Per-configuration Intermediate Build Files Path` to `$(PROJECT_TEMP_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)`. Took me hours, thanks Xcode. – tropicalfish Mar 27 '17 at 08:03
  • Perfect - This fixed the issue where adding a new scheme was breaking things. Maybe react-native should add a 'new-scheme' CLI cmd which would do all this for us (not that there's much there - but later down the track more things may be required) – James111 Apr 26 '17 at 03:51
  • For people who are struggling with react-native project, I found this guide quite useful: https://github.com/microsoft/react-native-code-push/blob/master/docs/multi-deployment-testing-ios.md. Also checkout this document regarding the new changes in XCode 11, and if you also have pod dependencies: https://github.com/microsoft/react-native-code-push/issues/1782 – Wing Jun 08 '20 at 03:58
9

Xcode 8.3.2 needs a bit different changes.

To make it work, you need to change the Per-configuration Build Products Path for your custom build config. For example, I have an Internal build config. In that field, instead of $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME), I put $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME), and now it works :).

Ben Kane
  • 9,331
  • 6
  • 36
  • 58
pvinis
  • 4,059
  • 5
  • 39
  • 59
  • Edits have to be more than 6 charachters and this it's a measly one char correction: It's Per-configuration Build Products Path :) – jonasl Jun 21 '17 at 06:40
  • Did you ever encounter the issue with, "Make sure you're running a packager server or have included a .jsbundle file in your application bundle." ? – TomTom Aug 07 '17 at 09:18
  • yea.. i just stop and start the packager and the project. it doesnt happen that often to annoy me enough to try to fix it. i know thats bad, but i need to fix other stuff before that. – pvinis Aug 07 '17 at 12:59
  • 1
    Tried your solution....but the problem I face is all schemes are building in single folder(release) inside ~/Library/...../Build/Products folder....Is it possible for different builds to be present in different folders based on the selected scheme and link the library successfully? Please help – user2552751 Aug 08 '18 at 19:57