Skip to content

Commit

Permalink
Minimum OS versions, fixed iOS & OS X builds
Browse files Browse the repository at this point in the history
- Minimum OS versions for iOS, OS X and watchOS
- xcodeTargets => xcodeTargetsIos, xcodeTargetsOsx & xcodeTargetsWatchos
- Extensive refactoring of Podfile updating logic
- Extensive unit tests for all the forgoing changes
- Fixes j2objc-contrib#520

TODO: get watchOS build working
  • Loading branch information
brunobowden committed Oct 21, 2015
1 parent cee7d0b commit f872086
Show file tree
Hide file tree
Showing 5 changed files with 769 additions and 346 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,23 +622,26 @@ class J2objcConfig {
* <p/>
* See https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW2
*/
String minIosVersion = '6.0'
// Matches the oldest version supported in Xcode 7
String minVersionIos = '6.0'

/**
* The minimum OS X version to build against. You cannot use APIs that are not supported
* in this version.
* <p/>
* See https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW2
*/
String minOsxVersion = '10.4'
// Matches the oldest version supported in Xcode 7
String minVersionOsx = '10.4'

/**
* The minimum Watch OS version to build against. You cannot use APIs that are not supported
* in this version.
* <p/>
* See https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW2
*/
String minWatchosVersion = '1.0'
// Matches the oldest version supported in Xcode 7
String minVersionWatchos = '1.0'

// XCODE
/**
Expand All @@ -649,28 +652,54 @@ class J2objcConfig {
*
*/
String xcodeProjectDir = null

/**
* Xcode app targets that should be linked to the generated library.
* iOS app and test Xcode targets to link to the generated libraries.
*
* This will automatically add linkage for any target in the specified list
* to the generated shared library. This should include any Test and Watch
* targets if needed.
* to the generated shared libraries. This should include test targets also.
*/
List<String> xcodeTargetsIos = new ArrayList<>()
/**
* iOS app and test Xcode targets to link to the generated libraries.
*
* If empty (default), it will link all targets defined within the Xcode project.
* @param xcodeTargetsIos targets to link to the generated libraries.
*/
List<String> xcodeTargets = new ArrayList<>()
void xcodeTargetsIos(String... xcodeTargetsIos) {
appendArgs(this.xcodeTargetsIos, 'xcodeTargetsIos', xcodeTargetsIos)
}

/**
* Add targets within Xcode to link to the generated shared library.
* OS X app and test Xcode targets that should be linked to the generated libraries.
*
* If this is never called, it will default to linking all targets
* to the generated shared library.
* This will automatically add linkage for any target in the specified list
* to the generated shared libraries. This should include test targets also.
*/
List<String> xcodeTargetsOsx = new ArrayList<>()
/**
* OS X app and test Xcode targets to link to the generated libraries.
*
* @param xcodeTargets links targets to generated library.
* @param xcodeTargetsOsx targets to link to the generated libraries.
*/
void xcodeTargets(String... xcodeTargets) {
appendArgs(this.xcodeTargets, 'xcodeTargets', xcodeTargets)
void xcodeTargetsOsx(String... xcodeTargetsOsx) {
appendArgs(this.xcodeTargetsOsx, 'xcodeTargetsOsx', xcodeTargetsOsx)
}

/**
* watchOS app and test Xcode targets that should be linked to the generated libraries.
*
* This will automatically add linkage for any target in the specified list
* to the generated shared libraries. This should include test targets also.
*/
List<String> xcodeTargetsWatchos = new ArrayList<>()
/**
* watchOS app and test Xcode targets to link to the generated libraries.
*
* @param xcodeTargetsWatchos targets to link to the generated libraries.
*/
void xcodeTargetsWatchos(String... xcodeTargetsWatchos) {
appendArgs(this.xcodeTargetsWatchos, 'xcodeTargetsWatchos', xcodeTargetsWatchos)
}


protected boolean finalConfigured = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ class NativeCompilation {
switch (targetSpec) {
case TargetSpec.TARGET_IOS_DEVICE:
clangArgs += iphoneClangArgs
clangArgs += ["-miphoneos-version-min=${config.minIosVersion}"]
clangArgs += ["-miphoneos-version-min=${config.minVersionIos}"]
linkerArgs += ["-L$j2objcPath/lib"]
break
case TargetSpec.TARGET_IOS_SIMULATOR:
clangArgs += simulatorClangArgs
clangArgs += ["-mios-simulator-version-min=${config.minIosVersion}"]
clangArgs += ["-mios-simulator-version-min=${config.minVersionIos}"]
linkerArgs += ["-L$j2objcPath/lib"]
break
case TargetSpec.TARGET_OSX:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class PodspecTask extends DefaultTask {
String getPodNameRelease() { "j2objc-${project.name}-release" }

@Input
String getMinIosVersion() { return J2objcConfig.from(project).getMinIosVersion() }
String getMinVersionIos() { return J2objcConfig.from(project).getMinVersionIos() }
@Input
String getMinOsxVersion() { return J2objcConfig.from(project).getMinOsxVersion() }
String getMinVersionOsx() { return J2objcConfig.from(project).getMinVersionOsx() }
@Input
String getMinWatchosVersion() { return J2objcConfig.from(project).getMinWatchosVersion() }
String getMinVersionWatchos() { return J2objcConfig.from(project).getMinVersionWatchos() }


// CocoaPods podspec files that are referenced by the Podfile
Expand All @@ -97,19 +97,19 @@ class PodspecTask extends DefaultTask {
String libDirOsxDebug = relativizeToBuildDir(new File(getDestLibDirFile(), 'x86_64Debug'), project)
String libDirOsxRelease = relativizeToBuildDir(new File(getDestLibDirFile(), 'x86_64Release'), project)

validateNumericVersion(getMinIosVersion(), 'minIosVersion')
validateNumericVersion(getMinOsxVersion(), 'minOsxVersion')
validateNumericVersion(getMinWatchosVersion(), 'minWatchosVersion')
validateNumericVersion(getMinVersionIos(), 'minVersionIos')
validateNumericVersion(getMinVersionOsx(), 'minVersionOsx')
validateNumericVersion(getMinVersionWatchos(), 'minVersionWatchos')

String podspecContentsDebug =
genPodspec(getPodNameDebug(), headerIncludePath, resourceIncludePath,
libDirIosDebug, libDirOsxDebug, libDirIosDebug,
getMinIosVersion(), getMinOsxVersion(), getMinWatchosVersion(),
getMinVersionIos(), getMinVersionOsx(), getMinVersionWatchos(),
getLibName(), getJ2objcHome())
String podspecContentsRelease =
genPodspec(getPodNameRelease(), headerIncludePath, resourceIncludePath,
libDirIosRelease, libDirOsxRelease, libDirIosRelease,
getMinIosVersion(), getMinOsxVersion(), getMinWatchosVersion(),
getMinVersionIos(), getMinVersionOsx(), getMinVersionWatchos(),
getLibName(), getJ2objcHome())

logger.debug("Writing debug podspec... ${getPodspecDebug()}")
Expand Down
Loading

0 comments on commit f872086

Please sign in to comment.