yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project
MIT License
7.04k stars 819 forks source link

Way to create universal framework target #73

Open toshi0383 opened 7 years ago

toshi0383 commented 7 years ago
lgtm $ xcodegen-debug
📋  Loaded spec:
  Name: LGTM
  Targets:
    🖥  application: LGTM
    📱  framework: LGTMKit_iOS
    🖥  framework: LGTMKit_macOS
    📺  framework: LGTMKit_tvOS
    ⌚️  framework: LGTMKit_watchOS
    📱  application: LGTM_iOS
2 Spec validations errors:
    - Target "LGTM" has invalid dependency: "LGTMKit"
    - Target "LGTM_iOS" has invalid dependency: "LGTMKit"

How could I generate an empty(buildSettings = { };) framework target? I don't want each target for every platform.

toshi0383 commented 7 years ago

BTW I have a xcconfig like this. This should be enough for universal framework.

SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator appletvos appletvsimulator
TARGETED_DEVICE_FAMILY = 1,2,3,4

ENABLE_BITCODE[sdk=iphone*] = YES;
ENABLE_BITCODE[sdk=watch*] = YES;
ENABLE_BITCODE[sdk=appletv*] = YES;

LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=iphone*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=watch*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=appletv*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks

// NOTE: LGTMKit depends on Carthage frameworks
FRAMEWORK_SEARCH_PATHS[sdk=macosx*] = $(inherited) $(PROJECT_DIR)/Carthage/Build/Mac
FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(inherited) $(PROJECT_DIR)/Carthage/Build/iOS

APPLICATION_EXTENSION_API_ONLY = YES;
yonaskolb commented 7 years ago

I see. What's happening now is that I'm guessing you're specifying

platform: iOS,macOS,tvOS,watchOS

which then automatically creates a target for each platform.

There are some downsides to having a universal framework as opposed to frameworks per platform, but we should still make it possible. I guess what is needed is to make platform optional, but with the knowledge that the developer will provide all the relevant build settings if it's left out.

These are the platform setting presets by the way https://github.com/yonaskolb/XcodeGen/tree/master/SettingPresets/Platforms

If you did want to stick the the multi target approach you can fix the errors in the spec by just appending _iOS or _macOS to the target dependencies. Note that the PRODUCT_NAME is still the same and without the suffix, so you can still import these frameworks with import LGTMKit

toshi0383 commented 7 years ago

Thanks for quick follow up! I will try to workaround it by appending _iOS and _macOS for now.👌