Xcode: Make Xcode build libwg-go.a automatically

This is based on Jeroen Leenarts' work (commit a3cdb84)
and Jason Donenfeld's work (commit 9d01829).

To reproduce:

In Xcode, add a new target called 'WireGuardGoBridge' with
the Cross-platform > External build system template. Configure
that target with the 'make' build tool and ask it to build on the
wireguard-go-bridge directory.

The Makefile in wireguard-go-bridge is already configured to
handle being called from Xcode as an external build system.

In WireGuardNetworkExtension's build phases, add a dependancy to
WireGuardGoBridge, and ask it to link to libwg-go.a (the make command
shall generate this archive). Add libwg-go.a as a library to be linked
with.

Edit the Xcode pbxproj file and in the file reference entry for
libwg-go.a, set path as "libwg-go.a" and sourceTree as
BUILT_PRODUCTS_DIR.
This commit is contained in:
Roopesh Chander 2018-10-27 15:31:32 +05:30
parent 69a35ec3ff
commit be25d9d491
1 changed files with 77 additions and 0 deletions

View File

@ -25,6 +25,7 @@
6F7774EA217229DB006A79B3 /* IPAddressRange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7774E9217229DB006A79B3 /* IPAddressRange.swift */; }; 6F7774EA217229DB006A79B3 /* IPAddressRange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7774E9217229DB006A79B3 /* IPAddressRange.swift */; };
6F7774EF21722D97006A79B3 /* TunnelsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7774EE21722D97006A79B3 /* TunnelsManager.swift */; }; 6F7774EF21722D97006A79B3 /* TunnelsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7774EE21722D97006A79B3 /* TunnelsManager.swift */; };
6F7774F321774263006A79B3 /* TunnelEditTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7774F221774263006A79B3 /* TunnelEditTableViewController.swift */; }; 6F7774F321774263006A79B3 /* TunnelEditTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7774F221774263006A79B3 /* TunnelEditTableViewController.swift */; };
6FDEF7E421846C1A00D8FBF6 /* libwg-go.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6FDEF7E321846C1A00D8FBF6 /* libwg-go.a */; };
6FF4AC1F211EC472002C96EB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6FF4AC1E211EC472002C96EB /* Assets.xcassets */; }; 6FF4AC1F211EC472002C96EB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6FF4AC1E211EC472002C96EB /* Assets.xcassets */; };
6FF4AC22211EC472002C96EB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6FF4AC20211EC472002C96EB /* LaunchScreen.storyboard */; }; 6FF4AC22211EC472002C96EB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6FF4AC20211EC472002C96EB /* LaunchScreen.storyboard */; };
6FF4AC472120B9E0002C96EB /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6FF4AC462120B9E0002C96EB /* NetworkExtension.framework */; }; 6FF4AC472120B9E0002C96EB /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6FF4AC462120B9E0002C96EB /* NetworkExtension.framework */; };
@ -38,6 +39,13 @@
remoteGlobalIDString = 6F5D0C19218352EF000F85AD; remoteGlobalIDString = 6F5D0C19218352EF000F85AD;
remoteInfo = WireGuardNetworkExtension; remoteInfo = WireGuardNetworkExtension;
}; };
6FDEF7E121846C0000D8FBF6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6FF4AC0C211EC46F002C96EB /* Project object */;
proxyType = 1;
remoteGlobalIDString = 6FDEF7DD21846BC100D8FBF6;
remoteInfo = WireGuardGoBridge;
};
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
@ -78,6 +86,7 @@
6F7774E9217229DB006A79B3 /* IPAddressRange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPAddressRange.swift; sourceTree = "<group>"; }; 6F7774E9217229DB006A79B3 /* IPAddressRange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPAddressRange.swift; sourceTree = "<group>"; };
6F7774EE21722D97006A79B3 /* TunnelsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelsManager.swift; sourceTree = "<group>"; }; 6F7774EE21722D97006A79B3 /* TunnelsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelsManager.swift; sourceTree = "<group>"; };
6F7774F221774263006A79B3 /* TunnelEditTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelEditTableViewController.swift; sourceTree = "<group>"; }; 6F7774F221774263006A79B3 /* TunnelEditTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelEditTableViewController.swift; sourceTree = "<group>"; };
6FDEF7E321846C1A00D8FBF6 /* libwg-go.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libwg-go.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6FF4AC14211EC46F002C96EB /* WireGuard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WireGuard.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6FF4AC14211EC46F002C96EB /* WireGuard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WireGuard.app; sourceTree = BUILT_PRODUCTS_DIR; };
6FF4AC1E211EC472002C96EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 6FF4AC1E211EC472002C96EB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6FF4AC21211EC472002C96EB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 6FF4AC21211EC472002C96EB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
@ -92,6 +101,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
6FDEF7E421846C1A00D8FBF6 /* libwg-go.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -217,6 +227,7 @@
6FF4AC452120B9E0002C96EB /* Frameworks */ = { 6FF4AC452120B9E0002C96EB /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
6FDEF7E321846C1A00D8FBF6 /* libwg-go.a */,
6FF4AC462120B9E0002C96EB /* NetworkExtension.framework */, 6FF4AC462120B9E0002C96EB /* NetworkExtension.framework */,
); );
name = Frameworks; name = Frameworks;
@ -224,6 +235,23 @@
}; };
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXLegacyTarget section */
6FDEF7DD21846BC100D8FBF6 /* WireGuardGoBridge */ = {
isa = PBXLegacyTarget;
buildArgumentsString = "$(ACTION)";
buildConfigurationList = 6FDEF7E021846BC700D8FBF6 /* Build configuration list for PBXLegacyTarget "WireGuardGoBridge" */;
buildPhases = (
);
buildToolPath = /usr/bin/make;
buildWorkingDirectory = "$(PROJECT_DIR)/../wireguard-go-bridge";
dependencies = (
);
name = WireGuardGoBridge;
passBuildSettingsInEnvironment = 1;
productName = WireGuardGoBridge;
};
/* End PBXLegacyTarget section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
6F5D0C19218352EF000F85AD /* WireGuardNetworkExtension */ = { 6F5D0C19218352EF000F85AD /* WireGuardNetworkExtension */ = {
isa = PBXNativeTarget; isa = PBXNativeTarget;
@ -236,6 +264,7 @@
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
6FDEF7E221846C0000D8FBF6 /* PBXTargetDependency */,
); );
name = WireGuardNetworkExtension; name = WireGuardNetworkExtension;
productName = WireGuardNetworkExtension; productName = WireGuardNetworkExtension;
@ -275,6 +304,9 @@
CreatedOnToolsVersion = 10.0; CreatedOnToolsVersion = 10.0;
LastSwiftMigration = 1000; LastSwiftMigration = 1000;
}; };
6FDEF7DD21846BC100D8FBF6 = {
CreatedOnToolsVersion = 10.0;
};
6FF4AC13211EC46F002C96EB = { 6FF4AC13211EC46F002C96EB = {
CreatedOnToolsVersion = 9.4.1; CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1000; LastSwiftMigration = 1000;
@ -301,6 +333,7 @@
targets = ( targets = (
6FF4AC13211EC46F002C96EB /* WireGuard */, 6FF4AC13211EC46F002C96EB /* WireGuard */,
6F5D0C19218352EF000F85AD /* WireGuardNetworkExtension */, 6F5D0C19218352EF000F85AD /* WireGuardNetworkExtension */,
6FDEF7DD21846BC100D8FBF6 /* WireGuardGoBridge */,
); );
}; };
/* End PBXProject section */ /* End PBXProject section */
@ -364,6 +397,11 @@
target = 6F5D0C19218352EF000F85AD /* WireGuardNetworkExtension */; target = 6F5D0C19218352EF000F85AD /* WireGuardNetworkExtension */;
targetProxy = 6F5D0C20218352EF000F85AD /* PBXContainerItemProxy */; targetProxy = 6F5D0C20218352EF000F85AD /* PBXContainerItemProxy */;
}; };
6FDEF7E221846C0000D8FBF6 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 6FDEF7DD21846BC100D8FBF6 /* WireGuardGoBridge */;
targetProxy = 6FDEF7E121846C0000D8FBF6 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */ /* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
@ -426,6 +464,36 @@
}; };
name = Release; name = Release;
}; };
6FDEF7DE21846BC100D8FBF6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEBUGGING_SYMBOLS = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = R2NV2FHE22;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
6FDEF7DF21846BC100D8FBF6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = R2NV2FHE22;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
6FF4AC24211EC472002C96EB /* Debug */ = { 6FF4AC24211EC472002C96EB /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 6FF4AC2B211EC776002C96EB /* Developer.xcconfig */; baseConfigurationReference = 6FF4AC2B211EC776002C96EB /* Developer.xcconfig */;
@ -599,6 +667,15 @@
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release; defaultConfigurationName = Release;
}; };
6FDEF7E021846BC700D8FBF6 /* Build configuration list for PBXLegacyTarget "WireGuardGoBridge" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6FDEF7DE21846BC100D8FBF6 /* Debug */,
6FDEF7DF21846BC100D8FBF6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
6FF4AC0F211EC46F002C96EB /* Build configuration list for PBXProject "WireGuard" */ = { 6FF4AC0F211EC46F002C96EB /* Build configuration list for PBXProject "WireGuard" */ = {
isa = XCConfigurationList; isa = XCConfigurationList;
buildConfigurations = ( buildConfigurations = (