Skip to content

Commit

Permalink
Make it easy to change the bundle ID
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed May 11, 2019
1 parent 632e4b8 commit ca00c48
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 29 deletions.
25 changes: 6 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,17 @@ You'll need these things to build the project:
- Clang and LLD (on mac, `brew install llvm`, on linux, `sudo apt install clang lld` or `sudo pacman -S clang lld` or whatever)
- sqlite3 (this is so common it may already be installed on linux and is definitely already installed on mac. if not, do something like `sudo apt install libsqlite3-dev`)

To set up your environment, cd to the project and run `meson build` to create a build directory in `build`. Then cd to the build directory and run `ninja`.

To set up a self-contained Alpine linux filesystem, download the Alpine minirootfs tarball for i386 from the [Alpine website](https://alpinelinux.org/downloads/) and run the `tools/fakefsify.py` script. Specify the minirootfs tarball as the first argument and the name of the output directory as the second argument. Then you can run things inside the Alpine filesystem with `./ish -f alpine /bin/login -f root`, assuming the output directory is called `alpine`.

You can replace `ish` with `tools/ptraceomatic` to run the program in a real process and single step and compare the registers at each step. I use it for debugging. Requires 64-bit Linux 4.11 or later.
## Build for iOS

To compile the iOS app, just open the Xcode project and click run. There are scripts that should download and set up the alpine filesystem and create build directories for cross compilation and so on automatically.
Open the project in Xcode and click Run. If you're not me, first open the project build settings and change the Product Bundle Identifier to something unique. There are scripts that should do everything else automatically. If you run into any problems, open an issue and I'll try to help.

## Further setup guide
## Build command line tool for testing

To enable local development there are a few more steps that needs to be done.

- Go to the project settings in Xcode find the "iSH" target
- Under "General" change the bundle identifier to a specific identifier for you
- Under "Capabilities" change the name of the "App Group" and remove the old app group

- Go to the "iSHFileProvider" target
- Under "General" use the same bundle identifier you created before and add `.FileProvider` to it
- Under "Capabilities" use the same name of the "App Group" as for the "iSH" target
To set up your environment, cd to the project and run `meson build` to create a build directory in `build`. Then cd to the build directory and run `ninja`.

- Go to the file `app/AppDelegate.m`
- Change the string in the function `manager containerURLForSecurityApplicationGroupIdentifier:` to your App Group name that you entered in the step before.
To set up a self-contained Alpine linux filesystem, download the Alpine minirootfs tarball for i386 from the [Alpine website](https://alpinelinux.org/downloads/) and run the `tools/fakefsify.py` script. Specify the minirootfs tarball as the first argument and the name of the output directory as the second argument. Then you can run things inside the Alpine filesystem with `./ish -f alpine /bin/login -f root`, assuming the output directory is called `alpine`.

Congratulations! You should now have the app running!
You can replace `ish` with `tools/ptraceomatic` to run the program in a real process and single step and compare the registers at each step. I use it for debugging. Requires 64-bit Linux 4.11 or later.

# A note on the JIT

Expand Down
2 changes: 1 addition & 1 deletion app/AboutViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[UIApplication openURL:@"https://discord.gg/SndDh5y"];
} else if (cell == self.exportContainerCell) {
// copy the files to the app container so they can be extracted from iTunes file sharing
NSURL *container = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:@"group.app.ish.iSH"];
NSURL *container = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:PRODUCT_APP_GROUP_IDENTIFIER];
NSURL *documents = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0];
[NSFileManager.defaultManager removeItemAtURL:[documents URLByAppendingPathComponent:@"roots copy"] error:nil];
[NSFileManager.defaultManager copyItemAtURL:[container URLByAppendingPathComponent:@"roots"]
Expand Down
2 changes: 1 addition & 1 deletion app/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ @implementation AppDelegate

- (int)startThings {
NSFileManager *manager = [NSFileManager defaultManager];
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:@"group.app.ish.iSH"];
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:PRODUCT_APP_GROUP_IDENTIFIER];
NSURL *alpineRoot = [container URLByAppendingPathComponent:@"roots/alpine"];
[manager createDirectoryAtURL:[container URLByAppendingPathComponent:@"roots"]
withIntermediateDirectories:YES
Expand Down
2 changes: 1 addition & 1 deletion app/FileProvider/FileProviderExtension.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (instancetype)init {
return nil;
self.mount->fs = &fakefs;
NSFileManager *manager = NSFileManager.defaultManager;
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:@"group.app.ish.iSH"];
NSURL *container = [manager containerURLForSecurityApplicationGroupIdentifier:PRODUCT_APP_GROUP_IDENTIFIER];
_root = [container URLByAppendingPathComponent:@"roots/alpine/data"];
self.mount->source = strdup(self.root.fileSystemRepresentation);
int err = self.mount->fs->mount(self.mount);
Expand Down
2 changes: 1 addition & 1 deletion app/FileProvider/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>NSExtension</key>
<dict>
<key>NSExtensionFileProviderDocumentGroup</key>
<string>group.app.ish.iSH</string>
<string>$(PRODUCT_APP_GROUP_IDENTIFIER)</string>
<key>NSExtensionFileProviderSupportsEnumeration</key>
<true/>
<key>NSExtensionPointIdentifier</key>
Expand Down
2 changes: 1 addition & 1 deletion app/FileProvider/iSHFileProvider.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.app.ish.iSH</string>
<string>$(PRODUCT_APP_GROUP_IDENTIFIER)</string>
</array>
</dict>
</plist>
2 changes: 1 addition & 1 deletion app/iSH.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.app.ish.iSH</string>
<string>$(PRODUCT_APP_GROUP_IDENTIFIER)</string>
</array>
</dict>
</plist>
14 changes: 10 additions & 4 deletions iSH.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = "PRODUCT_APP_GROUP_IDENTIFIER=@\\\"$(PRODUCT_APP_GROUP_IDENTIFIER)\\\"";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -1202,6 +1203,8 @@
ISH_LOG = "";
MESON_BUILD_DIR = "$(CONFIGURATION_BUILD_DIR)/meson";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_APP_GROUP_IDENTIFIER = "group.$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.staging;
SDKROOT = iphoneos;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -1233,6 +1236,7 @@
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = "PRODUCT_APP_GROUP_IDENTIFIER=@\\\"$(PRODUCT_APP_GROUP_IDENTIFIER)\\\"";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -1242,6 +1246,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
ISH_LOG = "";
MESON_BUILD_DIR = "$(CONFIGURATION_BUILD_DIR)/meson";
PRODUCT_APP_GROUP_IDENTIFIER = "group.$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.staging;
SDKROOT = iphoneos;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -1305,7 +1311,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1363,7 +1369,7 @@
INFOPLIST_FILE = app/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1407,7 +1413,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.FileProvider;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).FileProvider";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -1444,7 +1450,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.ish.iSH.FileProvider;
PRODUCT_BUNDLE_IDENTIFIER = "$(PRODUCT_BUNDLE_IDENTIFIER).FileProvider";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down

0 comments on commit ca00c48

Please sign in to comment.