سؤال

I have two Xcode projects: Super and Sub. Super has a custom configuration: Enterprise. Sub only has the default configurations: Debug and Release. Super has a target dependency on Sub. When I build Super with the Enterprise configuration, Sub builds with its default configuration: Release. This yields the following hierarchy:

Build
|-Products
  |-Enterprise-iphoneos
    |-Super.app
  |-Release-iphoneos
    |-libSub.a
    |-Sub
      |-Sub.h

Clang fails to build because libSub.a and Sub/Sub.h is normally in the same directory as Super.app, but instead is in a different directory because Sub built with the Release configuration instead of Enterprise. I control both projects, so I could easily add an Enterprise configuration to Sub, but I feel like there must be a magical incantation of Xcode Build Settings to make this work.

هل كانت مفيدة؟

المحلول

I have solved exactly the same problem by using Xcode Configuration Files in my parent project - typically your application.

These are the steps I took:

  1. Create a Base Configuration file in Xcode via New > Other > Configuration File.

  2. Write your base xcconfig file, mine looks a bit like this:

    /// Configure Search Paths
    HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/include" "$(BUILT_PRODUCTS_DIR)/usr/local/include"
    LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../Externals/Libraries/GoogleAnalytics"
    
    /// Linker flags
    OTHER_LDFLAGS=-ObjC -all_load
    
  3. The thing to note here, is that $(BUILT_PRODUCTS_DIR) is the concatenation of:

    $(BUILD_DIR)/$(CONFIGURATION)-$(PLATFORM_NAME)
    
  4. Write a specialised configuration for a custom configuration. I created an Ad Hoc configuration which duplicated Release, therefore my search paths now look like this:

    #include "BaseConfig.xcconfig"
    
    /// Ad Hoc search paths
    HEADER_SEARCH_PATHS = "$(BUILD_DIR)/Release-$(PLATFORM_NAME)/include" "$(BUILD_DIR)/Release-$(PLATFORM_NAME)/usr/local/include"
    LIBRARY_SEARCH_PATHS = "$(BUILD_DIR)/Release-$(PLATFORM_NAME)" "$(SRCROOT)/../Externals/Sources/GoogleAnalytics"
    

Then in your application's project's Info tab select your configurations, to use the Base Configuration for Debug and Release, and then the special one for your custom configuration.

نصائح أخرى

I had a similar problem in one of my apps. In Xcode 12.4 I was able to solve it by setting the System Framework Search Paths for my extra configuration (which I call Ad Hoc for Test) to $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME).

This setting can be found in your project by selecting your Target and then the Build Settings tab. I suggest searching for "System Framework" to find it. Once you add the path, Xcode will translate it to the actual path on your system, as seen in my screenshot. This works for archiving too.

Build Settings Example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top